Ejemplo n.º 1
0
 protected void Dispose(bool IsDisposing)
 {
     if (_background != null)
     {
         _background.Dispose();
         _background = null;
     }
     if (_foreground != null)
     {
         _foreground.Dispose();
         _foreground = null;
     }
     if (_thresholded != null)
     {
         _thresholded.Dispose();
         _thresholded = null;
     }
     if (_calc1 != null)
     {
         _calc1.Dispose();
         _calc1 = null;
     }
     if (_strel != null)
     {
         _strel.Dispose();
         _strel = null;
     }
     if (_angleStore != null)
     {
         System.Runtime.InteropServices.Marshal.FreeHGlobal((IntPtr)_angleStore);
         _angleStore = null;
     }
 }
Ejemplo n.º 2
0
 protected virtual void Dispose(bool disposing)
 {
     if (_bgModel != null)
     {
         _bgModel.Dispose();
         _bgModel = null;
     }
     if (_calc != null)
     {
         _calc.Dispose();
         _calc = null;
     }
     if (_foreground != null)
     {
         _foreground.Dispose();
         _foreground = null;
     }
     if (_markerBuffer != null)
     {
         Marshal.FreeHGlobal((IntPtr)_markerBuffer);
         _markerBuffer = null;
     }
     if (_momentState != null)
     {
         ip.ippiMomentFree_64s(_momentState);
         _momentState = null;
     }
 }
Ejemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         if (_trackWriter != null)
         {
             _trackWriter.Dispose();
             _trackWriter = null;
         }
         if (_imageWriter != null)
         {
             _imageWriter.Dispose();
             _imageWriter = null;
         }
         if (_backgroundWriter != null)
         {
             _backgroundWriter.Dispose();
             _backgroundWriter = null;
         }
         if (_laser != null)
         {
             _laser.Dispose();
         }
         if (_scanner != null)
         {
             _scanner.Dispose();
         }
         if (_camRegion != null)
         {
             _camRegion.Dispose();
             _camRegion = null;
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Disposes the mask image
 /// </summary>
 public void Dispose()
 {
     if (_mask != null)
     {
         _mask.Dispose();
         _mask = null;
     }
 }
Ejemplo n.º 5
0
 public void Dispose()
 {
     if (isDisposed)
     {
         return;
     }
     gridImage.Dispose();
     isDisposed = true;
 }
Ejemplo n.º 6
0
 public void Dispose()
 {
     if (_mask != null)
     {
         _mask.Dispose();
         _mask = null;
     }
     IsDisposed = true;
 }
Ejemplo n.º 7
0
 protected virtual void Dispose(bool disposing)
 {
     if (background != null)
     {
         background.Dispose();
     }
     if (bgImage != null)
     {
         bgImage.Dispose();
     }
 }
Ejemplo n.º 8
0
 public virtual void Dispose()
 {
     _stop.Set();
     if (_canvas != null)
     {
         _canvas.Dispose();
         _canvas = null;
     }
     if (_color != null)
     {
         Marshal.FreeHGlobal((IntPtr)_color);
         _color = null;
     }
     IsDisposed = true;
 }
Ejemplo n.º 9
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (_bgModel != null)
     {
         _bgModel.Dispose();
         _bgModel = null;
     }
     if (_fgModel != null)
     {
         _fgModel.Dispose();
         _fgModel = null;
     }
     if (_calc != null)
     {
         _calc.Dispose();
         _calc = null;
     }
     if (_foreground != null)
     {
         _foreground.Dispose();
         _foreground = null;
     }
     if (_markerBuffer != null)
     {
         Marshal.FreeHGlobal((IntPtr)_markerBuffer);
         _markerBuffer = null;
     }
     if (_laser != null)
     {
         _laser.Dispose();
         _laser = null;
     }
     if (_scanner != null)
     {
         _scanner.Hit(new IppiPoint_32f(0.0f, 0.0f));
         _scanner.Dispose();
         _scanner = null;
     }
     if (_strel3x3 != null)
     {
         _strel3x3.Dispose();
         _strel3x3 = null;
     }
 }
Ejemplo n.º 10
0
 protected void Dispose(bool IsDisposing)
 {
     if (_imPrevious != null)
     {
         _imPrevious.Dispose();
         _imPrevious = null;
     }
     if (_imDelta != null)
     {
         _imDelta.Dispose();
         _imDelta = null;
     }
     if (_imThresh != null)
     {
         _imThresh.Dispose();
         _imThresh = null;
     }
 }
Ejemplo n.º 11
0
        public double GetMeanDifference(Image8 im1, Image8 im2)
        {
            var diff   = new double[1];
            var imDiff = new Image8(im1.Width, im1.Height);

            try
            {
                fixed(double *pDiff = diff)
                {
                    GetDifferenceImage(im1, im2, imDiff);
                    ip.ippiMean_8u_C1R(imDiff.Image, imDiff.Stride, imDiff.Size, pDiff);
                }
            }
            finally {
                imDiff.Dispose();
            }
            return(diff[0]);
        }
Ejemplo n.º 12
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (_histogramLevels != null)
     {
         Marshal.FreeHGlobal((IntPtr)_histogramLevels);
         _histogramLevels = null;
     }
     if (_hist != null)
     {
         Marshal.FreeHGlobal((IntPtr)_hist);
         _hist = null;
     }
     if (_wellCompare != null)
     {
         _wellCompare.Dispose();
         _wellCompare = null;
     }
     //Free memory of our parallel tracking buffers
     for (int i = 0; i < _parallelChunks; i++)
     {
         if (_parallelMarkerBuffers != null)
         {
             if (_parallelMarkerBuffers[i] != null)
             {
                 Marshal.FreeHGlobal((IntPtr)_parallelMarkerBuffers[i]);
                 _parallelMarkerBuffers[i] = null;
             }
         }
         if (_parallelMomentStates != null)
         {
             if (_parallelMomentStates[i] != null)
             {
                 ip.ippiMomentFree_64s(_parallelMomentStates[i]);
                 _parallelMomentStates[i] = null;
             }
         }
     }
 }
