Accord.Vision.Tracking.MatchingTracker.track C# (CSharp) Method

track() private method

private track ( UnmanagedImage frame ) : void
frame Accord.Imaging.UnmanagedImage
return void
        private void track(UnmanagedImage frame)
        {
            if (searchWindow.Width < template.Width)
                searchWindow.Width = template.Width;
            if (searchWindow.Height < template.Height)
                searchWindow.Height = template.Height;

            searchWindow.Intersect(new Rectangle(0, 0, frame.Width, frame.Height));

            if (searchWindow.Width < template.Width || 
                searchWindow.Height < template.Height)
            {
                searchWindow.Inflate((int)(0.2f * searchWindow.Width),
                                     (int)(0.2f * searchWindow.Height));
                return;
            }

            // compare two images
            TemplateMatch obj = match(frame);

            // get object information
            int width = obj.Rectangle.Width;
            int height = obj.Rectangle.Height;

            // update object position
            updateObject(obj.Rectangle);


            // check similarity level
            if (!checkSteadiness(obj))
            {
                Reset(); return;
            }

             if (obj.Similarity >= 0.99)
             {
                 registerTemplate(frame, obj.Rectangle);
             }


            // Compute a new window size
            searchWindow = obj.Rectangle;

            if (obj.Similarity < 0.98)
                searchWindow.Inflate((int)(0.2f * width), (int)(0.2f * height));

            else
                searchWindow.Inflate((int)(0.1f * width), (int)(0.1f * height));
        }