识别邮政网银红黑干扰验证码例子
By
admin
at 2019-07-02 • 0人收藏 • 1705人看过
感谢aar群里: 小学生 提供的ocr识别dll和库
邮政验证码有红黑干扰, 需要祛除黑色字干扰, 这个利用gpid.bitmap就可以了.
import win.ui; import Tocr; import inet.http import crypt.bin /*DSG{{*/ mainForm = win.form(text="OCR英数万能高级版";right=359;bottom=221) mainForm.add( button={cls="button";text="识别";left=39;top=167;right=130;bottom=205;z=3}; button2={cls="button";text="识别";left=229;top=167;right=320;bottom=205;z=6}; edit={cls="edit";left=92;top=120;right=263;bottom=151;disabled=1;edge=1;z=2}; groupbox={cls="groupbox";left=10;top=3;right=353;bottom=216;edge=1;z=1}; picturebox={cls="picturebox";left=39;top=32;right=164;bottom=93;border=1;notify=1;z=4}; picturebox2={cls="picturebox";left=214;top=32;right=339;bottom=93;border=1;notify=1;z=5} ) /*}}*/ import gdip; import console console.open() Tocr = Tocr() http = inet.http() mainForm.button.oncommand = function(id,event){ if(!img){mainForm.edit.text = "请先点击图片框下载验证码!" return;} var img = crypt.bin.encodeBase64(img) var code = Tocr.OcrCode(img) if(code){mainForm.edit.text = "识别结果为:"++code } } getimg = function(){ img = http.get("https://pbank.psbc.com/perbank/VerifyImage?update=0.9671032051568338") mainForm.picturebox.image = img if(img){ bmp = gdip.bitmap( img ) //获取位图数据 var bmpdata = bmp.lockData32(); //修改图像内存数据 for(h=1;bmp.height ){ for(w=1;bmp.width){ if(bmpdata.bits.rows[h].pixels[w] <= 0xFF677379){ bmpdata.bits.rows[h].pixels[w] = 0xFFD9F5FF; } } } //解除内存锁定、刷新的位图数据 bmp.unlockData(bmpdata); mainForm.picturebox2.setBitmap(bmp.copyHandle()) ; } } mainForm.picturebox.oncommand = function(id,event){getimg()} mainForm.button2.oncommand = function(id,event){ var hbmp = bmp.saveToBuffer() if(!hbmp){mainForm.edit.text = "请先点击图片框下载验证码!" return;} var hbmp = crypt.bin.encodeBase64(hbmp) var code = Tocr.OcrCode(hbmp) if(code){mainForm.edit.text = "识别结果为:"++code } } mainForm.show(); return win.loopMessage();
2 个回复 | 最后更新于 2024-06-18
登录后方可回帖
大佬,ocr识别dll和库能分享一下吗