PaddleOCR - Split output Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

PaddleOCR - Split output

Post by MrDodel » 29 Nov 2021, 05:11

Hey all,
I'm working on an script that imports an screenshot, uses PaddleOCR to get the string & value, and then uses an loop to to display the output of each in an message box (for now.)

What I am struggling with is splitting the output into 2 fields," String" And "Value," as it stands it's "String value."

So far my 'working' code:

Code: Select all

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook On
#Persistent
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
DetectHiddenWindows, On
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SetWorkingDir %A_ScriptDir%
Global UserProfile
EnvGet, UserProfile, UserProfile
#Include PaddleOCR\PaddleOCR.ahk

ret := PaddleOCR("DoDStats.png", {"get_all_info":1})
for k, v in ret
{
  words := v.words ;
  MsgBox, 
  (Ltrim
  `t%words%
   )
}
ESC::ExitApp
DoDStats.png
Image used for PaddleOCR
DoDStats.png (83.96 KiB) Viewed 544 times
Output.png
Output from Splitting the image
Output.png (2.31 KiB) Viewed 544 times
Thank you for any guidance :)

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: PaddleOCR - Split output  Topic is solved

Post by mikeyww » 29 Nov 2021, 05:52

It gets some of the text & numbers wrong.

Code: Select all

#Include d:\utils\PaddleOCR-AutoHotkey\PaddleOCR\PaddleOCR.ahk
statistics := []
For each, item in PaddleOCR("D:\temp2\DoDStats.png", {"get_all_info":1})
   RegExMatch(item.words, "i)([\d ,]*)([a-z].*)", part)
 , (part1 > "") && statistics[part2] := RegExReplace(part1, "[ ,]")
; ----------------------------------------------------
For stat, number in statistics               ; Display the list
 list .= (list ? "`n" : "") stat ": " number
MsgBox, 64, Stats, %list%
image211129-0601-001.png
Output
image211129-0601-001.png (10.4 KiB) Viewed 486 times

User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: PaddleOCR - Split output

Post by MrDodel » 29 Nov 2021, 06:03

That'll do nicely, thank you for the prompt response.
So much universe, and so little time. GNU Sir Terry.

Post Reply

Return to “Ask for Help (v1)”