Exemple #1
0
 public static extern int imaqFindTransformRects2(IntPtr image, ref ROI primaryROI, ref ROI secondaryROI, FindTransformMode mode, ref CoordinateSystem baseSystem, ref CoordinateSystem newSystem, ref FindTransformRectsOptions2 findTransformOptions, ref StraightEdgeOptions primaryStraightEdgeOptions, ref StraightEdgeOptions secondaryStraightEdgeOptions, ref AxisReport axisReport);
Exemple #2
0
        private void FindTransformWithPattern(VisionImage image, VisionImage template, FindTransformMode mode, MatchPatternOptions matchOptions, DrawOptions drawOptions, CoordinateTransform transform)
        {
            // Find the pattern in the image.
            Collection <PatternMatch> matches = Algorithms.MatchPattern(image, template, matchOptions);

            // If the pattern was found:
            if (matches.Count > 0)
            {
                // The points in the Corners collection are returned like this:
                //
                //   0 — 1
                //   |   |
                //   3 — 2
                //
                // Our main axis will be along the line from point 3 to point 2 and
                // our secondary axis will be from point 3 to point 0. The origin will
                // be at point 3.
                LineContour mainAxis      = new LineContour(matches[0].Corners[3], matches[0].Corners[2]);
                LineContour secondaryAxis = new LineContour(matches[0].Corners[3], matches[0].Corners[0]);

                // Fill in the coordinate transform with the data obtained by the pattern matching.
                transform.MeasurementSystem.Origin          = matches[0].Corners[3];
                transform.MeasurementSystem.Angle           = matches[0].Rotation;
                transform.MeasurementSystem.AxisOrientation = AxisOrientation.Direct;

                // If this is the first run, fill in the reference system too.
                if (mode == FindTransformMode.FindReference)
                {
                    transform.ReferenceSystem.Origin          = matches[0].Corners[3];
                    transform.ReferenceSystem.Angle           = matches[0].Rotation;
                    transform.ReferenceSystem.AxisOrientation = AxisOrientation.Direct;
                }

                // Draw the results on the image.
                if (drawOptions.ShowResult)
                {
                    // Draw the origin.
                    image.Overlays.Default.AddRectangle(new RectangleContour(mainAxis.Start.X - 2, mainAxis.Start.Y - 2, 5, 5), Rgb32Value.RedColor, DrawingMode.DrawValue);

                    // Draw each axis.
                    image.Overlays.Default.AddLine(mainAxis, Rgb32Value.RedColor);
                    DrawArrow(image.Overlays.Default, mainAxis, Rgb32Value.RedColor);
                    image.Overlays.Default.AddLine(secondaryAxis, Rgb32Value.RedColor);
                    DrawArrow(image.Overlays.Default, secondaryAxis, Rgb32Value.RedColor);
                }
            }
        }
Exemple #3
0
 public static extern int imaqFindTransformRect2(IntPtr image, ref ROI roi, FindTransformMode mode, ref CoordinateSystem baseSystem, ref CoordinateSystem newSystem, ref FindTransformRectOptions2 findTransformOptions, ref StraightEdgeOptions straightEdgeOptions, ref AxisReport axisReport);