public void Evaluate(int SpreadMax)
        {
            if (FFirstRun)
            {
                FPinOutOutput[0] = FOutput;
                FFirstRun        = false;
            }

            if (FPinInProperties.IsChanged)
            {
                FPayload = FPinInProperties[0];
                if (FPayload == null)
                {
                    FStatus[0] = "Needs properties";
                    FImage.Initialise(new Size(1, 1), TColourFormat.L8);
                    return;
                }

                FImage.Initialise(FPayload.FrameAttributes);
                FNeedsUpdate = true;
            }

            if (FNeedsUpdate || FPinInFrame.IsChanged)
            {
                Update();
                FNeedsUpdate = false;
            }
        }
Esempio n. 2
0
 public override void Allocate()
 {
     FGreyscale.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
     FPositive.Initialise(FGreyscale.ImageAttributes);
     FNegative.Initialise(FGreyscale.ImageAttributes);
     ScanSet.Allocate(FInput.ImageAttributes.Size);
 }
Esempio n. 3
0
        public override void Allocate()
        {
            FHsvImage.Initialise(FInput.ImageAttributes.Size, TColorFormat.HSV32F);
            FBuffer.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);

            FOutput.Image.Initialise(FInput.Image.ImageAttributes);

            FMult = FInput.ImageAttributes.BytesPerPixel > 4 ? float.MaxValue : byte.MaxValue;
        }
Esempio n. 4
0
        public override void Allocate()
        {
            FSize = FInput.ImageAttributes.Size;
            FOutput.Image.Initialise(FSize, TColorFormat.RGB32F);

            FCurrent.Initialise(FSize, TColorFormat.L8);
            FPrevious.Initialise(FSize, TColorFormat.L8);
            FVelocityX.Initialise(FSize, TColorFormat.L32F);
            FVelocityY.Initialise(FSize, TColorFormat.L32F);
        }
Esempio n. 5
0
        void Allocate()
        {
            lock (FLock)
            {
                FGreyscale.Initialise(FInput.ImageAttributes.Size, TColourFormat.L8);
                FHigh.Initialise(FGreyscale.ImageAttributes);
                FLow.Initialise(FGreyscale.ImageAttributes);
                FScanSet.Allocate(FInput.ImageAttributes.Size);

                FAllocated = true;
            }
        }
Esempio n. 6
0
        public override void Allocate()
        {
            TColorFormat AsGrayscale = TypeUtils.ToGrayscale(FInput.ImageAttributes.ColorFormat);

            FNeedsConversion = (AsGrayscale != FInput.ImageAttributes.ColorFormat);

            if (FNeedsConversion)
            {
                FGrayscale.Initialise(FInput.ImageAttributes.Size, AsGrayscale);
            }

            FOutput.Image.Initialise(FGrayscale.ImageAttributes);
        }
        public override void Allocate()
        {
            FOutFormat = ImageUtils.MakeGrayscale(FInput.ImageAttributes.ColorFormat);

            //if we can't convert or it's already grayscale, just pass through
            if (FOutFormat == TColorFormat.UnInitialised)
            {
                FOutFormat = FInput.ImageAttributes.ColorFormat;
            }

            FOutput.Image.Initialise(FInput.Image.ImageAttributes.Size, FOutFormat);

            FGrayScale.Initialise(FInput.Image.ImageAttributes.Size, FOutFormat);
        }
Esempio n. 8
0
        public void Evaluate(int SpreadMax)
        {
            if (FFirstRun)
            {
                FPinOutOutput[0] = new CVImageLink();
                FFirstRun        = false;
            }

            if (FPinInInput.IsChanged)
            {
                FScanSet = FPinInInput[0];
                if (FScanSet != null)
                {
                    FScanSet.UpdateAttributes += new EventHandler(FScanSet_UpdateAttributes);
                    FScanSet.UpdateData       += new EventHandler(FScanSet_UpdateData);

                    FAttributesUpdated = FScanSet.Initialised;
                    FDataUpdated       = FScanSet.DataAvailable;
                }
            }

            if (FAttributesUpdated)
            {
                FOutput.Initialise(FScanSet.CameraSize, TColourFormat.L8);
                FDataUpdated = FScanSet.DataAvailable;
                FAllocated   = true;

                FAttributesUpdated = false;
            }

            if (FDataUpdated || FPinInThreshold.IsChanged)
            {
                if (FAllocated)
                {
                    UpdateData();
                    FPinOutOutput[0].Send(FOutput);
                }

                FDataUpdated = false;
            }
        }
