tools/ocr识别.aardio
2024-06-08 20:40:51 +08:00

51 lines
1.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//屏幕找字完整版
import win.ui;
/*DSG{{*/
var winform = win.form(text="string.ocrLite简单演示";right=796;bottom=504)
winform.add(
button={cls="button";text="识别剪贴板图像";left=528;top=423;right=712;bottom=477;db=1;dr=1;z=2};
edit={cls="edit";left=497;top=36;right=764;bottom=403;db=1;dr=1;dt=1;edge=1;hscroll=1;multiline=1;vscroll=1;z=3};
plus={cls="plus";left=25;top=36;right=474;bottom=403;db=1;dl=1;dr=1;dt=1;repeat="scale";z=1}
)
/*}}*/
/*DSG{{*/
var winform2 = win.form(text="输出窗口";right=1151;bottom=745;parent=...;scroll=1)
winform.add()
/*}}*/
//web.form 使用系统自带的 IE 内核,生成的EXE体积很小
//即使 WIN10 删除IE浏览器IE内核浏览器控件仍作为操作系统组件被保留。
//大家通常低估了IE控件的作用IE11已普及一般用不到最新前端技术的话IE控件是非常强大的。
import web.form;
var wb = web.form.ie11( winform2);//低于IE11就自动安装IE11
//相关 OCR 范例:"~\codes\范例程序\2) 调用其他语言\2) dotNet\ocr.aardio"
import string.ocrLite;
import string.ocrLite.defaultModels;
import win.clip;
var ocr = string.ocrLite(,true);
winform.button.oncommand = function(id,event){
var hBmp = win.clip.readBitmap()
if(!hBmp){
winform.edit.print("剪贴板未读取到图像")
return;
}
var bmp = gdip.bitmap(hBmp);
var ocrRet = ocr.detectBitmap(bmp);
if(ocrRet){
winform.plus.background = ocrRet.resultBitmap;
winform.edit.text = ocrRet.text;
}
}
winform.show();
win.loopMessage();