Пример #1
0
        override public void Process()
        {
            if (!Enabled)
            {
                return;
            }

            FInput.Image.GetImage(TColourFormat.L8, FGrayscale);

            Size SizeNow = BoardSize;

            PointF[] points = CameraCalibration.FindChessboardCorners(FGrayscale.GetImage() as Image <Gray, byte>, SizeNow, CALIB_CB_TYPE.ADAPTIVE_THRESH);

            lock (FFoundPointsLock)
            {
                if (points == null)
                {
                    FFoundPoints.SliceCount = 0;
                }
                else
                {
                    FFoundPoints.SliceCount = SizeNow.Width * SizeNow.Height;
                    for (int i = 0; i < FFoundPoints.SliceCount; i++)
                    {
                        FFoundPoints[i] = new Vector2D(points[i].X, points[i].Y);
                    }
                }
            }
        }
 void UpdateImage()
 {
     if (!FInput.Allocated)
     {
         return;
     }
     FInput.GetImage(FImage);
     FImageBox.Image = FImage.GetImage();
 }
Пример #3
0
 public void GetImage(CVImage target)
 {
     LockForReading();
     try
     {
         FFrontBuffer.GetImage(target);
     }
     finally
     {
         ReleaseForReading();
     }
 }
Пример #4
0
        public override void Process()
        {
            CVImage swap = FPrevious;

            FPrevious = FCurrent;
            FCurrent  = swap;

            FInput.Image.GetImage(TColourFormat.L8, FCurrent);

            Image <Gray, byte>  p  = FPrevious.GetImage() as Image <Gray, byte>;
            Image <Gray, byte>  c  = FCurrent.GetImage() as Image <Gray, byte>;
            Image <Gray, float> vx = FVelocityX.GetImage() as Image <Gray, float>;
            Image <Gray, float> vy = FVelocityY.GetImage() as Image <Gray, float>;

            OpticalFlow.HS(p, c, UsePrevious, vx, vy, FLambda, new MCvTermCriteria(FIterations));

            CopyToRgb();
            FOutput.Send();
        }
Пример #5
0
        public override void Process()
        {
            CVImage swap = FPrevious;

            FPrevious = FCurrent;
            FCurrent  = swap;

            FInput.Image.GetImage(TColourFormat.L8, FCurrent);

            Image <Gray, byte>  p  = FPrevious.GetImage() as Image <Gray, byte>;
            Image <Gray, byte>  c  = FCurrent.GetImage() as Image <Gray, byte>;
            Image <Gray, float> vx = FVelocityX.GetImage() as Image <Gray, float>;
            Image <Gray, float> vy = FVelocityY.GetImage() as Image <Gray, float>;

            OpticalFlow.LK(p, c, FWindowSize, vx, vy);

            CopyToRgb();
            FOutput.Send();
        }
Пример #6
0
        override public void Process()
        {
            if (!Enabled)
            {
                return;
            }

            FInput.Image.GetImage(TColourFormat.L8, FGrayscale);
            Image <Gray, byte> img = FGrayscale.GetImage() as Image <Gray, byte>;

            if (img != null)
            {
                //Seriously EmguCV? what the f**k is up with your syntax?
                //both ways of skinning this cat involve f*****g a moose

                List <ContourTempData> results = new List <ContourTempData>();
                ContourTempData        c;

                try
                {
                    CHAIN_APPROX_METHOD cam;

                    switch (Approximation)
                    {
                    case ContourApproximation.None:
                        cam = CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE;
                        break;

                    case ContourApproximation.TehChinKCOS:
                        cam = CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_TC89_KCOS;
                        break;

                    case ContourApproximation.TehChinL1:
                        cam = CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_TC89_L1;
                        break;

                    case ContourApproximation.LinkRuns:
                        cam = CHAIN_APPROX_METHOD.CV_LINK_RUNS;
                        break;

                    case ContourApproximation.Simple:
                    case ContourApproximation.Poly:
                    default:
                        cam = CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE;
                        break;
                    }

                    Contour <Point> contour = img.FindContours(cam, RETR_TYPE.CV_RETR_LIST);

                    for (; contour != null; contour = contour.HNext)
                    {
                        c        = new ContourTempData();
                        c.Area   = contour.Area;
                        c.Bounds = contour.BoundingRectangle;

                        if (Approximation == ContourApproximation.Poly)
                        {
                            c.Perimeter = new ContourPerimeter(contour.ApproxPoly(FPolyAccuracy), img.Width, img.Height);
                        }
                        else
                        {
                            c.Perimeter = new ContourPerimeter(contour, img.Width, img.Height);
                        }

                        results.Add(c);
                    }


                    lock (FLockResults)
                        FStatus = "OK";
                }
                catch (Exception e)
                {
                    lock (FLockResults)
                        FStatus = e.Message;
                }

                lock (FLockResults)
                {
                    FBoundingBox.SliceCount = results.Count;
                    FArea.SliceCount        = results.Count;
                    FPerimeter.SliceCount   = results.Count;

                    for (int i = 0; i < results.Count; i++)
                    {
                        c = results[i];

                        FBoundingBox[i] = new Vector4D(((double)c.Bounds.X / (double)img.Width) * 2.0d - 1.0d,
                                                       1.0d - ((double)c.Bounds.Y / (double)img.Height) * 2.0d,
                                                       (double)c.Bounds.Width * 2.0d / (double)img.Width,
                                                       (double)c.Bounds.Height * 2.0d / (double)img.Height);

                        FArea[i] = (double)c.Area * (4.0d / (double)(img.Width * img.Height));

                        FPerimeter[i] = c.Perimeter;
                    }
                }
            }
        }