public FinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback)
 {
     this.image = image;
     this.possibleCenters = new System.Collections.Generic.List<Object>(10);
     this.crossCheckStateCount = new int[5];
     this.resultPointCallback = resultPointCallback;
 }
Exemplo n.º 2
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);
		}
Exemplo n.º 3
0
      /// <summary>
      ///   <p>Detects a QR Code in an image, simply.</p>
      /// </summary>
      /// <param name="hints">optional hints to detector</param>
      /// <returns>
      ///   <see cref="DetectorResult"/> encapsulating results of detecting a QR Code
      /// </returns>
      public virtual DetectorResult detect(IDictionary<DecodeHintType, object> hints)
      {
         resultPointCallback = hints == null || !hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK) ? null : (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];

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

         return processFinderPatternInfo(info);
      }
Exemplo n.º 4
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(Dictionary<DecodeHintType, Object> hints)
        {
            resultPointCallback = hints == null
                                      ? null
                                      : (ResultPointCallback) hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];

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

            return processFinderPatternInfo(info);
        }
 /// <summary> <p>Creates a finder that will look in a portion of the whole image.</p>
 /// 
 /// </summary>
 /// <param name="image">image to search
 /// </param>
 /// <param name="startX">left column from which to start searching
 /// </param>
 /// <param name="startY">top row from which to start searching
 /// </param>
 /// <param name="width">width of region to search
 /// </param>
 /// <param name="height">height of region to search
 /// </param>
 /// <param name="moduleSize">estimated module size so far
 /// </param>
 internal AlignmentPatternFinder(BitMatrix image, int startX, int startY, int width, int height, float moduleSize, ResultPointCallback resultPointCallback)
 {
    this.image = image;
    this.possibleCenters = new List<AlignmentPattern>(5);
    this.startX = startX;
    this.startY = startY;
    this.width = width;
    this.height = height;
    this.moduleSize = moduleSize;
    this.crossCheckStateCount = new int[3];
    this.resultPointCallback = resultPointCallback;
 }
 internal MultiFinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback)
     : base(image, resultPointCallback)
 {
 }
 /// <summary> <p>Creates a finder that will look in a portion of the whole image.</p>
 ///
 /// </summary>
 /// <param name="image">image to search
 /// </param>
 /// <param name="startX">left column from which to start searching
 /// </param>
 /// <param name="startY">top row from which to start searching
 /// </param>
 /// <param name="width">width of region to search
 /// </param>
 /// <param name="height">height of region to search
 /// </param>
 /// <param name="moduleSize">estimated module size so far
 /// </param>
 internal AlignmentPatternFinder(BitMatrix image, int startX, int startY, int width, int height, float moduleSize, ResultPointCallback resultPointCallback)
 {
     this.image                = image;
     this.possibleCenters      = new List <AlignmentPattern>(5);
     this.startX               = startX;
     this.startY               = startY;
     this.width                = width;
     this.height               = height;
     this.moduleSize           = moduleSize;
     this.crossCheckStateCount = new int[3];
     this.resultPointCallback  = resultPointCallback;
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// <p>Like decodeRow(int, BitArray, java.util.Map), but
        /// allows caller to inform method about where the UPC/EAN start pattern is
        /// found. This allows this to be computed once and reused across many implementations.</p>
        /// </summary>
        virtual public Result decodeRow(int rowNumber,
                                        BitArray row,
                                        int[] startGuardRange,
                                        IDictionary <DecodeHintType, object> hints)
        {
            ResultPointCallback resultPointCallback = hints == null || !hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK) ? null :
                                                      (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK];

            if (resultPointCallback != null)
            {
                resultPointCallback(new ResultPoint(
                                        (startGuardRange[0] + startGuardRange[1]) / 2.0f, rowNumber
                                        ));
            }

            StringBuilder result = decodeRowStringBuffer;

            result.Length = 0;
            int endStart = decodeMiddle(row, startGuardRange, result);

            if (endStart < 0)
            {
                return(null);
            }

            if (resultPointCallback != null)
            {
                resultPointCallback(new ResultPoint(
                                        endStart, rowNumber
                                        ));
            }

            int[] endRange = decodeEnd(row, endStart);
            if (endRange == null)
            {
                return(null);
            }

            if (resultPointCallback != null)
            {
                resultPointCallback(new ResultPoint(
                                        (endRange[0] + endRange[1]) / 2.0f, rowNumber
                                        ));
            }


            // Make sure there is a quiet zone at least as big as the end pattern after the barcode. The
            // spec might want more whitespace, but in practice this is the maximum we can count on.
            int end      = endRange[1];
            int quietEnd = end + (end - endRange[0]);

            if (quietEnd >= row.Size || !row.isRange(end, quietEnd, false))
            {
                return(null);
            }

            String resultString = result.ToString();

            if (!checkChecksum(resultString))
            {
                return(null);
            }

            float         left         = (startGuardRange[1] + startGuardRange[0]) / 2.0f;
            float         right        = (endRange[1] + endRange[0]) / 2.0f;
            BarcodeFormat format       = BarcodeFormat;
            Result        decodeResult = new Result(resultString,
                                                    null, // no natural byte representation for these barcodes
                                                    new ResultPoint[]
            {
                new ResultPoint(left, rowNumber),
                new ResultPoint(right, rowNumber)
            },
                                                    format);

            Result extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);

            if (extensionResult != null)
            {
                decodeResult.putMetadata(ResultMetadataType.UPC_EAN_EXTENSION, extensionResult.Text);
                decodeResult.putAllMetadata(extensionResult.ResultMetadata);
                decodeResult.addResultPoints(extensionResult.ResultPoints);
            }

            if (format == BarcodeFormat.EAN_13 || format == BarcodeFormat.UPC_A)
            {
                String countryID = eanManSupport.lookupCountryIdentifier(resultString);
                if (countryID != null)
                {
                    decodeResult.putMetadata(ResultMetadataType.POSSIBLE_COUNTRY, countryID);
                }
            }

            return(decodeResult);
        }
Exemplo n.º 10
0
 internal MultiFinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback)
     : base(image, resultPointCallback)
 {
 }