This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder patterns but are smaller and appear at regular intervals throughout the image.

At the moment this only looks for the bottom-right alignment pattern.

This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, pasted and stripped down here for maximum performance but does unfortunately duplicate some code.

This class is thread-safe but not reentrant. Each thread must allocate its own object.

Esempio n. 1
0
        /// <summary>
        ///   <p>Attempts to locate an alignment pattern in a limited region of the image, which is
        /// guessed to contain it. This method uses {@link AlignmentPattern}.</p>
        /// </summary>
        /// <param name="overallEstModuleSize">estimated module size so far</param>
        /// <param name="estAlignmentX">x coordinate of center of area probably containing alignment pattern</param>
        /// <param name="estAlignmentY">y coordinate of above</param>
        /// <param name="allowanceFactor">number of pixels in all directions to search from the center</param>
        /// <returns>
        ///   <see cref="AlignmentPattern"/> if found, or null otherwise
        /// </returns>
        protected AlignmentPattern findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor)
        {
            // Look for an alignment pattern (3 modules in size) around where it
            // should be
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            int allowance           = (int)(allowanceFactor * overallEstModuleSize);
            int alignmentAreaLeftX  = Math.Max(0, estAlignmentX - allowance);
            int alignmentAreaRightX = Math.Min(image.Width - 1, estAlignmentX + allowance);

            if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3)
            {
                return(null);
            }

            int alignmentAreaTopY    = Math.Max(0, estAlignmentY - allowance);
            int alignmentAreaBottomY = Math.Min(image.Height - 1, estAlignmentY + allowance);

            var alignmentFinder = new AlignmentPatternFinder(
                image,
                alignmentAreaLeftX,
                alignmentAreaTopY,
                alignmentAreaRightX - alignmentAreaLeftX,
                alignmentAreaBottomY - alignmentAreaTopY,
                overallEstModuleSize,
                resultPointCallback);

            return(alignmentFinder.find());
        }
Esempio n. 2
0
      /// <summary>
      ///   <p>Attempts to locate an alignment pattern in a limited region of the image, which is
      /// guessed to contain it. This method uses {@link AlignmentPattern}.</p>
      /// </summary>
      /// <param name="overallEstModuleSize">estimated module size so far</param>
      /// <param name="estAlignmentX">x coordinate of center of area probably containing alignment pattern</param>
      /// <param name="estAlignmentY">y coordinate of above</param>
      /// <param name="allowanceFactor">number of pixels in all directions to search from the center</param>
      /// <returns>
      ///   <see cref="AlignmentPattern"/> if found, or null otherwise
      /// </returns>
      protected AlignmentPattern findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor)
      {
         // Look for an alignment pattern (3 modules in size) around where it
         // should be
         //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
         int allowance = (int)(allowanceFactor * overallEstModuleSize);
         int alignmentAreaLeftX = Math.Max(0, estAlignmentX - allowance);
         int alignmentAreaRightX = Math.Min(image.Width - 1, estAlignmentX + allowance);
         if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3)
         {
            return null;
         }

         int alignmentAreaTopY = Math.Max(0, estAlignmentY - allowance);
         int alignmentAreaBottomY = Math.Min(image.Height - 1, estAlignmentY + allowance);

         var alignmentFinder = new AlignmentPatternFinder(
            image,
            alignmentAreaLeftX,
            alignmentAreaTopY,
            alignmentAreaRightX - alignmentAreaLeftX,
            alignmentAreaBottomY - alignmentAreaTopY,
            overallEstModuleSize,
            resultPointCallback);

         return alignmentFinder.find();
      }