public int GetLastFrameNoDigitPosition(IotaVtiOcrProcessor stateManager) { for (int i = IotaVtiOcrProcessor.FIRST_FRAME_NO_DIGIT_POSITIONS; i <= IotaVtiOcrProcessor.MAX_POSITIONS; i++) { uint[] pixels = stateManager.GetBlockAtPosition(Image, i, IsOddField); int nuberSignalPixels = pixels.Count(x => x < 127); if (stateManager.IsMatchingSignature(nuberSignalPixels) /* Matches to blank block */) { return(i); } } return(-1); }
private static char OcrBlock(uint[] fieldPixels, IotaVtiOcrProcessor stateManager, int blockIndex, bool isOddField) { uint[] block = stateManager.GetBlockAtPosition(fieldPixels, blockIndex, isOddField); int[] diffSignatures = new int[10]; int[] diffDigits = new int[10]; diffSignatures[0] = GetDiffSignature(block, stateManager.ZeroDigitPattern); diffDigits[0] = 0; diffSignatures[1] = GetDiffSignature(block, stateManager.OneDigitPattern); diffDigits[1] = 1; diffSignatures[2] = GetDiffSignature(block, stateManager.TwoDigitPattern); diffDigits[2] = 2; diffSignatures[3] = GetDiffSignature(block, stateManager.ThreeDigitPattern); diffDigits[3] = 3; diffSignatures[4] = GetDiffSignature(block, stateManager.FourDigitPattern); diffDigits[4] = 4; diffSignatures[5] = GetDiffSignature(block, stateManager.FiveDigitPattern); diffDigits[5] = 5; diffSignatures[6] = GetDiffSignature(block, stateManager.SixDigitPattern); diffDigits[6] = 6; diffSignatures[7] = GetDiffSignature(block, stateManager.SevenDigitPattern); diffDigits[7] = 7; diffSignatures[8] = GetDiffSignature(block, stateManager.EightDigitPattern); diffDigits[8] = 8; diffSignatures[9] = GetDiffSignature(block, stateManager.NineDigitPattern); diffDigits[9] = 9; Array.Sort(diffSignatures, diffDigits); if (stateManager.IsMatchingSignature(diffSignatures[0])) { if (diffDigits[0] == 8 || diffDigits[0] == 6 || diffDigits[0] == 9) { // If we matched to a 6, 8 or 9, then do additional check as those three characters are too similar } return(diffDigits[0].ToString()[0]); } return(' '); }
public void PrepareLastTwoDigitsFromTheFrameNumber(IotaVtiOcrProcessor stateManager) { LastFrameNoDigit = stateManager.GetBlockAtPosition(Image, stateManager.LastFrameNoDigitPosition, IsOddField); SecondLastFrameNoDigit = stateManager.GetBlockAtPosition(Image, stateManager.LastFrameNoDigitPosition - 1, IsOddField); }