public ResponseType DetectThrow()
        {
            var response  = ResponseType.Nothing;
            var diffImage = CaptureAndDiff();
            var moves     = diffImage.CountNonzero()[0];

            logger.Debug($"Moves is '{moves}'");
            var extractProcess = moves > movesExtraction;
            var throwDetected  = !extractProcess && moves > movesDart;

            if (throwDetected)
            {
                OriginFrame = videoCapture.QueryFrame().ToImage <Bgr, byte>();
                RoiFrame    = OriginFrame.Clone().Convert <Gray, byte>().Not();
                ThresholdRoi(RoiFrame);
                RefreshImages(diffImage);

                response = ResponseType.Trow;
            }

            if (extractProcess)
            {
                response = ResponseType.Extraction;
            }

            logger.Debug($"Response is '{response}'");
            return(response);
        }
        public void FindThrow()
        {
            logger.Debug($"Find throw for cam_{camNumber} start");

            OriginFrame = videoCapture.QueryFrame().ToImage <Bgr, byte>();
            RoiFrame    = OriginFrame.Clone().Convert <Gray, byte>().Not();
            ThresholdRoi(RoiFrame);
            var diffImage = CaptureAndDiff();

            RefreshImages(diffImage);

            logger.Debug($"Find throw for cam_{camNumber} end");
        }
Пример #3
0
        private void DoCapturesInternal(List <double> slidersData)
        {
            var roiRectangleTemp = new Rectangle(0,
                                                 (int)slidersData.ElementAt(2),
                                                 (int)slidersData.ElementAt(4),
                                                 (int)slidersData.ElementAt(3));

            OriginFrame  = videoCapture.QueryFrame().ToImage <Bgr, byte>();
            LinedFrame   = drawService.DrawSetupLines(OriginFrame.Clone(), slidersData);
            RoiFrame     = OriginFrame.Clone().Convert <Gray, byte>().Not();
            RoiFrame.ROI = roiRectangleTemp;
            RoiFrame._SmoothGaussian(smoothGauss);

            CvInvoke.Threshold(RoiFrame, RoiFrame, slidersData.ElementAt(5), 255, ThresholdType.Binary);
        }
        public void DoCapture(bool withRoiBackgroundRefresh = false)
        {
            logger.Debug($"Doing capture for cam_{camNumber} start. RoiBackgroundRefresh = {withRoiBackgroundRefresh}");

            GetSlidersData();
            DrawSetupLines();

            if (withRoiBackgroundRefresh)
            {
                OriginFrame = videoCapture.QueryFrame().ToImage <Bgr, byte>();
                RoiFrame    = OriginFrame.Clone().Convert <Gray, byte>().Not();
                ThresholdRoi(RoiFrame);
                RoiFrameBackground = RoiFrame.Clone();
                RoiLastThrowFrame  = RoiFrame.Clone();
                RefreshImageBoxes();
            }

            logger.Debug($"Doing capture for cam_{camNumber} end");
        }
        private void DrawSetupLines()
        {
            OriginFrame = videoCapture.QueryFrame().ToImage <Bgr, byte>();
            LinedFrame  = OriginFrame.Clone();

            roiRectangle = new Rectangle(0,
                                         (int)roiPosYSlider,
                                         resolutionWidth,
                                         (int)roiHeightSlider);

            drawService.DrawRectangle(LinedFrame,
                                      roiRectangle,
                                      drawService.camRoiRectColor.MCvScalar,
                                      drawService.camRoiRectThickness);

            surfacePoint1 = new PointF(0, (float)surfaceSlider);
            surfacePoint2 = new PointF(resolutionWidth,
                                       (float)surfaceSlider);
            drawService.DrawLine(LinedFrame,
                                 surfacePoint1,
                                 surfacePoint2,
                                 drawService.camSurfaceLineColor.MCvScalar,
                                 drawService.camSurfaceLineThickness);

            surfaceCenterPoint1 = new PointF((float)surfaceCenterSlider,
                                             (float)surfaceSlider);

            surfaceCenterPoint2 = new PointF(surfaceCenterPoint1.X,
                                             surfaceCenterPoint1.Y - 50);
            drawService.DrawLine(LinedFrame,
                                 surfaceCenterPoint1,
                                 surfaceCenterPoint2,
                                 drawService.camSurfaceLineColor.MCvScalar,
                                 drawService.camSurfaceLineThickness);

            surfaceLeftPoint1 = new PointF((float)surfaceCenterSlider - LinedFrame.Cols / 3,
                                           (float)surfaceSlider);

            surfaceRightPoint1 = new PointF((float)surfaceCenterSlider + LinedFrame.Cols / 3,
                                            (float)surfaceSlider);
        }