com.google.zxing.pdf417.detector.Detector.patternMatchVariance(int[], int[], int)

Here are the examples of the csharp api class com.google.zxing.pdf417.detector.Detector.patternMatchVariance(int[], int[], int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: ZXing-CSharp
Source File: Detector.cs
View license
private static int[] findGuardPattern(BitMatrix matrix, int column, int row, int width, bool whiteFirst, int[] pattern)
		{
			int patternLength = pattern.Length;
			// TODO: Find a way to cache this array, as this method is called hundreds of times
			// per image, and we want to allocate as seldom as possible.
			int[] counters = new int[patternLength];
			bool isWhite = whiteFirst;
			
			int counterPosition = 0;
			int patternStart = column;
			for (int x = column; x < column + width; x++)
			{
				bool pixel = matrix.get_Renamed(x, row);
				if (pixel ^ isWhite)
				{
					counters[counterPosition]++;
				}
				else
				{
					if (counterPosition == patternLength - 1)
					{
						if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE)
						{
							return new int[]{patternStart, x};
						}
						patternStart += counters[0] + counters[1];
						for (int y = 2; y < patternLength; y++)
						{
							counters[y - 2] = counters[y];
						}
						counters[patternLength - 2] = 0;
						counters[patternLength - 1] = 0;
						counterPosition--;
					}
					else
					{
						counterPosition++;
					}
					counters[counterPosition] = 1;
					isWhite = !isWhite;
				}
			}
			return null;
		}