Skip to content

SuInk/go-captcha-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-captcha-recognition

Go语言实现简单的图形验证码识别

识别步骤

验证码识别步骤为

  1. 读取验证码

  2. 将验证码图片二值化

  3. 将二值化后的图片进行近似等分切割(可能有更好的方法,对于精度不高要求不高的话等分即可)

  4. 将切割后的图片进行识别(调用train()函数,手动标注验证码,生成指纹数组,也可以写入到一个文件中,然后读取)

  5. 将识别后的结果进行拼接

每一个步骤都需要根据验证码特性进行相应代码调整

如何使用

var numSign = [][]string{
       
	{"J", "0000000000000011000000000000001100000000000000110000000000000011000000000000001100000000000000110000000000001111000000000001111100000001111111110000001111111111000111111111111011111111111111101111111111111100111111111110000011111110000000001111111000000000"},
	{"j", "0000000000000011000000000000001100000000001111110000001111111111000011111111111111001111111111101100111111100010110011000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000"},
	{"f", "0000011100000011000001110000001100000111011111110000011111111111000011111111111100111110111111110111111111111110011111111111110001111111100000001111111110000000111101110000000011110111000000001111011100000000111101110000000011110000000000001111000000000000"},
	{"b", "0000000000000011000010000111111100001111111111111111111111111111111111111111111111111111111111101111111111100111111100011000001100000011000000110000001100000111000001110000011100001111000001110000111100001111000011111111111100001111111111100000001111111100"},
	
}

numSign为人工标注验证码生成的指纹数组,不同样式的验证码有不同的指纹库,为了符合您所需要的验证码,请将以上替换为

var numSign = [][]string{}

之后运行train()函数来进行训练,生成的指纹数组被写入 train.txt中,每训练一次需要手动将文本添加到numSign当中

运行train()函数前需要将网址替换为你的网址(或者使用本地图片), 并对二值化, 字符切割等函数进行微调

运行train()并打开./view/01.原始图片.jpeg在控制台输入正确结果并回车

About

Go语言实现简单的验证码识别

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages