コード例 #1
0
        public Tracker90mmDish(int imageWidth, int imageHeight, IppiPoint dishCenter)
        {
            _foreground   = new Image8(imageWidth, imageHeight);
            _bgSubtracted = new Image8(imageWidth, imageHeight);
            _calc         = new Image8(imageWidth, imageHeight);
            _dishCenter   = dishCenter;
            int bufferSize = 0;

            IppHelper.IppCheckCall(cv.ippiLabelMarkersGetBufferSize_8u_C1R(new IppiSize(imageWidth, imageHeight), &bufferSize));
            _markerBuffer = (byte *)Marshal.AllocHGlobal(bufferSize);
            int momentSize = 0;

            IppHelper.IppCheckCall(ip.ippiMomentGetStateSize_64f(IppHintAlgorithm.ippAlgHintNone, &momentSize));
            _momentState = (IppiMomentState_64f *)Marshal.AllocHGlobal(momentSize);
            //let ipp decide whether to give accurate or fast results
            IppHelper.IppCheckCall(ip.ippiMomentInit_64f(_momentState, IppHintAlgorithm.ippAlgHintNone));
            _frame = 0;
            //populate tracking parameters with default values
            _threshold        = 6;
            _minArea          = 11;
            _maxAllowedArea   = 120;
            _minEccentricity  = 0.3;
            _fullTrustMinArea = 20;
            _imageROI         = new IppiROI(0, 0, imageWidth, imageHeight);
            _searchRegionSize = 90;
            _removeCMOSISBrightLineArtefact = false;
            _strel3x3 = Morphology.Generate3x3Mask(_foreground.Size);
            //The following calculation for FramesInBackground means that after ~30s of movie
            //a stationary object will have dissappeared into the background (at 63% level)
            FramesInBackground      = (int)((30 * 250));
            FramesInitialBackground = 2 * 30 * 250;
            BGUpdateEvery           = 2;
        }
コード例 #2
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;
     }
 }