Beispiel #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> {@link AlignmentPattern} if found, or null otherwise
        /// </returns>
        /// <throws>  ReaderException if an unexpected error occurs during detection </throws>
        protected internal virtual 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  = System.Math.Max(0, estAlignmentX - allowance);
            int alignmentAreaRightX = System.Math.Min(_image.Width - 1, estAlignmentX + allowance);

            if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3)
            {
                throw ReaderException.Instance;
            }

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

            AlignmentPatternFinder alignmentFinder = new AlignmentPatternFinder(_image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, _resultPointCallback);

            return(alignmentFinder.find());
        }
Beispiel #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> {@link AlignmentPattern} if found, or null otherwise
		/// </returns>
		/// <throws>  ReaderException if an unexpected error occurs during detection </throws>
		protected internal virtual 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 = System.Math.Max(0, estAlignmentX - allowance);
			int alignmentAreaRightX = System.Math.Min(_image.Width - 1, estAlignmentX + allowance);
			if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3)
			{
				throw ReaderException.Instance;
			}
			
			int alignmentAreaTopY = System.Math.Max(0, estAlignmentY - allowance);
			int alignmentAreaBottomY = System.Math.Min(_image.Height - 1, estAlignmentY + allowance);
			
			AlignmentPatternFinder alignmentFinder = new AlignmentPatternFinder(_image, alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, _resultPointCallback);
			return alignmentFinder.find();
		}