Ejemplo n.º 1
0
        /// <summary> <p>This is called when a horizontal scan finds a possible alignment pattern. It will
        /// cross check with a vertical scan, and if successful, will see if this pattern had been
        /// found on a previous horizontal scan. If so, we consider it confirmed and conclude we have
        /// found the alignment pattern.</p>
        ///
        /// </summary>
        /// <param name="stateCount">reading state module counts from horizontal scan
        /// </param>
        /// <param name="i">row where alignment pattern may be found
        /// </param>
        /// <param name="j">end of possible alignment pattern in row
        /// </param>
        /// <returns> {@link AlignmentPattern} if we have found the same pattern twice, or null if not
        /// </returns>
        private AlignmentPattern handlePossibleCenter(int[] stateCount, int i, int j)
        {
            int   stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
            float centerJ         = centerFromEnd(stateCount, j);
            //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'"
            float centerI = crossCheckVertical(i, (int)centerJ, 2 * stateCount[1], stateCountTotal);

            if (!System.Single.IsNaN(centerI))
            {
                //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'"
                float estimatedModuleSize = (float)(stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f;
                int   max = possibleCenters.Count;
                for (int index = 0; index < max; index++)
                {
                    AlignmentPattern center = (AlignmentPattern)possibleCenters[index];
                    // Look for about the same center and module size:
                    if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
                    {
                        return(new AlignmentPattern(centerJ, centerI, estimatedModuleSize));
                    }
                }
                // Hadn't found this before; save it
                ResultPoint point = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
                possibleCenters.Add(point);
                if (resultPointCallback != null)
                {
                    resultPointCallback.foundPossibleResultPoint(point);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        /**
         * <p>This is called when a horizontal scan finds a possible alignment pattern. It will
         * cross check with a vertical scan, and if successful, will see if this pattern had been
         * found on a previous horizontal scan. If so, we consider it confirmed and conclude we have
         * found the alignment pattern.</p>
         *
         * @param stateCount reading state module counts from horizontal scan
         * @param i row where alignment pattern may be found
         * @param j end of possible alignment pattern in row
         * @return {@link AlignmentPattern} if we have found the same pattern twice, or null if not
         */
        private AlignmentPattern handlePossibleCenter(int[] stateCount, int i, int j)
        {
            int   stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
            float centerJ         = centerFromEnd(stateCount, j);
            float centerI         = crossCheckVertical(i, (int)centerJ, 2 * stateCount[1], stateCountTotal);

            if (!Single.IsNaN(centerI))
            {
                float estimatedModuleSize = (float)(stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f;
                int   max = possibleCenters.Count;
                for (int index = 0; index < max; index++)
                {
                    AlignmentPattern center = (AlignmentPattern)possibleCenters[index];
                    // Look for about the same center and module size:
                    if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
                    {
                        return(new AlignmentPattern(centerJ, centerI, estimatedModuleSize));
                    }
                }
                // Hadn't found this before; save it
                possibleCenters.Add(new AlignmentPattern(centerJ, centerI, estimatedModuleSize));
            }
            return(null);
        }