private MotionTrackingAnimation InitAnimation()
        {
            var gen         = new MotionTrackingAnimation();
            var shape       = GenerateRectangleAsPolygon();
            var targetColor = new Scalar(255, 255, 255);

            gen.Init(new Size(800, 600), new Scalar(0, 0, 0));
            gen.InitMotion(shape, targetColor);
            return(gen);
        }
        private void assertDetection(MotionTrackingAnimation anim, int animationIndex = 0)
        {
            const int frameNumberForInitialStabilization = 5;
            var       task = new MotionTrackingTask();

            task.Init(anim.GetTargetColor(animationIndex));
            for (int frameIndex = 0; frameIndex < anim.GetFrameCount(animationIndex); frameIndex++)
            {
                Mat frame = anim.GetFrame(frameIndex);
                task.TrackNextFrame(frame);

                if (frameIndex > frameNumberForInitialStabilization)
                {
                    Point currentPos      = task.GetCurrentPosition();
                    Point correctLocation = anim.GetCorrectLocation(animationIndex, frameIndex);
                    Assert.IsTrue(areNear(currentPos, correctLocation));
                }
            }
        }