Esempio n. 9
0
 public override void Allocate()
 {
     FGrayScale.Initialise(FInput.Image.Size, TColorFormat.L8);
 }
 public override void Allocate()
 {
     FBgrImage.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.RGB8);
 }
        override public void Process()
        {
            if (!Enabled)
            {
                return;
            }

            if (!FGrayscale.Allocated || FGrayscale.Size != FInput.ImageAttributes.Size)
            {
                FGrayscale.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
            }

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

            Size SizeNow = BoardSize;

            PointF[] points = null;

            if (TestAtLowResolution)
            {
                if (!FLowResolution.Allocated)
                {
                    FLowResolution.Initialise(new Size(1024, 1024), TColorFormat.L8);
                }
                CvInvoke.cvResize(FGrayscale.CvMat, FLowResolution.CvMat, INTER.CV_INTER_LINEAR);
                var lowResPoints = CameraCalibration.FindChessboardCorners(FLowResolution.GetImage() as Image <Gray, byte>, SizeNow, CALIB_CB_TYPE.ADAPTIVE_THRESH);

                if (lowResPoints != null)
                {
                    int minX = FGrayscale.Width;
                    int minY = FGrayscale.Height;
                    int maxX = 0;
                    int maxY = 0;

                    foreach (var point in lowResPoints)
                    {
                        if ((int)point.X > maxX)
                        {
                            maxX = (int)point.X;
                        }

                        if ((int)point.Y > maxY)
                        {
                            maxY = (int)point.Y;
                        }

                        if ((int)point.X < minX)
                        {
                            minX = (int)point.X;
                        }

                        if ((int)point.Y < minY)
                        {
                            minY = (int)point.Y;
                        }
                    }

                    minX = minX * FGrayscale.Width / 1024;
                    maxX = maxX * FGrayscale.Width / 1024;
                    minY = minY * FGrayscale.Height / 1024;
                    maxY = maxY * FGrayscale.Height / 1024;

                    int boardResolutionMin = Math.Min(SizeNow.Width, SizeNow.Height);
                    int strideX            = (maxX - minX) / boardResolutionMin;
                    int strideY            = (maxY - minY) / boardResolutionMin;

                    minX -= strideX * 2;
                    maxX += strideX * 2;
                    minY -= strideY * 2;
                    maxY += strideY * 2;

                    if (minX < 0)
                    {
                        minX = 0;
                    }
                    if (minY < 0)
                    {
                        minY = 0;
                    }
                    if (maxX > FGrayscale.Width - 1)
                    {
                        maxX = FGrayscale.Width - 1;
                    }
                    if (maxY > FGrayscale.Height - 1)
                    {
                        maxY = FGrayscale.Height - 1;
                    }

                    Rectangle rect = new Rectangle(minX, minY, maxX - minX, maxY - minY);

                    CvInvoke.cvSetImageROI(FGrayscale.CvMat, rect);
                    FCropped.Initialise(new Size(rect.Width, rect.Height), TColorFormat.L8);
                    CvInvoke.cvCopy(FGrayscale.CvMat, FCropped.CvMat, IntPtr.Zero);
                    CvInvoke.cvResetImageROI(FGrayscale.CvMat);

                    points = CameraCalibration.FindChessboardCorners(FCropped.GetImage() as Image <Gray, byte>, SizeNow, CALIB_CB_TYPE.ADAPTIVE_THRESH);

                    if (points != null)
                    {
                        for (int iPoint = 0; iPoint < points.Length; iPoint++)
                        {
                            points[iPoint].X += minX;
                            points[iPoint].Y += minY;
                        }
                    }
                }
            }
            else
            {
                points = CameraCalibration.FindChessboardCorners(FGrayscale.GetImage() as Image <Gray, byte>, SizeNow, CALIB_CB_TYPE.ADAPTIVE_THRESH);
            }

            lock (FFoundPointsLock)
            {
                if (points == null)
                {
                    SearchFailed            = true;
                    FFoundPoints.SliceCount = 0;
                }
                else
                {
                    SearchSuccessful        = true;
                    FFoundPoints.SliceCount = SizeNow.Width * SizeNow.Height;
                    for (int i = 0; i < FFoundPoints.SliceCount; i++)
                    {
                        FFoundPoints[i] = new Vector2D(points[i].X, points[i].Y);
                    }
                }
            }
        }
 public override void Allocate()
 {
     FOutput.Image.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
     FBackground.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
 }
Esempio n. 13
0
 public override void Allocate()
 {
     FBuffer.Initialise(FInput.ImageAttributes);
 }
