Example #1
0
 public void Dispose()
 {
     if (IsDisposed)
     {
         return;
     }
     if (_analysisThread != null)
     {
         _analysisThread.Dispose();
         _analysisThread = null;
     }
     if (_smoother != null)
     {
         _smoother.Dispose();
         _smoother = null;
     }
     if (_mova != null)
     {
         _mova.Dispose();
         _mova = null;
     }
     if (_isb != null)
     {
         _isb.Dispose();
         _isb = null;
     }
     IsDisposed = true;
 }
Example #2
0
 /// <summary>
 /// Creates a new online bout detector with custom
 /// bout detection parameters
 /// </summary>
 /// <param name="chunkSize">The number of centroids to accumulate before processing</param>
 /// <param name="frameRate">The framerate of imaging</param>
 /// <param name="smoothingWindowSize">The size of the filtering window for centroid smoothing</param>
 /// <param name="speedThreshold">The absolute speed threshold in bout detection</param>
 /// <param name="minFramesPerBout">The minimum number of frames per bout</param>
 /// <param name="maxFramesAtPeak">The maximum number of peak frames in each bout</param>
 public OnlineBoutDetector(int chunkSize, int frameRate, int smoothingWindowSize, float speedThreshold, int minFramesPerBout, int maxFramesAtPeak)
 {
     if (frameRate < 1)
     {
         throw new ArgumentOutOfRangeException("The class only works with framerates of 1Hz or larger");
     }
     if (chunkSize < frameRate)
     {
         throw new ArgumentOutOfRangeException("The chunksize has to be the framerate or larger.");
     }
     _frameRate           = frameRate;
     _chunkSize           = chunkSize;
     _smoothingWindowSize = smoothingWindowSize;
     _speedThreshold      = speedThreshold;
     _minFramesPerBout    = minFramesPerBout;
     _maxFramesAtPeak     = maxFramesAtPeak;
     _centBuffers         = new CentroidBuffer[2];
     _centBuffers[0]      = new CentroidBuffer(_chunkSize);
     _centBuffers[1]      = new CentroidBuffer(_chunkSize);
     _isb                 = new InstantSpeedBuffer(_chunkSize);
     _smoother            = new CoordinateSmoother(_chunkSize, _smoothingWindowSize);
     _mova                = new MovementAnalyzer(_chunkSize);
     _currentActiveBuffer = 0;
     _centroidsReceived   = 0;
     _bufferReady         = new AutoResetEvent(false);
     _newCalcDoneSignal   = new AutoResetEvent(false);
     //start our analysis thread
     _analysisThread = new Worker(AnalyzeBouts, true, 3000);
 }