Beispiel #1
0
        /// <summary> <p>Detects a QR Code in an image, simply.</p>
        ///
        /// </summary>
        /// <param name="hints">optional hints to detector
        /// </param>
        /// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
        /// </returns>
        /// <throws>  ReaderException if no QR Code can be found </throws>
        public virtual DetectorResult detect(System.Collections.Hashtable hints)
        {
            resultPointCallback = hints == null?null:(ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];

            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo   info   = finder.find(hints);

            return(processFinderPatternInfo(info));
        }
        /// <summary> <p>Detects a QR Code in an image, simply.</p>
        ///
        /// </summary>
        /// <param name="hints">optional hints to detector
        /// </param>
        /// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
        /// </returns>
        /// <throws>  ReaderException if no QR Code can be found </throws>
        // public virtual DetectorResult detect(System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public virtual DetectorResult detect(System.Collections.Generic.Dictionary <Object, Object> hints) // added by .net follower (http://dotnetfollower.com)
        {
            // resultPointCallback = hints == null?null:(ResultPointCallback) hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]; // commented by .net follower (http://dotnetfollower.com)
            resultPointCallback = null;                                                                      // added by .net follower (http://dotnetfollower.com)
            if (hints != null && hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK))               // added by .net follower (http://dotnetfollower.com)
            {
                resultPointCallback = (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]; // added by .net follower (http://dotnetfollower.com)
            }
            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo   info   = finder.find(hints);

            return(processFinderPatternInfo(info));
        }
Beispiel #3
0
        /// <summary> <p>Detects a QR Code in an image, simply.</p>
        ///
        /// </summary>
        /// <param name="hints">optional hints to detector
        /// </param>
        /// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
        /// </returns>
        /// <throws>  ReaderException if no QR Code can be found </throws>
        public virtual DetectorResult detect(System.Collections.Generic.Dictionary <Object, Object> hints)
        {
            resultPointCallback = hints == null?null: hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)?(ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]:null;

            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo   info   = finder.find(hints);

            if (info == null)
            {
                return(null);
            }
            return(processFinderPatternInfo(info));
        }
Beispiel #4
0
        /// <summary>
        /// <p>Detects a QR Code in an image, simply.</p>
        /// </summary>
        /// <param name="hints"> optional hints to detector </param>
        /// <returns> <seealso cref="NotFoundException"/> encapsulating results of detecting a QR Code </returns>
        /// <exception cref="NotFoundException"> if QR Code cannot be found </exception>
        /// <exception cref="FormatException"> if a QR Code cannot be decoded </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public final com.google.zxing.common.DetectorResult detect(java.util.Map<com.google.zxing.DecodeHintType,?> hints) throws com.google.zxing.NotFoundException, com.google.zxing.FormatException
        public DetectorResult detect(IDictionary <DecodeHintType, object> hints)
        {
            //resultPointCallback = hints == null ? null : (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];
            ResultPointCallback resultPointCallback = null;

            if (hints != null && hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK))
            {
                resultPointCallback = (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];
            }

            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo   info   = finder.find(hints);

            return(processFinderPatternInfo(info));
        }
