C#源代码,数字识别,特征识别,新浪数字,验证码识别
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
using System;
using System.Collections.Generic;
using ponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace测试数字提取
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//新浪微博数字识别,根据rgb红色分量150一下的识别
//下面是每个数字的特征
class NewNumber
{
static int[,] _num1 = new int[9, 7]
{{0,0,0,0,1,0,0},{0,0,0,1,1,0,0},{0,0,1,0,1,0,0},{0,0,0,0,1,0,0},{0,0,0,0,1,0,0}, {0,0,0,0,1,0,0},{0,0,0,0,1,0,0},{0,0,0,0,1,0,0},{0,0,0,0,1,0,0}};
static int[,] _num2 = new int[9, 7]
{{0,0,1,1,1,1,0},{0,1,0,0,0,1,0},{0,1,0,0,0,0,1},{0,0,0,0,0,1,0},{0,0,0,0,0,1,0}, {0,0,0,1,1,0,0},{0,0,1,1,0,0,0,},{0,1,1,0,0,0,0},{0,1,1,1,1,1,1}};
static int[,] _num3 = new int[9, 7]
{{0,0,1,1,1,0,0},{0,1,0,0,0,1,0},{0,0,0,0,0,1,0},{0,0,0,0,0,1,0},{0,0,0,1,1,0,0}, {0,0,0,0,0,1,0},{0,0,0,0,0,0,1},{0,1,0,0,0,1,0},{0,0,1,1,1,0,0}};
static int[,] _num4 = new int[9, 7]
{{0,0,0,0,0,1,0},{0,0,0,0,1,1,0},{0,0,0,1,1,0,0},{0,0,0,0,0,1,0},{0,0,1,0,0,1,0}, {0,1,0,0,0,1,0},{0,1,1,1,1,1,1},{0,0,0,0,0,1,0},{0,0,0,0,0,1,0}};
static int[,] _num5 = new int[9, 7]
{{0,0,1,1,1,1,0},{0,0,1,0,0,0,0},{0,0,0,0,0,0,0},{0,1,1,1,1,1,0},{0,1,0,0,0,0,0}, {0,0,0,0,0,0,1},{0,0,0,0,0,0,1},{0,1,0,0,0,0,0},{0,0,1,1,1,0,0}};
static int[,] _num6 = new int[9, 7]
{{0,0,0,1,1,0,0},{0,0,1,0,0,1,0},{0,1,0,0,0,0,0},{0,1,0,1,1,0,0},{0,1,1,0,0,1,0}, {0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,0,1,0,0,1,0},{0,0,1,1,1,0,0}};
static int[,] _num7 = new int[9, 7]
{{0,1,1,1,1,1,1},{0,0,0,0,0,1,0},{0,0,0,0,1,0,0},{0,0,0,0,1,0,0},{0,0,0,1,0,0,0}, {0,0,0,1,0,0,0},{0,0,0,1,0,0,0},{0,0,0,0,0,0,0},{0,0,1,0,0,0,0}};
static int[,] _num8 = new int[9, 7]
{{0,0,1,1,1,0,0},{0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,0,1,1,1,0,0}, {0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,0,1,1,1,0,0}};
static int[,] _num9 = new int[9, 7]
{{0,0,1,1,1,0,0},{0,1,1,0,0,1,0},{0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,1,1,0,0,1,0}, {0,0,1,1,1,0,0},{0,0,0,0,0,1,0},{0,1,0,0,0,1,0},{0,0,1,1,1,0,0}};
static int[,] _num0 = new int[9, 7]
{{0,0,1,1,1,0,0},{0,0,1,0,0,1,0},{0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},{0,1,0,0,0,1,0},{0,0,1,0,0,1,0},{0,0,1,1,1,0,0}};
int[,] locat = new int[200, 200];//将图像数字化,红色分量150一下的记为1
int[,] locatB = new int[200, 200];//图片数字化,将蓝色分量200以下的记为1
int starX = 0;
int starY = 0;
//图像数字化
private void NumberLocation(Bitmap bmp)
{
for (int i = 0; i < bmp.Height; i++)//控制行数y
{
for (int j = 0; j < bmp.Width; j++)//{
Color c = bmp.GetPixel(j, i);
if (c.B < 200)
{
locatB[i, j] = 1;
}
else
{
locatB[i, j] = 0;
}
if (c.R < 155)
{
locat[i,j] = 1;
}
else
{
locat[i,j] = 0;
}
}
}
}
//确定图片中数字在第几行开始
private void NumberStarX(int[,] locat)
{
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 79; j++) {
if (locat[i, j] == 1)
{
starX= i;
return;
}
}
}
}
//确定图像在第几列开始
private void NumberStarY(int[,] locatB)
{
for (int i = 0; i < 79; i++)
{
for (int j = 0; j < 12; j++)