Ejemplo n.º 13
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_trackThread != null)
         {
             _trackThread.Dispose();
         }
         if (_frames != null)
         {
             _frames.Dispose();
         }
         if (_currentImage != null)
         {
             _currentImage.Dispose();
         }
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("Tracker not disposed properly. Dispose tracker before ditching last reference.");
     }
 }
Ejemplo n.º 14
0
 private void Dispose(bool disposing)
 {
     if (_bgModel != null)
     {
         _bgModel.Dispose();
         _bgModel = null;
     }
     if (_calc != null)
     {
         _calc.Dispose();
         _calc = null;
     }
     if (_foreground != null)
     {
         _foreground.Dispose();
         _foreground = null;
     }
     if (_bgSubtracted != null)
     {
         _bgSubtracted.Dispose();
         _bgSubtracted = null;
     }
     if (_markerBuffer != null)
     {
         Marshal.FreeHGlobal((IntPtr)_markerBuffer);
         _markerBuffer = null;
     }
     if (_momentState != null)
     {
         Marshal.FreeHGlobal((IntPtr)_momentState);
         _momentState = null;
     }
     if (_strel3x3 != null)
     {
         _strel3x3.Dispose();
         _strel3x3 = null;
     }
 }
Ejemplo n.º 15
0
        void TrackThreadRun(AutoResetEvent stop, IExperiment experiment)
        {
            //Set up image for small region around fish
            Image8           fishImage = new Image8(60, 60);
            CameraLinkCamera camera    = null;

            try
            {
                camera = new CameraLinkCamera(Properties.Settings.Default.CameraInterface);
                using (Image8 image = new Image8(camera.Width, camera.Height))
                {
                    if (experiment != null && experiment.SuggestedBufferSeconds != null)
                    {
                        int buffsize = (int)(experiment.SuggestedBufferSeconds.Value * FrameRate);
                        camera.Start(buffsize > 2 ? buffsize : 2);
                    }
                    else
                    {
                        camera.Start(100);//start camera with 100 frames in buffer by default
                    }
                    while (!stop.WaitOne(0))
                    {
                        try
                        {
                            FrameIndex = camera.Extract(image, FrameIndex) + 1;
                            IppiPoint?fishCentroid = null;
                            if (experiment != null)
                            {
                                if (!experiment.ProcessNext((int)FrameIndex, image, out fishCentroid))
                                {
                                    break;
                                }
                            }

                            //at 10Hz display camera and fish image
                            if (FrameIndex % (FrameRate / 10) == 0)
                            {
                                //blank the fish image
                                ip.ippiSet_8u_C1R(0, fishImage.Image, fishImage.Stride, fishImage.Size);
                                if (experiment is PreviewTrack && DisplayImage != ImageType.Camera)
                                {
                                    Image8       toHandle = null;
                                    PreviewTrack pt       = experiment as PreviewTrack;
                                    switch (DisplayImage)
                                    {
                                    case ImageType.Background:
                                        toHandle       = pt.Background;
                                        MainImage.CMax = 255;
                                        FishImage.CMax = 255;
                                        break;

                                    case ImageType.Foreground:
                                        toHandle       = pt.Foreground;
                                        MainImage.CMax = 255;
                                        FishImage.CMax = 255;
                                        break;

                                    default:
                                        toHandle       = pt.Thresholded;
                                        MainImage.CMax = 1;
                                        FishImage.CMax = 1;
                                        break;
                                    }
                                    if (toHandle != null)
                                    {
                                        if (fishCentroid != null)
                                        {
                                            CopyRegionImage(fishCentroid.Value, fishImage, toHandle);
                                        }
                                        MainImage.Write(toHandle, stop);
                                        FishImage.Write(fishImage, stop);
                                    }
                                }
                                else
                                {
                                    //In preview we also apply our mask
                                    if (experiment is PreviewTrack)
                                    {
                                        if (_maskImage == null || _maskImage.Width != image.Width || _maskImage.Height != image.Height)
                                        {
                                            if (_maskImage != null)
                                            {
                                                _maskImage.Dispose();
                                            }
                                            _maskImage = new Image8(image.Width, image.Height);
                                            DishCenter = new IppiPoint(_maskImage.Width / 2, _maskImage.Height / 2);
                                            CreateCircularMask(_maskImage, DishCenter, MaskRadius);
                                        }
                                        DrawMask(_maskImage, image);
                                    }

                                    if (fishCentroid != null)
                                    {
                                        CopyRegionImage(fishCentroid.Value, fishImage, image);
                                    }
                                    MainImage.CMax = 255;
                                    FishImage.CMax = 255;
                                    MainImage.Write(image, stop);
                                    FishImage.Write(fishImage, stop);
                                }
                            }
                        }
                        catch (OperationCanceledException)
                        {
                            break;
                        }
                    }
                }
            }
            catch (NIImaqException camException)
            {
                System.Diagnostics.Debug.WriteLine(camException);
            }
            finally
            {
                if (experiment != null && experiment is IDisposable)
                {
                    (experiment as IDisposable).Dispose();
                }
                if (camera != null)
                {
                    camera.Dispose();
                }
                if (fishImage != null)
                {
                    fishImage.Dispose();
                }
                if (IsRunning)
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() => { Stop(); });
                }
            }
        }
Ejemplo n.º 16
0
 protected override void Dispose(bool disposing)
 {
     _updateMask.Dispose();
     base.Dispose(disposing);
 }