Exemplo n.º 1
0
        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);
        }