Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Capture Qm Window
#2
@kevin

The above code, I have not tested yet, I want to know, can it generate PNG format pictures?

The following code is the sample code I found in the ron tutorial, it can only generate bmp format images

The BMP format image is too big. I want to send the generated image to Baidu's OCR server and then recognize the text.

If the picture is too large, the sending time will be very long. I think the PNG format is the most suitable.

Macro QM_bmp
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 199 91 "Dialog"
;3 Button 0x54032000 0x0 40 9 129 30 "3. OUTPUT POINTS DRAGGED AREA DESKTOP"
;4 Button 0x54032000 0x0 39 49 130 32 "4. SCREENSHOT DRAG"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,RECT- r
,,EnableWindow id(3 hDlg) 0
,case WM_DESTROY    
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3        
,,out r.left
,,out r.top
,,out r.right
,,out r.bottom        
,case 4
,,str saveTo="$desktop$\new.bmp"
,,if(!CaptureImageOrColor(0 0 hDlg saveTo r)) ret
,,EnableWindow id(3 hDlg) 1
,,;saveTo.UniqueFileName
,,;CaptureImageOnScreen r.left r.top r.right r.bottom saveTo
,case IDOK
,case IDCANCEL
ret 1


I want to implement something like the following Smile


Macro SNA+OCR
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 199 91 "Dialog"
;3 Button 0x54032000 0x0 40 9 129 30 "3. OUTPUT POINTS DRAGGED AREA DESKTOP"
;4 Button 0x54032000 0x0 39 49 130 32 "4. SCREENSHOT DRAG"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,RECT- r
,,EnableWindow id(3 hDlg) 0
,case WM_DESTROY    
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3        
,,out r.left
,,out r.top
,,out r.right
,,out r.bottom        
,case 4
,,str saveTo="$desktop$\new.bmp"
,,if(!CaptureImageOrColor(0 0 hDlg saveTo r)) ret
,,_s=sub.ocr(saveTo)
,,ShowText("Recognition result" _s)
,,
,,EnableWindow id(3 hDlg) 1
,,;saveTo.UniqueFileName
,,;CaptureImageOnScreen r.left r.top r.right r.bottom saveTo
,case IDOK
,case IDCANCEL
ret 1


#sub ocr
function~ ~name
typelib WinHttp {662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1; WinHttp.WinHttpRequest r._create; r.Open("POST" F"https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"); r.setRequestHeader("content-type", "application/x-www-form-urlencoded"); r.SetRequestHeader("cache-control" , "no-cache")
str access= "access_token=24.b305c9822131e65eda05e29c157dd719.2592000.1559103982.282335-16139329&image="
out name
str sFile.getfile(F"{name}");; change to file location
_s.encrypt(4 sFile "" 2); _s.escape(9); r.Send(F"{access}{_s}")
ARRAY(byte) a=r.ResponseBody; str s.fromn(&a[0] a.len)
IXml x=JsonToXml(s); ARRAY(IXmlNode) a1; x.Path("root/words_result/item/words" a1 1)

int i
str d
for(i 0 a1.len)
,;;out a1[i].Value
,d.formata("%s[]" a1[i].Value)
ret d.trim


Messages In This Thread
Capture Qm Window - by Kevin - 07-31-2018, 11:16 PM
RE: Capture Qm Window - by win - 05-07-2019, 12:40 AM
RE: Capture Qm Window - by Kevin - 05-07-2019, 01:10 AM
RE: Capture Qm Window - by win - 05-07-2019, 01:14 AM
RE: Capture Qm Window - by Kevin - 05-07-2019, 01:51 AM
RE: Capture Qm Window - by win - 05-07-2019, 01:55 AM
RE: Capture Qm Window - by Kevin - 05-07-2019, 02:04 AM
RE: Capture Qm Window - by win - 05-07-2019, 02:09 AM
RE: Capture Qm Window - by Kevin - 05-07-2019, 02:34 AM
RE: Capture Qm Window - by win - 05-10-2019, 12:46 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)