Example #1
0
        private static MedianFlowTracker LoadTracker()
        {
            MedianFlowTrackerBoundingBox bb        = LoadBoundingBox();
            LucasKanadeTracker           lkTracker = LoadLucasKanade();

            // fb error calculator
            MedianFlowTracker.FBError_Calculator fbErrorCalc = Service.FBError;

            // ncc calculator
            MedianFlowTracker.NCC_Calculator nccCalc = Service.NCC;

            // patch size
            Size patchSize = new Size(8, 8);

            // mad treshold
            float madTreshold = 10;

            return(new MedianFlowTracker
                   (
                       bb,
                       lkTracker,
                       fbErrorCalc,
                       nccCalc,
                       patchSize,
                       madTreshold
                   ));
        }
Example #2
0
        /// <summary>
        /// Instatiates a ready-to-go median flow tracker.
        /// All of its initial configuration is done here.
        /// </summary>
        private void InstantiateTracker()
        {
            // grid bounding box
            _gridBb = new MedianFlowTrackerBoundingBox
                      (
                new Size(10, 10),
                new SizeF(5, 5)
                      );

            // lucas kanade tracker
            _lkTracker = new LucasKanadeTracker(
                new Size(11, 11),
                2,
                new MCvTermCriteria(20, 0.03),
                LKFLOW_TYPE.DEFAULT,
                LKFLOW_TYPE.CV_LKFLOW_PYR_A_READY | LKFLOW_TYPE.CV_LKFLOW_PYR_B_READY
                );

            // fb error and ncc calculators
            _fbErrorCalc = Service.FBError;
            _nccCalc     = Service.NCC;

            // patch size for calculating NCC
            _patchSize = new Size(11, 11);

            // MAD treshold
            _madTrashold = 10;

            // ** instantiate the median flow tracker **
            _tracker = new MedianFlowTracker(
                _gridBb,
                _lkTracker,
                _fbErrorCalc,
                _nccCalc,
                _patchSize,
                _madTrashold
                );

            // initial frame
            _initialFrame = new Image <Gray, byte>(Path.Combine(_resourceDir, "violeta_5.jpg"));

            // initial bounding box
            _initialBB = new BoundingBox(
                new PointF(90, 81),
                new SizeF(70, 40)
                );

            // ** initialize the median flow tracker **
            _tracker.Initialize(_initialFrame, _initialBB);
        }