Пример #1
0
        private CamshiftOutput DoCamShift(Mat frame, Image <Bgr, byte> inputImage)
        {
            var input = new TrackingInput();

            if (_readyRectangle != Rectangle.Empty)
            {
                input.Config.ObjectOfInterest = _readyRectangle;
                input.Config.StartNewTrack    = true;
                _readyRectangle = Rectangle.Empty;
            }

            input.Captured = frame;

            var output = _camshiftDetector.Process(input);


            if (!output.ObjectOfInterest.Equals(RotatedRect.Empty))
            {
                var vertices = output.ObjectOfInterest.GetVertices();
                var points   = vertices.ToList().ConvertAll(f => f.ToPoint()).ToArray();
                CvInvoke.Polylines(inputImage, points, true, new Bgr(Color.Red).MCvScalar, 2);
            }

            return(output);
        }
        protected override CameraPanTiltProcessOutput DoProcess(CameraProcessInput input)
        {
            var trackingInput = new TrackingInput();

            trackingInput.Config           = TrackConfig;
            trackingInput.Captured         = input.Captured;
            trackingInput.SetCapturedImage = false;

            var camshiftOutput = _detector.Process(trackingInput);

            TrackConfig.StartNewTrack = false; // turn it off after inititalising

            CameraPanTiltProcessOutput output;

            if (camshiftOutput.HasObjectOfInterest)
            {
                var targetPoint = camshiftOutput.ObjectOfInterest.Center.ToPoint();
                output = ReactToTarget(targetPoint);
            }
            else
            {
                output = ReactToTarget(CentrePoint);
            }

            return(output);
        }