{"id":17242825,"url":"https://github.com/imcuttle/verifycode","last_synced_at":"2025-03-26T03:44:23.312Z","repository":{"id":69113281,"uuid":"64069939","full_name":"imcuttle/VerifyCode","owner":"imcuttle","description":"数字验证码识别-\u003ejavac -d out -sourcepath src src/moyu/Services.java -encoding ISO-8859-1","archived":false,"fork":false,"pushed_at":"2016-09-13T03:37:14.000Z","size":116,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T02:34:06.516Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imcuttle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-24T14:42:50.000Z","updated_at":"2019-09-11T13:19:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"8aaa899e-400a-4de1-a72e-90aca2279f81","html_url":"https://github.com/imcuttle/VerifyCode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2FVerifyCode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2FVerifyCode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2FVerifyCode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imcuttle%2FVerifyCode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imcuttle","download_url":"https://codeload.github.com/imcuttle/VerifyCode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245585797,"owners_count":20639671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T06:14:10.667Z","updated_at":"2025-03-26T03:44:23.293Z","avatar_url":"https://github.com/imcuttle.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VerifyCode\n\nJava 实现的数字验证码识别, ...准确率不是很高, 模式识别和去噪处理的不是很好, 但学习入门已经够了，\n而且！！！已经运用至之前做的教务系统的验证码识别\n\n# 识别思路\n\n首先，得到图片数据，如\n\n![/images/src.png]\n\n然后我试着对图片进行各种处理，比如...\n\n1. 变成灰化图\n![](/images/gray.png)\n\n2. 去噪...好像效果不明显\n![](/images/reduceSrc.png)\n\n3. 对灰化图去噪\n![](/images/reduceGray.png)\n\n4. 灰化图转成二值图（阈值128）\n![](/images/grayBin.png)\n\n5. 原图转成二值图（阈值128）\n![](/images/srcBin.png)\n\n6. 对二值图膨胀运算\n![](/images/srcBinExpend.png)\n\n7. 对二值图腐蚀运算\n![](/images/srcBinCorrode.png)\n\n8. 对二值图开运算 (先腐蚀后膨胀)\n![](/images/srcBinOpen.png)\n\n9. 对二值图闭运算 (先膨胀后腐蚀)\n![](/images/srcBinClose.png)\n\n多次实验对比后，发现还是对原图的二值化图最好处理。\n\n然后，便是将图片中的数字分割为固定大小的图片（固定大小是为了后续的模式学习与识别）\n\n其实在这里我可以使用一种比较无赖的方式处理，将这种有规律的数字验证码按照像素点位置进行分割，\n\n但是这样做就没意思了...，所以我选择了用深度优先搜索算法（利用堆栈结构，如果递归，会导致栈溢出），\n\n并且带标记（防止重复处理处理过的点），将八连通的集合分割出来，效果如下\n\n![](/images/srcBinSplit1.png)\n\n![](/images/srcBinSplit2.png)\n\n![](/images/srcBinSplit3.png)\n\n![](/images/srcBinSplit4.png)\n\n当然二值图中的噪点会影响字符的划分\n\n最后便是模式识别算法的选择了，我没有选中书上与网上说的基于向量距离的方法，而是自己想了一个方法，所以识别能力有限...\n\n思路是：先将将一些已知数字的样本进行存储为一串字符串，白色存为\"0\"，黑色为\"1\"\n\n效果如下\n\n![](/images/srcBinSplit-1.png)\n\n```\n\n0111111111\n0111111111\n0111111111\n1100000011\n1000000011\n0000000110\n0000000110\n0000001100\n0001001100\n0000001100\n0000011000\n0000011000\n0000011000\n0000110000\n0000110000\n0000110000\n\n```\n\n![](/images/srcBinSplit-2.png)\n\n```\n\n0000000110\n0000000110\n0000001110\n0000011110\n0000101110\n0001001110\n0001001110\n0010001110\n0100001110\n1000001110\n1111111111\n1111111111\n0000001110\n0000001110\n0000001110\n0000001110\n\n```\n\n将图像编码完成后，对比待识别图片与10种数字样本之间字符\"1\"的位置吻合度，最高的即为识别出来的数字\n\n但是这种方法容易将3，5，8识别错误，或者因为分割的不成功而导致的识别错误。\n\n\n# 代码地址\n- Java源码\n    [VerifyCode](https://github.com/moyuyc/VerifyCode)\n\n- 一键查分（运用该技术）\n    [njnu-quick-get-score](https://github.com/moyuyc/njnu-quick-get-score)\n\n# 参考资料\n\n形态学运算\n\nhttp://blog.csdn.net/bagboy_taobao_com/article/details/5574159\nhttp://blog.csdn.net/hellousb2010/article/details/37939809\n\n字符分割\n\nhttps://www.zhihu.com/question/19702292\nhttp://www.voidcn.com/blog/beechina/article/p-5761020.html\n\nPDF 299 模式识别\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fverifycode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimcuttle%2Fverifycode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimcuttle%2Fverifycode/lists"}