예제 #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, ah, cross-cross-check
        /// with another horizontal scan. This is needed primarily to locate the real horizontal
        /// center of the pattern in cases of extreme skew.</p>
        ///
        /// <p>If that succeeds the finder pattern location is added to a list that tracks
        /// the number of times each location has been nearly-matched as a finder pattern.
        /// Each additional find is more evidence that the location is in fact a finder
        /// pattern center
        ///
        /// </summary>
        /// <param name="stateCount">reading state module counts from horizontal scan
        /// </param>
        /// <param name="i">row where finder pattern may be found
        /// </param>
        /// <param name="j">end of possible finder pattern in row
        /// </param>
        /// <returns> true if a finder pattern candidate was found this time
        /// </returns>
        protected internal virtual bool handlePossibleCenter(int[] stateCount, int i, int j)
        {
            int   stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
            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, stateCount[2], stateCountTotal);

            if (!System.Single.IsNaN(centerI))
            {
                // Re-cross check
                //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'"
                centerJ = crossCheckHorizontal((int)centerJ, (int)centerI, stateCount[2], stateCountTotal);
                if (!System.Single.IsNaN(centerJ))
                {
                    //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)stateCountTotal / 7.0f;
                    bool  found = false;
                    int   max   = possibleCenters.Count;
                    for (int index = 0; index < max; index++)
                    {
                        FinderPattern center = (FinderPattern)possibleCenters[index];
                        // Look for about the same center and module size:
                        if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
                        {
                            center.incrementCount();
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        ResultPoint point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
                        possibleCenters.Add(point);
                        if (resultPointCallback != null)
                        {
                            resultPointCallback.foundPossibleResultPoint(point);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
예제 #2
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, ah, cross-cross-check
        /// with another horizontal scan. This is needed primarily to locate the real horizontal
        /// center of the pattern in cases of extreme skew.</p>
        ///
        /// <p>If that succeeds the finder pattern location is added to a list that tracks
        /// the number of times each location has been nearly-matched as a finder pattern.
        /// Each additional find is more evidence that the location is in fact a finder
        /// pattern center
        /// </summary>
        /// <param name="stateCount"> reading state module counts from horizontal scan </param>
        /// <param name="i"> row where finder pattern may be found </param>
        /// <param name="j"> end of possible finder pattern in row </param>
        /// <returns> true if a finder pattern candidate was found this time </returns>
        protected internal bool handlePossibleCenter(int[] stateCount, int i, int j)
        {
            int   stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
            float centerJ         = centerFromEnd(stateCount, j);
            float centerI         = crossCheckVertical(i, (int)centerJ, stateCount[2], stateCountTotal);

            if (!float.IsNaN(centerI))
            {
                // Re-cross check
                centerJ = crossCheckHorizontal((int)centerJ, (int)centerI, stateCount[2], stateCountTotal);
                if (!float.IsNaN(centerJ))
                {
                    float estimatedModuleSize = (float)stateCountTotal / 7.0f;
                    bool  found = false;
                    for (int index = 0; index < possibleCenters.Count; index++)
                    {
                        FinderPattern center = possibleCenters[index];
                        // Look for about the same center and module size:
                        if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
                        {
                            possibleCenters[index] = center.combineEstimate(centerI, centerJ, estimatedModuleSize);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        FinderPattern point = new FinderPattern(centerJ, centerI, estimatedModuleSize);
                        possibleCenters.Add(point);
                        if (resultPointCallback != null)
                        {
                            resultPointCallback.foundPossibleResultPoint(point);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
예제 #3
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, ah, cross-cross-check
         * with another horizontal scan. This is needed primarily to locate the real horizontal
         * center of the pattern in cases of extreme skew.</p>
         *
         * <p>If that succeeds the finder pattern location is added to a list that tracks
         * the number of times each location has been nearly-matched as a finder pattern.
         * Each additional find is more evidence that the location is in fact a finder
         * pattern center
         *
         * @param stateCount reading state module counts from horizontal scan
         * @param i row where finder pattern may be found
         * @param j end of possible finder pattern in row
         * @return true if a finder pattern candidate was found this time
         */
        private bool handlePossibleCenter(int[] stateCount,
                                          int i,
                                          int j)
        {
            int   stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
            float centerJ         = centerFromEnd(stateCount, j);
            float centerI         = crossCheckVertical(i, (int)centerJ, stateCount[2], stateCountTotal);

            if (!Single.IsNaN(centerI))
            {
                // Re-cross check
                centerJ = crossCheckHorizontal((int)centerJ, (int)centerI, stateCount[2], stateCountTotal);
                if (!Single.IsNaN(centerJ))
                {
                    float estimatedModuleSize = (float)stateCountTotal / 7.0f;
                    bool  found = false;
                    int   max   = possibleCenters.Count;
                    for (int index = 0; index < max; index++)
                    {
                        FinderPattern center = (FinderPattern)possibleCenters[index];
                        // Look for about the same center and module size:
                        if (center.aboutEquals(estimatedModuleSize, centerI, centerJ))
                        {
                            center.incrementCount();
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        possibleCenters.Add(new FinderPattern(centerJ, centerI, estimatedModuleSize));
                    }
                    return(true);
                }
            }
            return(false);
        }