Beispiel #5
0
        /// <summary> <p>Detects a QR Code in an image, simply.</p>
        /// 
        /// </summary>
        /// <param name="hints">optional hints to detector
        /// </param>
        /// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
        /// </returns>
        /// <throws>  ReaderException if no QR Code can be found </throws>
        public virtual DetectorResult detect(System.Collections.Hashtable hints)
        {
            resultPointCallback = hints == null?null:(ResultPointCallback) hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];

            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo info = finder.find(hints);

            return processFinderPatternInfo(info);
        }
        /**
           * <p>Detects a QR Code in an image, simply.</p>
           *
           * @param hints optional hints to detector
           * @return {@link DetectorResult} encapsulating results of detecting a QR Code
           * @throws ReaderException if no QR Code can be found
           */
        public DetectorResult detect(System.Collections.Hashtable hints)
        {
            MonochromeBitmapSource image = this.image;
            if (!BlackPointEstimationMethod.TWO_D_SAMPLING.Equals(image.getLastEstimationMethod())) {
              image.estimateBlackPoint(BlackPointEstimationMethod.TWO_D_SAMPLING, 0);
            }

            FinderPatternFinder finder = new FinderPatternFinder(image);
            FinderPatternInfo info = finder.find(hints);

            FinderPattern topLeft = info.getTopLeft();
            FinderPattern topRight = info.getTopRight();
            FinderPattern bottomLeft = info.getBottomLeft();

            float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);
            if (moduleSize < 1.0f) {
              throw new ReaderException();
            }
            int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);

            Version provisionalVersion = Version.getProvisionalVersionForDimension(dimension);
            int modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

            AlignmentPattern alignmentPattern = null;
            // Anything above version 1 has an alignment pattern
            if (provisionalVersion.getAlignmentPatternCenters().Length > 0) {

              // Guess where a "bottom right" finder pattern would have been
              float bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
              float bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();

              // Estimate that alignment pattern is closer by 3 modules
              // from "bottom right" to known top left location
              float correctionToTopLeft = 1.0f - 3.0f / (float) modulesBetweenFPCenters;
              int estAlignmentX = (int) (topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
              int estAlignmentY = (int) (topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));

              // Kind of arbitrary -- expand search radius before giving up
              for (int i = 4; i <= 16; i <<= 1) {
                try {
                  alignmentPattern = findAlignmentInRegion(moduleSize,
                      estAlignmentX,
                      estAlignmentY,
                      (float) i);
                  break;
                } catch (ReaderException re) {
                  // try next round
                }
              }
              if (alignmentPattern == null) {
                throw new ReaderException();
              }

            }

            BitMatrix bits = sampleGrid(image, topLeft, topRight, bottomLeft, alignmentPattern, dimension);

            ResultPoint[] points;
            if (alignmentPattern == null) {
              points = new ResultPoint[]{bottomLeft, topLeft, topRight};
            } else {
              points = new ResultPoint[]{bottomLeft, topLeft, topRight, alignmentPattern};
            }
            return new DetectorResult(bits, points);
        }
Beispiel #7
0
        /// <summary> <p>Detects a QR Code in an image, simply.</p>
        /// 
        /// </summary>
        /// <param name="hints">optional hints to detector
        /// </param>
        /// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
        /// </returns>
        /// <throws>  ReaderException if no QR Code can be found </throws>
        public virtual DetectorResult detect(System.Collections.Generic.Dictionary<Object,Object> hints)
        {
            resultPointCallback = hints == null?null: hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)?(ResultPointCallback) hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]:null;

            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo info = finder.find(hints);

            return processFinderPatternInfo(info);
        }
