Exemplo n.º 1
0
        private VisionImage GetNextImage()
        {
            VisionImage toReturn;

            // Load an image or return to the previous image.
            if (imageNumber >= images.Count)
            {
                toReturn = new VisionImage();
                toReturn.ReadFile(System.IO.Path.Combine(imagePath, "Roundcard " + String.Format("{0:00}", imageNumber + 1) + ".tif"));
                images.Add(toReturn);
            }
            else
            {
                toReturn = images[imageNumber];
                // Clear any calibration information or overlays.
                toReturn.RemoveVisionInfo(InfoTypes.Calibration | InfoTypes.Overlay);
            }

            // Advance the image number to the next image
            imageNumber++;
            if (imageNumber >= maxImageNumber)
            {
                imageNumber = 0;
            }
            return(toReturn);
        }
Exemplo n.º 2
0
        private VisionImage GetNextImage()
        {
            VisionImage toReturn;

            // Load an image or return to the previous image.
            if (imageNumber >= images.Count)
            {
                toReturn = new VisionImage();
                toReturn.ReadFile(System.IO.Path.Combine(imagePath, "Image" + String.Format("{0:00}", imageNumber) + ".jpg"));
                images.Add(toReturn);
            }
            else
            {
                toReturn = images[imageNumber];
                // Remove any overlays.
                toReturn.Overlays.Default.Clear();
            }

            // Advance the image number to the next image
            imageNumber++;
            if (imageNumber > 14)
            {
                imageNumber = 0;
            }
            return(toReturn);
        }
Exemplo n.º 3
0
        private VisionImage GetNextImage()
        {
            VisionImage nextImage;

            // Load an image or return to the previous image.
            if (imageNumber >= images.Count)
            {
                nextImage = new VisionImage();
                nextImage.ReadFile(System.IO.Path.Combine(imagePath, "Image" + String.Format("{0:00}", imageNumber) + ".jpg"));
                images.Add(nextImage);
            }
            else
            {
                nextImage = images[imageNumber];
                // Clear any overlays
                nextImage.Overlays.Default.Clear();
            }

            // Advance the number number to the next image
            imageNumber++;
            if (imageNumber > 6)
            {
                imageNumber = 0;
            }
            return(nextImage);
        }
        public HttpResponseMessage Post()
        {
            HttpResponseMessage result = null;
            var httpRequest            = HttpContext.Current.Request;

            var form = httpRequest.Form;

            if (form.Count == 2)
            {
                string param1 = form.Get(0);
                string param2 = form.Get(1);
            }

            VisCalculation calc = new VisCalculation();

            //VisCalculationSize calcSize = new VisCalculationSize();

            if (httpRequest.Files.Count > 0)
            {
                var docfiles = new List <string>();
                foreach (string file in httpRequest.Files)
                {
                    var postedFile = httpRequest.Files[file];
                    //string myFile = Server.MapPath("images") + "\" + FileUpload1.PostedFile.FileName;
                    string fileName  = Path.GetFileName(postedFile.FileName);
                    string foderDate = DateTime.Now.ToString("yyyyMMdd");

                    var    filePath = HttpContext.Current.Server.MapPath("~/images/" + foderDate + "/" + fileName); //postedFile.FileName);
                    string fullPath = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fullPath))
                    {
                        Directory.CreateDirectory(fullPath);
                    }
                    postedFile.SaveAs(filePath);

                    //Image image = Image.FromFile(HttpContext.Current.Server.MapPath("~/images/" + foderDate + "/" + fileName));

                    FileInformation fileinfo = Algorithms.GetFileInformation(filePath);
                    VisionImage     image    = new VisionImage();
                    image.Type = fileinfo.ImageType;
                    image.ReadFile(filePath);
                    //calculation grain type
                    calc = new VisCalculation(image);
                    //calculation grain size
                    //calcSize = new VisCalculationSize(image);

                    docfiles.Add(filePath);
                }
                //result = Request.CreateResponse(HttpStatusCode.Created, docfiles);
                result = Request.CreateResponse(HttpStatusCode.OK, calc.GrainResults);
            }
            else
            {
                //result = Request.CreateResponse(HttpStatusCode.BadRequest);
                VisGrainTypeCollection cols = new VisGrainTypeCollection();
                cols.Message = "BadRequest";
                result       = Request.CreateResponse(HttpStatusCode.OK, cols);
            }
            return(result);
        }
