コード例 #1
0
 public LucasKanadeTracker(
     Size searchWindowSize,
     int levels,
     MCvTermCriteria terminationCriteria,
     LKFLOW_TYPE forwardFlags,
     LKFLOW_TYPE backwardFlags
     )
 {
     // save arguments
     _searchWindowSize    = searchWindowSize;
     _levels              = levels;
     _terminationCriteria = terminationCriteria;
     _forwardFlags        = forwardFlags;
     _backwardFlags       = backwardFlags;
 }
コード例 #2
0
ファイル: MainModel.cs プロジェクト: nithi89/code-browse
        private void CalculateOpticalFlow()
        {
            PointF[] trackedFeatures;
            float[]  trackedErrors;

            LKFLOW_TYPE flags = LKFLOW_TYPE.DEFAULT;

            if (this.TrackedFeatures != null)
            {
                // We have a prefilled pyramid
                m_PreviousPyrBufferParam = m_CurrentPyrBufferParam;
                flags = LKFLOW_TYPE.CV_LKFLOW_PYR_A_READY;
            }

            Emgu.CV.OpticalFlow.PyrLK(
                this.PreviousGrayImage,
                this.CurrentGrayImage,
                m_PreviousPyrBufferParam,
                m_CurrentPyrBufferParam,
                this.PreviousFoundFeatures,
                new Size(c_WinSize, c_WinSize),
                5,                 // level
                m_OpticalFlowTerminationCriteria,
                flags,
                out trackedFeatures,
                out m_TrackingStatus,
                out trackedErrors);

            this.TrackedFeatures = trackedFeatures;

            int notTrackedFeatures = 0;

            for (int i = 0; i < m_TrackingStatus.Length; i++)
            {
                if (m_TrackingStatus[i] == 0)
                {
                    notTrackedFeatures++;
                }
            }
            this.NotTrackedFeaturesCount = notTrackedFeatures;
        }
コード例 #3
0
ファイル: OpticalFlow.cs プロジェクト: nithi89/code-browse
        internal OpticalFlowResult CalculateOpticalFlow(Image <Gray, Byte> previousGrayImage, Image <Gray, Byte> currentGrayImage, PointF[] previousFoundFeaturePoints)
        {
            LKFLOW_TYPE flags = LKFLOW_TYPE.DEFAULT;

            if (m_PreviousPyrBufferParam != null)
            {
                // We have a prefilled pyramid
                m_PreviousPyrBufferParam = m_CurrentPyrBufferParam;
                flags = LKFLOW_TYPE.CV_LKFLOW_PYR_A_READY;
            }
            else
            {
                m_PreviousPyrBufferParam = new Image <Gray, byte>(currentGrayImage.Width + 8, currentGrayImage.Height / 3);
                m_CurrentPyrBufferParam  = new Image <Gray, byte>(currentGrayImage.Width + 8, currentGrayImage.Height / 3);
            }

            PointF[] trackedFeaturePoints;
            float[]  trackingErrors;
            byte[]   trackingStatusIndicators;

            Emgu.CV.OpticalFlow.PyrLK(
                previousGrayImage,
                currentGrayImage,
                m_PreviousPyrBufferParam,
                m_CurrentPyrBufferParam,
                previousFoundFeaturePoints,
                new Size(c_WinSize, c_WinSize),
                5,                 // level
                m_OpticalFlowTerminationCriteria,
                flags,
                out trackedFeaturePoints,
                out trackingStatusIndicators,
                out trackingErrors);

            this.OpticalFlowResult.TrackedFeaturePoints     = trackedFeaturePoints;
            this.OpticalFlowResult.TrackingStatusIndicators = trackingStatusIndicators;
            this.OpticalFlowResult.TrackingErrors           = trackingErrors;

            return(this.OpticalFlowResult);
        }