Untitled
unknown
c_cpp
2 years ago
8.2 kB
4
Indexable
// OCR.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <stdio.h> #include <stdint.h> // for int16_t on windows #include <string.h> #define DigitBitmapHeight 24 #define DigitBitmapWidth 16 int16_t DigitBitmap[9][DigitBitmapHeight] = { {0, 0, 96, 224, 224, 992, 4064, 4064, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 0, 0}, {0, 0, 496, 2044, 4092, 7710, 7182, 14350, 14351, 14, 30, 60, 124, 496, 2016, 3968, 7680, 7168, 14336, 16382, 16382, 16382, 0, 0}, {0, 0, 992, 4088, 8188, 7196, 14350, 14350, 14350, 28, 252, 504, 508, 30, 14, 14, 14350, 14350, 14350, 15422, 8188, 4080, 0, 0}, {0, 0, 56, 120, 120, 248, 504, 440, 952, 1848, 3640, 3640, 7224, 14392, 14392, 16383, 16383, 56, 56, 56, 56, 56, 0, 0 }, {0, 0, 4092, 4092, 4092, 3072, 7168, 7168, 7168, 8176, 8184, 8188, 7198, 14, 14, 15, 14, 14350, 14350, 15932, 8188, 4080, 0, 0}, {0, 0, 496, 2044, 4092, 7710, 7182, 7174, 14336, 14832, 15352, 16380, 15902, 15374, 14350, 14343, 14343, 14350, 7182, 7708, 4092, 2032, 0, 0}, {0, 0, 16382, 16383, 16383, 14, 28, 28, 56, 112, 112, 224, 224, 448, 448, 960, 896, 896, 1920, 1792, 1792, 1792, 0, 0, }, {0, 0, 992, 4088, 8188, 7198, 7182, 14350, 7182, 7196, 4092, 4088, 8188, 15390, 14350, 14350, 14350, 14350, 15374, 7710, 8188, 2040, 128, 0, }, {0, 0, 992, 4088, 8188, 7196, 14350, 14350, 14350, 14350, 14350, 15390, 7742, 8190, 2030, 14, 14, 14364, 14364, 7224, 8184, 4080, 0, 0, } }; unsigned char Cell_8[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0, }; int masking(int ligne, int colonne, int valeur) { //int bitwiseReturn = (DigitBitmap[ligne][colonne] >> valeur) & 1; int bitwiseReturn = (DigitBitmap[ligne][colonne] & 1 << (15 - valeur)) == (1 << (15 - valeur)); return bitwiseReturn; };//returns 0 or 1 from bitmap /*int compare(int position) { for (int i = 0; i < 0; i++) { } Cell_8[postition] ; };*/ int main(int argc, const char* argv[]) { char kur[] = { 98, 91, 78, 78, 85, 78, 78, 90, 76, 75 }; double c; int cellDecimal[DigitBitmapHeight][DigitBitmapWidth]; int counter[9] = {0}; int counterHelp = 0; //memset(counter, 0, sizeof(counter)); //int m = 0; for (int chiffresBitmap = 0; chiffresBitmap < 9; chiffresBitmap++) //chifres de 1 à 9 du bitmap { for (int cellVert = 0; cellVert < 44 - DigitBitmapHeight; cellVert++) //déplacements verticales dans cell { for (int cellHoriz = 0; cellHoriz < 44 - DigitBitmapWidth; cellHoriz++) //déplacements horizontales dans cell { for (int bitmapVert = 0; bitmapVert < DigitBitmapHeight/*24*/; bitmapVert++) //colonnes de bitmap { for (int bitmapHoriz = 0; bitmapHoriz < DigitBitmapWidth/*16*/; bitmapHoriz++) //lignes de bitmap { int situation = bitmapHoriz + (bitmapVert * 44) + (cellHoriz)+(cellVert * 44); /*if (situation == 1056) { m++; }*/ if (masking(chiffresBitmap, bitmapVert, bitmapHoriz) == Cell_8[situation]) { counterHelp += 1; } } } if (counterHelp > counter[chiffresBitmap]) //numberOfCoincidences { counter[chiffresBitmap] = counterHelp; } counterHelp = 0; } } //printf("%d ", m); } for (int k = 0; k < 9; k++) { if ((counter[k] * 100 / 384) > kur[k + 1] || (counter[k] * 100 / 384) >= kur[0]) { printf("%d is the number with a percentage of %d", k + 1, (counter[k] * 100 / 384)); } } /*for (int t = 0; t < 9; t++) { printf("%d ", counter[t]*100/384); }*/ }
Editor is loading...