Exemplo n.º 5
0
        private void GetNextImage(VisionImage dest)
        {
            VisionImage nextImage;

            // Load an image or return to the previous image
            if (imageNumber >= images.Count)
            {
                nextImage = new VisionImage();
                nextImage.ReadFile(System.IO.Path.Combine(ExampleImagesFolder.GetExampleImagesFolder(), @"Parts\Parts0" + imageNumber + ".png"));
                images.Add(nextImage);
            }
            else
            {
                nextImage = images[imageNumber];
                // Clear any overlays.
                nextImage.Overlays.Default.Clear();
            }
            // Copy the image to the destination image
            Algorithms.Copy(nextImage, dest);

            // Advance the image number to the next image
            imageNumber++;
            if (imageNumber > 4)
            {
                imageNumber = 0;
            }
        }
Exemplo n.º 6
0
        private void loadTargetButton_Click(object sender, EventArgs e)
        {
            // Load Calibration Grid image.
            uncorrectedImage.ReadFile(System.IO.Path.Combine(ExampleImagesFolder.GetExampleImagesFolder(), "Distorted coins.png"));
            imageViewer1.Attach(uncorrectedImage);

            measurePartsButton.Enabled = true;
        }
Exemplo n.º 7
0
        private void loadCalibrationButton_Click(object sender, EventArgs e)
        {
            // Load the calibration grid image.
            calibrationTemplate.ReadFile(System.IO.Path.Combine(ExampleImagesFolder.GetExampleImagesFolder(), "Calibration grid.tif"));
            imageViewer1.Attach(calibrationTemplate);

            // Update command buttons.
            learnCalibrationButton.Enabled = true;
            measureDistancesButton.Enabled = false;
        }
Exemplo n.º 8
0
        void _Subject_Ran(ImageData imageData)
        {
            try
            {
                bmp = ImageFactory.CreateBitmap(_Subject.OutputImageData);
                bmp.Save($"{ @"./ImageTemp/temp.jpg"}");

                VI = new VisionImage(ImageType.Rgb32);
                VI.ReadFile($"{ @"./ImageTemp/temp.jpg"}");

                log.Debug("相机完成" + ReceiveCmd + "图像采集");
            }
            catch
            {
                bmp = null;
            }
            try
            {
                log.Debug("程序执行:" + ReceiveCmd + "处理流程");
                switch (ReceiveCmd)
                {
                case "C3":    //外工位定位
                    LeftPosProcess(VI, bmp);

                    break;

                case "C4":    //外工位点胶检查
                    LeftGlueCheck(VI, bmp, Position.Instance.GlueComspec, Position.Instance.GlueMarkspec);

                    break;

                case "C1":    //里工位定位
                    RightPosProcess(VI, bmp);

                    break;

                case "C2":    //里工位点胶检查
                    RightGlueCheck(VI, bmp, Position.Instance.GlueComspec, Position.Instance.GlueMarkspec);

                    break;

                default:
                    break;
                }
            }
            catch
            {
                log.Debug(ReceiveCmd + "图像识别异常!");
            }
            finally
            {
                frmAAVision.Writestring(frmAAVision.SendHandle, SendCmd);
            }
        }
Exemplo n.º 9
0
        private void loadCalibrationButton_Click(object sender, EventArgs e)
        {
            // Load Calibration Grid image.
            calibrationTemplate.ReadFile(System.IO.Path.Combine(ExampleImagesFolder.GetExampleImagesFolder(), "Nonlinear grid.png"));
            imageViewer1.Attach(calibrationTemplate);

            // Update command buttons.
            learnCalibrationButton.Enabled = true;
            loadTargetButton.Enabled       = false;
            measurePartsButton.Enabled     = false;
        }
Exemplo n.º 10
0
 private void RightCheck_Click(object sender, EventArgs e)
 {
     if (cboxLocal.Checked)
     {
         ImagePreviewFileDialog imageDialog = new ImagePreviewFileDialog();
         if (imageDialog.ShowDialog() == DialogResult.OK)
         {
             LocalVI = new VisionImage(ImageType.Rgb32);
             LocalVI.ReadFile(imageDialog.FileName);
             InputImage = new Bitmap(Image.FromFile(imageDialog.FileName));
             edit.RightGlueCheck(LocalVI, InputImage, (double)numComspec.Value, (double)numMarkspec.Value);
         }
     }
     else
     {
         edit.ReceiveCmd = "C2";
         Acquire();
     }
 }
