Пример #1
0
        public static FinderPatternPair LocateFinderPatternPair(Bitmap sourceImage, int patternRadius)
        {
            int           minPatternRadius = (int)Math.Floor((double)patternRadius * 0.9);
            int           maxPatternRadius = (int)Math.Ceiling((double)patternRadius * 1.1);
            List <Point3> finderPatterns   = FinderCircleHoughTransform.LocateFinderCircles(
                sourceImage, minPatternRadius, maxPatternRadius, 2);
            FinderPatternPair fp = new FinderPatternPair();

            fp.p1    = new Point(finderPatterns[0].X, finderPatterns[0].Y);
            fp.size1 = finderPatterns[0].Z;
            fp.p2    = new Point(finderPatterns[1].X, finderPatterns[1].Y);
            fp.size2 = finderPatterns[1].Z;
            return(fp);
        }
Пример #2
0
        public static Option <Tuple <uint, DataMatrixExtraction> > ExtractCodeExt(Bitmap sourceImage, int minPatternRadius, int maxPatternRadius)
        {
            List <Point3> finderCircles = FinderCircleHoughTransform.LocateFinderCircles(sourceImage, minPatternRadius, maxPatternRadius, 2);

            var fpp = new FinderPatternPair();

            fpp.p1    = new Point(finderCircles[0].X, finderCircles[0].Y);
            fpp.size1 = finderCircles[0].Z;
            fpp.p2    = new Point(finderCircles[1].X, finderCircles[1].Y);
            fpp.size2 = finderCircles[1].Z;

            var dme = new DataMatrixExtraction(sourceImage, fpp);

            Option <uint> extractedCode = DataMarshaller.UnMarshallInt(dme.extractedData);

            if (extractedCode.NonEmpty())
            {
                return(new Some <Tuple <uint, DataMatrixExtraction> >(new Tuple <uint, DataMatrixExtraction>(extractedCode.Get(), dme)));
            }
            else
            {
                return(new None <Tuple <uint, DataMatrixExtraction> >());
            }
        }