Exemplo n.º 1
0
        private void OnFrame(Mat image)
        {
            if (image == null || image.Ptr == IntPtr.Zero || !onProcessing)
            {
                return;
            }

            CvInvoke.Undistort(image, frame, mtxCamera, distCoeffs);

            /*  if(!bgAttach)
             * {
             *    bg = frame.Clone();
             *
             *    GRBL.Instance.LaserOn();
             *    Thread.Sleep(400);
             *    bgAttach = true;
             * }
             * else
             * {*/
            var processing = new ProcessingImageList(frame, bg, xstep);

            processingList.Enqueue(processing);

            GRBL.Instance.SetPositionX(xres, GRBL.Position.Relative);

            xstep += xres;

            if (xstep >= xmax)
            {
                OnFinalSucess();
                return;
            }

            /*
             *  CvInvoke.Imshow("W", bg);
             *  CvInvoke.Imshow("W2", frame);
             *  CvInvoke.WaitKey(2000);
             *
             *  GRBL.Instance.SetPositionX(xres, GRBL.Position.Relative);
             *
             *  xstep += xres;
             *
             *  if (xstep >= xmax)
             *  {
             *      OnFinalSucess();
             *      return;
             *  }
             *
             *  GRBL.Instance.LaserOff();
             *  Thread.Sleep(00);
             *  bgAttach = false;*/
        }
Exemplo n.º 2
0
        // Przetwarza klatki z kamery w czasie rzeczywistym.
        private void OnFrame(Mat image)
        {
            if (!onProcessingRunning && image == null && videoMainImage == null)
            {
                return;
            }

            //  Mat laser = CvInvoke.Imread("laser.png");
            //  Mat bg = CvInvoke.Imread("laser_background.png");

            //  var processing = new ProcessingImageList(bg, laser);
            //  processingList.Enqueue(processing);



            frame = image.Clone();

            // Tryb GRAYA - pokazuje obraz w odcieniu graya ( wszystkie kanaly na raz )
            if (mode == WorkMode.GrayMode)
            {
                CvInvoke.CvtColor(image, grayFrame, ColorConversion.Bgr2Gray);
                CvInvoke.Resize(grayFrame, grayFrame, new Size(640, 480), 0, 0, Inter.Linear);

                if (videoMainImage != null)
                {
                    videoMainImage.Image = grayFrame;
                }
            }

            // Tryb RGB - pokazuje obraz w trybie koloru ( wszystkie kanaly na raz ).
            else if (mode == WorkMode.RgbMode)
            {
                CvInvoke.Resize(image, rgbFrame, new Size(640, 480));

                if (videoMainImage != null)
                {
                    videoMainImage.Image = rgbFrame;
                }
            }
            else
            {
                var processing = new ProcessingImageList(bg, frame);
                processingList.Enqueue(processing);
                attachBg = false;
            }
        }