Exemplo n.º 11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string imageDirPath = GetPath();

            // Read the character set and options from the character set file "Lot Number.abc"
            session = new OcrSession(imageDirPath + @"\Lot Number.abc");
            foreach (string file in System.IO.Directory.GetFiles(imageDirPath, "*.bmp"))
            {
                VisionImage image = new VisionImage();
                image.ReadFile(file);
                images.Add(image);
            }

            // Attach the image to the viewer
            imageViewer1.Attach(curImage);
            imageNumber     = 0;
            timer1.Enabled  = false;
            timer1.Interval = (int)delay.Value;
        }
Exemplo n.º 12
0
 private void RightPos_Click(object sender, EventArgs e)
 {
     if (cboxLocal.Checked)
     {
         ImagePreviewFileDialog imageDialog = new ImagePreviewFileDialog();
         if (imageDialog.ShowDialog() == DialogResult.OK)
         {
             LocalVI = new VisionImage(ImageType.Rgb32);
             LocalVI.ReadFile(imageDialog.FileName);
             InputImage = new Bitmap(Image.FromFile(imageDialog.FileName));
             edit.RightPosProcess(LocalVI, InputImage);
         }
     }
     else
     {
         edit.ReceiveCmd = "C1";
         Acquire();
     }
 }
Exemplo n.º 13
0
        private void measureDistancesButton_Click(object sender, EventArgs e)
        {
            // In a point-based measurement, it is not necessary to correct the image.  The
            // coordinates of the fiducial points can be found and transformed to real-world
            // coordinates.  All point measurements can then be performed on these
            // coordinates.

            // Load the Distortion Target image.
            testImage.ReadFile(System.IO.Path.Combine(ExampleImagesFolder.GetExampleImagesFolder(), "Distortion target.tif"));

            // Copy the calibration information from the calibrated image to the test image.
            Algorithms.CopyCalibrationInformation(calibrationTemplate, testImage);

            // Initialize the two search lines.
            Collection <LineContour> searchLines = new Collection <LineContour>();

            searchLines.Add(new LineContour(new PointContour(150, 250), new PointContour(490, 248.57)));
            searchLines.Add(new LineContour(new PointContour(318, 165), new PointContour(319.62, 340)));

            foreach (Direction d in new Direction[] { Direction.Horizontal, Direction.Vertical })
            {
                // Detect the edges along a line and convert the coordinates of the edge points
                // to real-world coordinates.
                EdgeReport report = Algorithms.EdgeTool(testImage, new Roi(new Shape[] { searchLines[d == Direction.Horizontal ? 0 : 1] }), EdgeProcess.All);
                Collection <PointContour> pixelPoints     = new Collection <PointContour>();
                Collection <PointContour> realWorldPoints = new Collection <PointContour>();
                foreach (EdgeInfo info in report.Edges)
                {
                    pixelPoints.Add(info.Position);
                    realWorldPoints.Add(info.CalibratedPosition);
                }
                Collection <PointContour> realWorldPoints2 = Algorithms.ConvertPixelToRealWorldCoordinates(testImage, pixelPoints).Points;
                MeasureDistortionTarget(testImage, pixelPoints, realWorldPoints, d);
            }

            imageViewer1.Attach(testImage);
        }
Exemplo n.º 14
0
 private void LoadSelectedImage()
 {
     source.ReadFile(imagePath.Text);
     InvertImage();
 }
Exemplo n.º 15
0
 private void ReadNoisyImage(VisionImage image, int index)
 {
     image.ReadFile(System.IO.Path.Combine(imagePath, "noise-" + String.Format("{0:00}", index) + ".png"));
 }