Beispiel #8
0
        /**
         * <p>Detects a QR Code in an image, simply.</p>
         *
         * @param hints optional hints to detector
         * @return {@link DetectorResult} encapsulating results of detecting a QR Code
         * @throws ReaderException if no QR Code can be found
         */
        public DetectorResult detect(System.Collections.Hashtable hints)
        {
            MonochromeBitmapSource image = this.image;

            if (!BlackPointEstimationMethod.TWO_D_SAMPLING.Equals(image.getLastEstimationMethod()))
            {
                image.estimateBlackPoint(BlackPointEstimationMethod.TWO_D_SAMPLING, 0);
            }

            FinderPatternFinder finder = new FinderPatternFinder(image);
            FinderPatternInfo   info   = finder.find(hints);

            FinderPattern topLeft    = info.getTopLeft();
            FinderPattern topRight   = info.getTopRight();
            FinderPattern bottomLeft = info.getBottomLeft();

            float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft);

            if (moduleSize < 1.0f)
            {
                throw new ReaderException();
            }
            int dimension = computeDimension(topLeft, topRight, bottomLeft, moduleSize);

            Version provisionalVersion      = Version.getProvisionalVersionForDimension(dimension);
            int     modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7;

            AlignmentPattern alignmentPattern = null;

            // Anything above version 1 has an alignment pattern
            if (provisionalVersion.getAlignmentPatternCenters().Length > 0)
            {
                // Guess where a "bottom right" finder pattern would have been
                float bottomRightX = topRight.getX() - topLeft.getX() + bottomLeft.getX();
                float bottomRightY = topRight.getY() - topLeft.getY() + bottomLeft.getY();

                // Estimate that alignment pattern is closer by 3 modules
                // from "bottom right" to known top left location
                float correctionToTopLeft = 1.0f - 3.0f / (float)modulesBetweenFPCenters;
                int   estAlignmentX       = (int)(topLeft.getX() + correctionToTopLeft * (bottomRightX - topLeft.getX()));
                int   estAlignmentY       = (int)(topLeft.getY() + correctionToTopLeft * (bottomRightY - topLeft.getY()));

                // Kind of arbitrary -- expand search radius before giving up
                for (int i = 4; i <= 16; i <<= 1)
                {
                    try {
                        alignmentPattern = findAlignmentInRegion(moduleSize,
                                                                 estAlignmentX,
                                                                 estAlignmentY,
                                                                 (float)i);
                        break;
                    } catch (ReaderException re) {
                        // try next round
                    }
                }
                if (alignmentPattern == null)
                {
                    throw new ReaderException();
                }
            }

            BitMatrix bits = sampleGrid(image, topLeft, topRight, bottomLeft, alignmentPattern, dimension);

            ResultPoint[] points;
            if (alignmentPattern == null)
            {
                points = new ResultPoint[] { bottomLeft, topLeft, topRight };
            }
            else
            {
                points = new ResultPoint[] { bottomLeft, topLeft, topRight, alignmentPattern };
            }
            return(new DetectorResult(bits, points));
        }
Beispiel #9
0
        /// <summary>
        /// <p>Detects a QR Code in an image, simply.</p>
        /// </summary>
        /// <param name="hints"> optional hints to detector </param>
        /// <returns> <seealso cref="NotFoundException"/> encapsulating results of detecting a QR Code </returns>
        /// <exception cref="NotFoundException"> if QR Code cannot be found </exception>
        /// <exception cref="FormatException"> if a QR Code cannot be decoded </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public final com.google.zxing.common.DetectorResult detect(java.util.Map<com.google.zxing.DecodeHintType,?> hints) throws com.google.zxing.NotFoundException, com.google.zxing.FormatException
        public DetectorResult detect(IDictionary<DecodeHintType, object> hints)
        {
            //resultPointCallback = hints == null ? null : (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];
              ResultPointCallback resultPointCallback = null;
              if (hints != null && hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK))
              {
              resultPointCallback = (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];
              }

            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo info = finder.find(hints);

            return processFinderPatternInfo(info);
        }
        // added by .net follower (http://dotnetfollower.com)
        /// <summary> <p>Detects a QR Code in an image, simply.</p>
        /// 
        /// </summary>
        /// <param name="hints">optional hints to detector
        /// </param>
        /// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
        /// </returns>
        /// <throws>  ReaderException if no QR Code can be found </throws>
        // public virtual DetectorResult detect(System.Collections.Hashtable hints) // commented by .net follower (http://dotnetfollower.com)
        public virtual DetectorResult detect(System.Collections.Generic.Dictionary<Object, Object> hints)
        {
            // resultPointCallback = hints == null?null:(ResultPointCallback) hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]; // commented by .net follower (http://dotnetfollower.com)
            resultPointCallback = null; // added by .net follower (http://dotnetfollower.com)
            if (hints != null && hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)) // added by .net follower (http://dotnetfollower.com)
                resultPointCallback = (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]; // added by .net follower (http://dotnetfollower.com)

            FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback);
            FinderPatternInfo info = finder.find(hints);

            return processFinderPatternInfo(info);
        }