I'm currently using the OCR tools in Sikuli API to find a transaction ID from the following screen:
It finds the text and returns the following after a little bit of cleanup:
My question is...How would one best replace the letter characters generated from the OCR with proper Numbers? From what I can see, its fairly consistent with how it deciphers the letters. For example, a '0' usually ends up '1J', a '6' turns into a 'b', and a '7' turns into a 'T'.
For those that are interested, I'll post the code I used to get the OCR to work as most correspondences about this are more then 2 years old.
1) Import your Sikuli libraries into your java project
2) At the top of your class, set the settings to TRUE
3) Setup you image to anchor off of and do a variation of the following code.
Thanks in advance for any help!
I use the same solution as @zerotres proposed myself and meanwhile didn't find anything better. Just few more points to consider that might improve the detection quality:
Option 1:
Make sure that the region enclosing the text doesn't include any unrelated areas, for example the frame around the text (as it appears in the question), etc...
Sometimes it will help moving the region slightly around the area of interest.
In both cases using region.highlight(seconds)
can be helpful to determine what exactly is being covered by the region.
Option 2:
Sometimes, the detected text is unsalvageable and character replacement won't work. In such cases, a different approach might be considered. If you have some static visual pattern near the region of interest, you can use it as a pivot to locate the area of the text. Then, if the text that you are trying to scrape is clickable, you can just select the text (with double click for example) and then read it form the clipboard. That will result in 100% correct outcome.
Figured out a solutions for this...
String transactionId = "1lJ1BT0357317IJ253 ";
System.out.println("Before Conversion: " + transactionId);
transactionId = transactionId.replace("lJ","0");
transactionId = transactionId.replace("IJ","0");
transactionId = transactionId.replace("B","8");
transactionId = transactionId.replace("T","7");
transactionId = transactionId.replace(" ","");
System.out.println("After Conversion: " + transactionId);
Seems to get the job done for me...Hope this helps others.