Exemplo n.º 16
0
        public HttpResponseMessage Post()
        {
            HttpResponseMessage result = null;
            var httpRequest            = HttpContext.Current.Request;

            var form = httpRequest.Form;

            VisCalculation calc = new VisCalculation();
            //VisCalculationSize calcSize = new VisCalculationSize();

            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["GrainConnection"].ConnectionString;


            if (httpRequest.Files.Count > 0)
            {
                var    docfiles = new List <string>();
                string fileName = "";
                foreach (string file in httpRequest.Files)
                {
                    var postedFile = httpRequest.Files[file];
                    //string myFile = Server.MapPath("images") + "\" + FileUpload1.PostedFile.FileName;
                    fileName = Path.GetFileName(postedFile.FileName);
                    string foderDate = DateTime.Now.ToString("yyyyMMdd");

                    var    filePath = HttpContext.Current.Server.MapPath("~/images/" + foderDate + "/" + fileName); //postedFile.FileName);
                    string fullPath = Path.GetDirectoryName(filePath);
                    if (!Directory.Exists(fullPath))
                    {
                        Directory.CreateDirectory(fullPath);
                    }
                    postedFile.SaveAs(filePath);

                    //Image image = Image.FromFile(HttpContext.Current.Server.MapPath("~/images/" + foderDate + "/" + fileName));

                    FileInformation fileinfo = Algorithms.GetFileInformation(filePath);
                    VisionImage     image    = new VisionImage();
                    image.Type = fileinfo.ImageType;
                    image.ReadFile(filePath);
                    //calculation grain type
                    calc = new VisCalculation(image);
                    //calculation grain size
                    //calcSize = new VisCalculationSize(image);

                    docfiles.Add(filePath);
                }
                //save to database
                string user = "";
                double lat  = 1000;
                double lng  = 1000;
                if (form.Count > 0)
                {
                    var items = form.AllKeys.SelectMany(form.GetValues, (k, v) => new { key = k, value = v });
                    foreach (var item in items)
                    {
                        //Console.WriteLine("{0} {1}", item.key, item.value);
                        if (item.key.Equals("USER_ID"))
                        {
                            user = item.value;
                        }
                        else if (item.key.Equals("LATITUDE"))
                        {
                            Double.TryParse(item.value, out lat);
                        }
                        else if (item.key.Equals("LONGITUDE"))
                        {
                            Double.TryParse(item.value, out lng);
                        }
                    }

                    /*
                     * int pos = 0;
                     * string param1 = "";
                     * string param2 = "";
                     * string param3 = "";
                     * foreach (var item in items)
                     * {
                     *  //Console.WriteLine("{0} {1}", item.key, item.value);
                     *  if (pos == 0)
                     *  {
                     *      //param1 = item.key;
                     *      param1 = item.value;
                     *  }
                     *  else if (pos == 1)
                     *  {
                     *      //param2 = item.key;
                     *      param2 = item.value;
                     *  }
                     *  else if (pos == 2)
                     *  {
                     *      //param3 = item.key;
                     *      param3 = item.value;
                     *  }
                     *  pos = pos + 1;
                     * } */

                    //string param1 = "form.Get(0)";
                    //string param2 = "form.Get(1)";
                    //string param3 = "form.Get(2)";

                    //if (!user.Equals("") && lat != 1000 && lng !=1000)
                    //{
                    SqlConnection con = new SqlConnection(connectionString);
                    try
                    {
                        con.Open();
                        string json = JsonConvert.SerializeObject(calc.GrainResults);
                        string sql  = "INSERT INTO G_RESULT (DATE_STAMP, USER_ID, LATITUDE, LONGITUDE, FILE_NAME, RESULT) VALUES('" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss") + "','" + user + "','" + Convert.ToString(lat) + "','" + Convert.ToString(lng) + "','" + fileName + "','" + json + "');";
                        //string sql = "INSERT INTO G_TEST1 (PARAM1, PARAM2, PARAM3) VALUES('" + param1 + "','" + param2 + "','" + param3 + "');";
                        SqlCommand cmd = new SqlCommand(sql, con);
                        cmd.CommandType = System.Data.CommandType.Text;
                        int ret = cmd.ExecuteNonQuery();
                        //msg = "Success";
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        //msg = ex.Message;
                    }
                    //}
                }


                result = Request.CreateResponse(HttpStatusCode.OK, calc.GrainResults);
                //result = Request.CreateResponse(HttpStatusCode.OK, user + ", " + Convert.ToString(lat) + ", " + Convert.ToString(lng));
            }
            else
            {
                //result = Request.CreateResponse(HttpStatusCode.BadRequest);
                VisGrainTypeCollection cols = new VisGrainTypeCollection();
                cols.Message = "BadRequest";
                //string msg = "";

                //cols.Message = msg; // connectionString;
                result = Request.CreateResponse(HttpStatusCode.OK, cols);
            }
            return(result);
        }
