Beispiel #1
0
        public static void LearnPattern(ImageViewer SourceImage, float fUpper = 0, float fLower = 0)
        {
            using (VisionImage plane = new VisionImage(ImageType.U8, 7))
            {
                // Extract the green color plane and copy it to the main image.
                if (SourceImage.Image.Type == ImageType.Rgb32)
                {
                    Algorithms.ExtractColorPlanes(SourceImage.Image, NationalInstruments.Vision.ColorMode.Rgb, null, plane, null);
                    Algorithms.Copy(plane, SourceImage.Image);
                }
            }
//          Algorithms.LearnPattern2(SourceImage.Image);
            OvalContour vaRect2 = new OvalContour(0, 0, 0, 0);
            Roi         roi     = new Roi();

            roi.Add(vaRect2);
            // Histogram Grayscale
            using (VisionImage imageMask = new VisionImage(ImageType.U8, 7))
            {
                RotationAngleRange ra        = new RotationAngleRange(fLower, fUpper);
                PixelValue         fillValue = new PixelValue(255);
                Algorithms.RoiToMask(imageMask, roi, fillValue, SourceImage.Image);
                Algorithms.LearnPattern2(SourceImage.Image, imageMask, MatchingAlgorithm.MatchGrayValuePyramid, ra);
            }
            roi.Dispose();
        }
Beispiel #2
0
        public override bool Lerarn(VisionImage image, Roi roi)
        {
            if (roi.Count == 0)
            {
                return(false);
            }
            bool rtn = false;

            try
            {
                Algorithms.Extract(image, this.Temp, roi);
                RotationAngleRange range = new RotationAngleRange();
                var op1 = (this.OptionList[0] as DetectCurveOptions).Options;

                Algorithms.LearnGeometricPatternEdgeBased(this.Temp, new PointContour(), 0, op1, LearnOptions);
                rtn = true;
            }
            catch (VisionException ex)
            {
                Debug.WriteLine(ex.VisionErrorText);
            }
            return(rtn);
        }
        public override bool Lerarn(VisionImage image, Roi roi)
        {
            if (roi.Count == 0)
            {
                return(false);
            }

            bool rtn = false;

            try
            {
                Algorithms.Extract(image, this.Temp, roi);
                RotationAngleRange range = new RotationAngleRange();
                range.Lower = 0;
                range.Upper = 360;
                Algorithms.LearnPattern2(this.Temp, null, this.MatchingAlgorithm, range);
                rtn = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            return(rtn);
        }