Esempio n. 14
0
 public override void Allocate()
 {
     FOutput.Image.Initialise(FInput.ImageAttributes);
     FLastFrame.Initialise(FInput.ImageAttributes);
 }
Esempio n. 15
0
 public override void Initialise()
 {
     FGrayScale.Initialise(FInput.Image.ImageAttributes.Size, TColourFormat.L8);
 }
Esempio n. 16
0
 public override void Allocate()
 {
     FOutput.Image.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
     FMask.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
     FUnmasked.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
 }
Esempio n. 17
0
 public override void Allocate()
 {
     Buffer.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
 }
Esempio n. 18
0
 public override void Allocate()
 {
     FImageGT.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
     FImageLT.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
     FOutput.Image.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
 }
Esempio n. 19
0
        public void Evaluate(int SpreadMax)
        {
            for (int i = SpreadMax; i < FOutput.SliceCount; i++)
                FOutput[i].Dispose();
            while (FOutput.SliceCount < SpreadMax)
                FOutput.Add(new CVImageLink());

            FStatus.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                if (!FDo[i])
                    continue;

                var inputSpread = FInput[i];
                var output = FOutput[i];

                foreach(var image in inputSpread)
                {
                    image.LockForReading();
                }

                CVImage result = new CVImage();
                try
                {
                    int size = inputSpread.SliceCount;

                    Image<Bgr, Byte>[] images = new Image<Bgr, byte>[size];
                    List<CVImage> ToDispose = new List<CVImage>();

                    for (int j = 0; j < size; j++)
                    {
                        if (inputSpread[j].FrontImage.ImageAttributes.ColourFormat == TColorFormat.RGB8)
                        {
                            images[j] = inputSpread[j].FrontImage.GetImage() as Image<Bgr, Byte>;
                        }
                        else
                        {
                            var image = new CVImage();
                            ToDispose.Add(image);
                            image.Initialise(inputSpread[j].FrontImage.Size, TColorFormat.RGB8);
                            inputSpread[j].FrontImage.GetImage(image);
                            images[j] = image.GetImage() as Image<Bgr, Byte>;
                        }
                    }

                    result.SetImage(FStitcher.Stitch(images));

                    foreach (var image in ToDispose)
                    {
                        image.Dispose();
                    }

                    FStatus[i] = "OK";
                }
                catch (Exception e)
                {
                    FStatus[i] = e.Message;
                }
                finally
                {
                    foreach(var image in inputSpread)
                    {
                        image.ReleaseForReading();
                    }
                }

                output.Send(result);
            }
        }
Esempio n. 20
0
 void UpdateAttributes(CVImageAttributes attributes)
 {
     FImage.Initialise(attributes);
 }
Esempio n. 21
0
        public void Evaluate(int SpreadMax)
        {
            for (int i = SpreadMax; i < FOutput.SliceCount; i++)
            {
                FOutput[i].Dispose();
            }
            while (FOutput.SliceCount < SpreadMax)
            {
                FOutput.Add(new CVImageLink());
            }

            FStatus.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                if (!FDo[i])
                {
                    continue;
                }

                var inputSpread = FInput[i];
                var output      = FOutput[i];

                foreach (var image in inputSpread)
                {
                    image.LockForReading();
                }

                CVImage result = new CVImage();
                try
                {
                    int size = inputSpread.SliceCount;

                    Image <Bgr, Byte>[] images    = new Image <Bgr, byte> [size];
                    List <CVImage>      ToDispose = new List <CVImage>();

                    for (int j = 0; j < size; j++)
                    {
                        if (inputSpread[j].FrontImage.ImageAttributes.ColourFormat == TColorFormat.RGB8)
                        {
                            images[j] = inputSpread[j].FrontImage.GetImage() as Image <Bgr, Byte>;
                        }
                        else
                        {
                            var image = new CVImage();
                            ToDispose.Add(image);
                            image.Initialise(inputSpread[j].FrontImage.Size, TColorFormat.RGB8);
                            inputSpread[j].FrontImage.GetImage(image);
                            images[j] = image.GetImage() as Image <Bgr, Byte>;
                        }
                    }

                    result.SetImage(FStitcher.Stitch(images));

                    foreach (var image in ToDispose)
                    {
                        image.Dispose();
                    }

                    FStatus[i] = "OK";
                }
                catch (Exception e)
                {
                    FStatus[i] = e.Message;
                }
                finally
                {
                    foreach (var image in inputSpread)
                    {
                        image.ReleaseForReading();
                    }
                }

                output.Send(result);
            }
        }