Beispiel #1
0
        private static FindEdgeReport IVA_FindEdge(VisionImage image,
                                                   Roi roi,
                                                   RakeDirection direction,
                                                   EdgeOptions options,
                                                   StraightEdgeOptions straightEdgeOptions,
                                                   IVA_Data ivaData,
                                                   int stepIndex)
        {
            // First, delete all the results of this step (from a previous iteration)
            Functions.IVA_DisposeStepResults(ivaData, stepIndex);

            // Find the Edge
            FindEdgeOptions edgeOptions = new FindEdgeOptions(direction);

            edgeOptions.EdgeOptions         = options;
            edgeOptions.StraightEdgeOptions = straightEdgeOptions;
            FindEdgeReport lineReport = new FindEdgeReport();

            lineReport = Algorithms.FindEdge(image, roi, edgeOptions);

            // If there was at least one line, get data
            if (lineReport.StraightEdges.Count >= 1)
            {
                // Store the results in the data structure.
                ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 1.X Position (Pix.)", lineReport.StraightEdges[0].StraightEdge.Start.X));
                ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 1.Y Position (Pix.)", lineReport.StraightEdges[0].StraightEdge.Start.Y));
                ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 2.X Position (Pix.)", lineReport.StraightEdges[0].StraightEdge.End.X));
                ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 2.Y Position (Pix.)", lineReport.StraightEdges[0].StraightEdge.End.Y));
                if ((image.InfoTypes & InfoTypes.Calibration) != 0)
                {
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 1.X Position (World)", lineReport.StraightEdges[0].CalibratedStraightEdge.Start.X));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 1.Y Position (World)", lineReport.StraightEdges[0].CalibratedStraightEdge.Start.Y));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 2.X Position (World)", lineReport.StraightEdges[0].CalibratedStraightEdge.End.X));
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Point 2.Y Position (World)", lineReport.StraightEdges[0].CalibratedStraightEdge.End.Y));
                }

                ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Angle", lineReport.StraightEdges[0].Angle));
                if ((image.InfoTypes & InfoTypes.Calibration) != 0)
                {
                    ivaData.stepResults[stepIndex].results.Add(new IVA_Result("Angle (World)", lineReport.StraightEdges[0].CalibratedAngle));
                }
            }
            return(lineReport);
        }
Beispiel #2
0
        private void FindEdges()
        {
            if (imageViewer1.Roi.Count > 0)
            {
                // Use search direction selected.
                RakeDirection direction = (RakeDirection)Enum.Parse(typeof(RakeDirection), (string)searchDirection.SelectedItem);

                // Fill in the edge options structure from the controls on the form.
                EdgeOptions edgeOptions = new EdgeOptions();
                edgeOptions.ColumnProcessingMode = (ColumnProcessingMode)Enum.Parse(typeof(ColumnProcessingMode), (string)smoothing.SelectedItem);
                edgeOptions.InterpolationType    = (InterpolationMethod)Enum.Parse(typeof(InterpolationMethod), (string)interpolationMethod.SelectedItem);
                edgeOptions.KernelSize           = (uint)kernelSize.Value;
                edgeOptions.MinimumThreshold     = (uint)minimumThreshold.Value;
                edgeOptions.Polarity             = (EdgePolaritySearchMode)Enum.Parse(typeof(EdgePolaritySearchMode), (string)polarity.SelectedItem);
                edgeOptions.Width = (uint)width.Value;

                // Fill in the straight edge options structure from the controls on the form.
                StraightEdgeOptions straightEdgeOptions = new StraightEdgeOptions();
                straightEdgeOptions.AngleRange      = (double)angleRange.Value;
                straightEdgeOptions.AngleTolerance  = (double)angleTolerance.Value;
                straightEdgeOptions.HoughIterations = (uint)houghIterations.Value;
                straightEdgeOptions.ScoreRange.Initialize((double)minimumScore.Value, (double)maximumScore.Value);
                straightEdgeOptions.MinimumCoverage           = (double)minimumCoverage.Value;
                straightEdgeOptions.MinimumSignalToNoiseRatio = (double)minimumSignalToNoiseRatio.Value;
                straightEdgeOptions.NumberOfLines             = (uint)numberOfLines.Value;
                straightEdgeOptions.Orientation = (double)orientation.Value;
                straightEdgeOptions.SearchMode  = (StraightEdgeSearchMode)Enum.Parse(typeof(StraightEdgeSearchMode), (string)searchMode.SelectedItem);
                straightEdgeOptions.StepSize    = (uint)stepSize.Value;

                FindEdgeOptions options = new FindEdgeOptions(direction, true, true, true, true);
                options.EdgeOptions         = edgeOptions;
                options.StraightEdgeOptions = straightEdgeOptions;

                // Clear all overlays from previous run.
                imageViewer1.Image.Overlays.Default.Clear();

                // Run the edge detection.
                FindEdgeReport report = Algorithms.FindEdge(imageViewer1.Image, imageViewer1.Roi, options);
            }
        }