Exemplo n.º 17
0
 private void LoadNextImage(VisionImage image)
 {
     // Load a random image from the image directory.
     image.ReadFile(filenames[r.Next(filenames.Count)]);
 }
Exemplo n.º 18
0
        public static PaletteType ProcessImage(VisionImage image, string path, out double[] distance)
        {
            // Initialize the IVA_Data structure to pass results and coordinate systems.
            IVA_Data ivaData = new IVA_Data(17, 1);

            distance = new double[4] {
                0, 0, 0, 0
            };

            // Creates a new, empty region of interest.
            Roi roi = new Roi();
            // Creates a new AnnulusContour using the given values.
            PointContour   vaCenter = new PointContour(1283, 965);
            AnnulusContour vaOval   = new AnnulusContour(vaCenter, 418, 702, 0, 0);

            roi.Add(vaOval);
            // Find Circular Edge
            EdgeOptions vaOptions = new EdgeOptions();

            vaOptions.ColumnProcessingMode = ColumnProcessingMode.Average;
            vaOptions.InterpolationType    = InterpolationMethod.Bilinear;
            vaOptions.KernelSize           = 3;
            vaOptions.MinimumThreshold     = 18;
            vaOptions.Polarity             = EdgePolaritySearchMode.Rising;
            vaOptions.Width = 3;
            CircularEdgeFitOptions vaFitOptions = new CircularEdgeFitOptions();

            vaFitOptions.ProcessType    = RakeProcessType.GetFirstEdges;
            vaFitOptions.StepSize       = 7;
            vaFitOptions.MaxPixelRadius = 3;

            vaCircularEdgeReport = IVA_FindCircularEdge(image, roi, SpokeDirection.InsideToOutside, vaOptions, vaFitOptions, ivaData, 1);

            roi.Dispose();

            // Set Coordinate System
            int             vaCoordSystemIndex    = 0;
            int             stepIndexOrigin       = 1;
            int             resultIndexOrigin     = 0;
            int             stepIndexAngle        = -1;
            int             resultIndexAngle      = 0;
            double          refSysOriginX         = vaCircularEdgeReport.Center.X;
            double          refSysOriginY         = vaCircularEdgeReport.Center.Y;
            double          refSysAngle           = 0;
            AxisOrientation refSysAxisOrientation = AxisOrientation.Direct;
            int             vaCoordSystemType     = 0;

            IVA_CoordSys(vaCoordSystemIndex, stepIndexOrigin, resultIndexOrigin, stepIndexAngle, resultIndexAngle, refSysOriginX, refSysOriginY, refSysAngle, refSysAxisOrientation, vaCoordSystemType, ivaData);

            // Image Buffer: Push
            Functions.IVA_PushBuffer(ivaData, image, 0);

            // Get Image
            string          vaFilePath = path;
            FileInformation vaFileInfo = Algorithms.GetFileInformation(vaFilePath);

            // Set the image size to 0 to speed up the cast.
            //image.SetSize(0, 0);
            //image.Type = vaFileInfo.ImageType;
            //image.BitDepth = 0;
            image.ReadFile(vaFilePath);

            switch (image.Type)
            {
            case ImageType.I16:
            case ImageType.U16:
                if (image.BitDepth == 0 & false)
                {
                    image.BitDepth = 10;
                }
                break;

            default:
                break;
            }
            // Operators: Absolute Difference Image
            Algorithms.AbsoluteDifference(image, Functions.IVA_GetBuffer(ivaData, 0), image);

            // Creates a new, empty region of interest.
            Roi roi2 = new Roi();
            // Creates a new AnnulusContour using the given values.
            PointContour   vaCenter2 = new PointContour(vaCircularEdgeReport.Center.X, vaCircularEdgeReport.Center.Y);
            AnnulusContour vaOval2   = new AnnulusContour(vaCenter2, 527, 846, 0, 0);

            roi2.Add(vaOval2);
            // Reposition the region of interest based on the coordinate system.
            int coordSystemIndex = 0;

            Algorithms.TransformRoi(roi2, new CoordinateTransform(ivaData.baseCoordinateSystems[coordSystemIndex], ivaData.MeasurementSystems[coordSystemIndex]));
            // Mask from ROI
            IVA_Mask_From_ROI(image, roi2, false, false);
            roi2.Dispose();

            // Color Threshold
            Range plane1Range = new Range(0, 60);
            Range plane2Range = new Range(0, 50);
            Range plane3Range = new Range(0, 255);

            using (VisionImage thresholdImage = new VisionImage(ImageType.U8, 7))
            {
                Algorithms.ColorThreshold(image, thresholdImage, ColorMode.Rgb, 1, plane1Range, plane2Range, plane3Range);
                Algorithms.Copy(thresholdImage, image);
            }

            // Truncates the frequencies of an image.
            IVA_FFT_Truncate(image, TruncateMode.High, 7);

            // Advanced Morphology: Remove Objects
            int[] vaCoefficients            = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
            StructuringElement vaStructElem = new StructuringElement(3, 3, vaCoefficients);

            vaStructElem.Shape = StructuringElementShape.Square;
            // Filters particles based on their size.
            Algorithms.RemoveParticle(image, image, 30, SizeToKeep.KeepLarge, Connectivity.Connectivity8, vaStructElem);

            // Invert Binary Image.
            IVA_BinaryInverse(image);

            // Advanced Morphology: Remove Objects
            int[] vaCoefficients2            = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
            StructuringElement vaStructElem2 = new StructuringElement(3, 3, vaCoefficients2);

            vaStructElem.Shape = StructuringElementShape.Square;
            // Filters particles based on their size.
            Algorithms.RemoveParticle(image, image, 5, SizeToKeep.KeepLarge, Connectivity.Connectivity8, vaStructElem2);

            // Basic Morphology - Applies morphological transformations to binary images.
            int[] vaCoefficients3            = { 0, 1, 0, 1, 1, 1, 0, 1, 0 };
            StructuringElement vaStructElem3 = new StructuringElement(3, 3, vaCoefficients3);

            vaStructElem.Shape = StructuringElementShape.Square;
            // Applies morphological transformations
            for (int i = 0; i < 3; ++i)
            {
                Algorithms.Morphology(image, image, MorphologyMethod.Erode, vaStructElem3);
            }

            // Advanced Morphology: Fill Holes
            VisionImage image1 = new VisionImage();

            Algorithms.FillHoles(image, image1, Connectivity.Connectivity8);

            // Particle Analysis - Computes the number of particles detected in a binary image and
            // returns the requested measurements about the particles.
            Collection <MeasurementType> vaPixelMeasurements      = new Collection <MeasurementType>(new MeasurementType[] { MeasurementType.Area });
            Collection <MeasurementType> vaCalibratedMeasurements = new Collection <MeasurementType>(new MeasurementType[] { });

            IVA_Particle(image1, Connectivity.Connectivity8, vaPixelMeasurements, vaCalibratedMeasurements, ivaData, 16, out vaParticleReport, out vaParticleReportCalibrated);
            double[,] area = vaParticleReport.PixelMeasurements;
            double Maxarea = 0;

            for (int i = 0; i < area.GetLength(0); i++)
            {
                for (int j = 0; j < area.GetLength(1); j++)
                {
                    if (area[i, j] > Maxarea)
                    {
                        Maxarea = area[i, j];
                    }
                }
            }
            image1.Dispose();

            if (Maxarea > 1000000)
            {
                // Creates a new, empty region of interest.
                Roi roi3 = new Roi();
                // Creates a new AnnulusContour using the given values.
                PointContour   vaCenter3 = new PointContour(1295, 963);
                AnnulusContour vaOval3   = new AnnulusContour(vaCenter3, 496, 892, 0, 0);
                roi3.Add(vaOval3);
                // Reposition the region of interest based on the coordinate system.
                int coordSystemIndex2 = 0;
                Algorithms.TransformRoi(roi3, new CoordinateTransform(ivaData.baseCoordinateSystems[coordSystemIndex2], ivaData.MeasurementSystems[coordSystemIndex2]));
                // Extract the contour edges from the image
                CurveParameters            vaCurveParams         = new CurveParameters(ExtractionMode.NormalImage, 1, EdgeFilterSize.ContourTracing, 30, 20, 10, true);
                double[]                   vaConstraintMinArray  = { };
                double[]                   vaConstraintMaxArray  = { };
                ConnectionConstraintType[] vaConstraintTypeArray = { };
                ExtractContourReport       vaExtractReport       = IVA_ExtractContour(image, roi3, ExtractContourDirection.AnnulusOuterInner, vaCurveParams, vaConstraintTypeArray, vaConstraintMinArray, vaConstraintMaxArray, ExtractContourSelection.Closest);
                // Fit a circle to the contour
                ContourOverlaySettings vaEquationOverlay = new ContourOverlaySettings(true, Rgb32Value.GreenColor, 1, true);
                ContourOverlaySettings vaPointsOverlay   = new ContourOverlaySettings(true, Rgb32Value.RedColor, 1, true);
                PartialCircle          vaCircleReport    = Algorithms.ContourFitCircle(image, 100, true);
                Algorithms.ContourOverlay(image, image, vaPointsOverlay, vaEquationOverlay);
                ComputeDistanceReport vaDistanceReport = Algorithms.ContourComputeDistances(image, image, 0);

                MaxDistance      = 0;
                MaxDistanceIndex = 0;
                for (int i = 0; i < vaDistanceReport.Distances.Count; i++)
                {
                    if (vaDistanceReport.Distances[i].Distance > MaxDistance)
                    {
                        MaxDistance      = vaDistanceReport.Distances[i].Distance;
                        MaxDistanceIndex = i;
                    }
                }
                var pos = vaDistanceReport.Distances[MaxDistanceIndex];
                distance[0] = MaxDistance;

                roi3.Dispose();

                // Creates a new, empty region of interest.
                Roi roi4 = new Roi();
                // Creates a new AnnulusContour using the given values.
                PointContour   vaCenter4 = new PointContour(1294, 962);
                AnnulusContour vaOval4   = new AnnulusContour(vaCenter4, 499, 885, 0, 0);
                roi4.Add(vaOval4);
                // Reposition the region of interest based on the coordinate system.
                int coordSystemIndex3 = 0;
                Algorithms.TransformRoi(roi4, new CoordinateTransform(ivaData.baseCoordinateSystems[coordSystemIndex3], ivaData.MeasurementSystems[coordSystemIndex3]));
                // Extract the contour edges from the image
                CurveParameters            vaCurveParams2         = new CurveParameters(ExtractionMode.NormalImage, 1, EdgeFilterSize.ContourTracing, 30, 25, 10, true);
                double[]                   vaConstraintMinArray2  = { };
                double[]                   vaConstraintMaxArray2  = { };
                ConnectionConstraintType[] vaConstraintTypeArray2 = { };
                ExtractContourReport       vaExtractReport2       = IVA_ExtractContour(image, roi4, ExtractContourDirection.AnnulusInnerOuter, vaCurveParams2, vaConstraintTypeArray2, vaConstraintMinArray2, vaConstraintMaxArray2, ExtractContourSelection.Closest);
                // Fit a circle to the contour
                ContourOverlaySettings vaEquationOverlay2 = new ContourOverlaySettings(true, Rgb32Value.GreenColor, 1, true);
                ContourOverlaySettings vaPointsOverlay2   = new ContourOverlaySettings(true, Rgb32Value.RedColor, 1, true);
                PartialCircle          vaCircleReport2    = Algorithms.ContourFitCircle(image, 100, true);
                Algorithms.ContourOverlay(image, image, vaPointsOverlay2, vaEquationOverlay2);
                ComputeDistanceReport vaDistanceReport2 = Algorithms.ContourComputeDistances(image, image, 0);

                MaxDistance1      = 0;
                MaxDistanceIndex1 = 0;
                for (int i = 0; i < vaDistanceReport2.Distances.Count; i++)
                {
                    if (vaDistanceReport2.Distances[i].Distance > MaxDistance1)
                    {
                        MaxDistance1      = vaDistanceReport2.Distances[i].Distance;
                        MaxDistanceIndex1 = i;
                    }
                }
                var pos1 = vaDistanceReport2.Distances[MaxDistanceIndex1];
                distance[1] = MaxDistance1;
                distance[2] = (vaCircleReport2.Center.X - vaCircularEdgeReport.Center.X) / 96;
                distance[3] = (vaCircleReport2.Center.Y - vaCircularEdgeReport.Center.Y) / 96;
                roi4.Dispose();
            }
            else
            {
                distance[0] = 9999;
                distance[1] = 9999;
                distance[2] = 9999;
                distance[3] = 9999;
            }

            // Dispose the IVA_Data structure.
            ivaData.Dispose();
            if (path == $"{ @"./ImageTemp/temp.jpg"}")
            {
                image.Dispose();
            }

            // Return the palette type of the final image.
            return(PaletteType.Binary);
        }