核心算法:简单字典匹配
先切割字符,二值化,将每个字符转换为01字符串之后进行字典匹配比较
private string Translate(string charToTranslate)
{
var array = charToTranslate.ToCharArray();
char max=' ';
int maxScore=0;
var results = digits.Select(digit =>
{
int i = 0;
int s = 0;
var digitArray = digit.ToCharArray();
array.All(pixel =>
{
if (i < digitArray.Length-2)
{
if (pixel == digitArray[i+2])
{
s++;
}
}
i++;
return true;
}
);
return new { name = digitArray[0], score = s };
}
).ToList().All(pair =>
{
if (pair.score > maxScore)
{
maxScore = pair.score;
max = pair.name;
}
return true;
});
return max.ToString();
}
}
目前所用字典:
0,000000000000000011100000001111111000001100011000011000001100011000001100011000001100011000001100011000001100011000001100011000001100001100011000001111111000000011100000
1,0000111000000011111000000011111000000000011000000000011000000000011000000000011000000000011000000000011000000000011000000000011000000011111111000011111111000
2,00011111000000111111100000100000110000000000110000000000110000000001100000000011000000000110000000001100000000011000000000110000000000111111110000111111110
3,000010000000001111100000011111111000010000011000000000011000000000111000001111100000001111110000000000111000000000011000000000011000010000111000011111110000001111100000
4,000000011000000000111000000000111000000001111000000011011000000011011000000110011000000110011000001111111110001111111110000000011000000000011000000000011000
5,00000000000000111111110000111111110000110000000000110000000000110000000000111110000000111111100000000001110000000000110000000000110000100001110000111111100000011111000
6,0000111100000001111110000011000010000011000000000110000000000110111100000111111110000111000111000110000011000110000011000011000111000011111110000000111100000
7,001111111100001111111100000000001100000000001000000000011000000000110000000000100000000001100000000001000000000011000000000011000000000110000000000110000000
8,000000000000000011111000000111111100000110001100000110001100000111001000000011111000000011111000000110011100001100000110001100000110001110001110000111111100000011111000
9,000111100000001111111000011100011000011000001100011000001100011100011100001111111100000111101100000000001100000000011000001000011000001111110000000111100000
5,001111111100001111111100001100000000001100000000001100000000001111100000001111111000000000011100000000001100000000001100001000011100001111111000000111110000
8,0001111100000011111110000011000110000011000110000011100100000001111100000001111100000011001110000110000011000110000011000111000111000011111110000001111100000
9,000011110000000111111100001110001100001100000110001100000110001110001110000111111110000011110110000000000110000000001100000100001100000111111000000011110000
1,000001110000000111110000000111110000000000110000000000110000000000110000000000110000000000110000000000110000000000110000000000110000000111111110000111111110
0,00000111000000011111110000011000110000110000011000110000011000110000011000110000011000110000011000110000011000110000011000011000110000011111110000000111000
1,0000111000000011111000000011111000000000011000000000011000000000011000000000011000000000011000000000011000000000011000000000011000000011111111000011111111000
2,00011111000000111111100000100000110000000000110000000000110000000001100000000011000000000110000000001100000000011000000000110000000000111111110000111111110
3,000010000000001111100000011111111000010000011000000000011000000000111000001111100000001111110000000000111000000000011000000000011000010000111000011111110000001111100000
4,000000011000000000111000000000111000000001111000000011011000000011011000000110011000000110011000001111111110001111111110000000011000000000011000000000011000
5,00000000000000111111110000111111110000110000000000110000000000110000000000111110000000111111100000000001110000000000110000000000110000100001110000111111100000011111000
6,0000111100000001111110000011000010000011000000000110000000000110111100000111111110000111000111000110000011000110000011000011000111000011111110000000111100000
7,001111111100001111111100000000001100000000001000000000011000000000110000000000100000000001100000000001000000000011000000000011000000000110000000000110000000
8,000000000000000011111000000111111100000110001100000110001100000111001000000011111000000011111000000110011100001100000110001100000110001110001110000111111100000011111000
9,000111100000001111111000011100011000011000001100011000001100011100011100001111111100000111101100000000001100000000011000001000011000001111110000000111100000
5,001111111100001111111100001100000000001100000000001100000000001111100000001111111000000000011100000000001100000000001100001000011100001111111000000111110000
8,0001111100000011111110000011000110000011000110000011100100000001111100000001111100000011001110000110000011000110000011000111000111000011111110000001111100000
9,000011110000000111111100001110001100001100000110001100000110001110001110000111111110000011110110000000000110000000001100000100001100000111111000000011110000
1,000001110000000111110000000111110000000000110000000000110000000000110000000000110000000000110000000000110000000000110000000000110000000111111110000111111110
0,00000111000000011111110000011000110000110000011000110000011000110000011000110000011000110000011000110000011000110000011000011000110000011111110000000111000
单个字符识别率90%左右
打包下载
https://files.cnblogs.com/clowwindy/jscode2.zip