OCR multithreading using java

Asked by Ivan on 2019-10-13

sikuli 1.1.4, using in Java project.

Is it possible to use OCR feature for different region objects in different threads?

Scenario:
there are predefined sikuli region objects. I'm creating two threads (using runnable Thread) and trying to read text from them (region.text()).
As a result I get:
"Please call Init before attempting to set an image." when program is trying to get text.

There is another question that sounds similar:

Rule: only one SikuliX workflow on one machine at the same time.
No exceptions! (https://answers.launchpad.net/sikuli/+question/684947)

If the answer on my question is the same then what is the source of that limitation? Is that a tess4j or is it sikuli implementation? (in other is it possible to use tess4j to get text from images in different threads?)

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-10-13
Last reply:
2019-10-14
RaiMan (raimund-hocke) said : #1

--- Is it possible to use OCR feature for different region objects in different threads?

If you use threading with SikuliX, you have to coordinate the access to screen, mouse and keyboard, since this is the restriction: uncoordinated access to these resources from different threads (or even scripts) will most probably lead to a mess, especially when the threads act on different windows or even applications (visibility/focus).

Therefor the basic rule is: only one script at a time on the same machine.

Exceptions to the rule need special coordination efforts as mentioned above.

about the error message:
 It might be needed, to use an extra TextRecognizer instance (TextRecognizer.start()) in each thread.

Can you help with this problem?

Provide an answer of your own, or ask Ivan for more information if necessary.

To post a message you must log in.