验证码识别技术

来源:百度知道 编辑:UC知道 时间:2024/06/19 04:09:55
如题,本人在做一个关于验证码识别的程序。要求识别的是随机英文字母+随机数字+随机颜色+随机位置+随机长度。有高手来帮帮忙哦。若是有最基础的随机数字+随机大写英文字母的四位验证码识别的程序,也给分哦。邮箱地址ningmengxinxin@163.com。急,谢谢各位!

public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException
{
// 验证码图片的宽度。
int width = 70;
//验证码图片的高度。
int height=36;
BufferedImage buffImg=new BufferedImage(width,height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g=buffImg.createGraphics();

//创建一个随机数生成器类。
Random random=new Random();

// 设定图像背景色(因为是做背景,所以偏淡)
g.setColor(getRandColor(180, 250));
g.fillRect(0,0,width,height);
//创建字体,字体的大小应该根据图片的高度来定。
Font font=new Font("Times New Roman",Font.PLAIN,28);
//设置字体。
g.setFont(font);

//画边框。
g.setColor(Color.BLACK);
g.drawRect(0,0,width-1,height-1);
// 随机产生160条干扰线,使图象中的认证码不易被其它程序探测到。
g.setColor(Color.GRAY);
for (int i=0;i<50;i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl =