Sign in to follow this  
Followers 0
S0789300

Issues with MODI/OCR Scripting

14 posts in this topic

Ok, so i've been using a modified version of Ptrex's code which OCR's the screen using MODI. it works fine, but ive stumbled on a few quirks that is making my life a little difficult and I was hoping someone could either help me, or lend me some insight.

I am OCR'ing a section of the screen using a screenshot capture program via the command line. This works. It makes a square capture that I define, so the size of this doesn't change. The text/numbers in the region does change. It's a list of items and their associated amounts, and this can change randomly. I can easily detect when there is a change, and then capture again and OCR. It works perfectly when I don't try and capture the numbers before hand... let me explain. The list could look something like this:

2 Gun AB

4 Alpha Numeric G

1 Gallicolfa

6 URtfolia

Remember, its within a screenshot I already captured. So the numbers in the list are near the left border of the screen. When I just capture the words (ie, set the screenshot to capture an X position AFTER the number column) the OCR algorithm works fine and spits out the right words. When I set the X position before the number column, to attempt to read the numbers and the words, it fails miserably - Either it just spits out the words without the numbers, or only catches a few numbers at a time.

I have thought about this and think this could be due to a few things. First, it seems MODI OCR doesn't like text/numbers near the edge of the screenshot. Its almost like there is a border of accuracy, and its much better at recording and spitting out words etc in the middle of the screenshot. If this is the case, is there a way around this?

Another issue, is when I just capture the number column, without the words (in an attempt to just see some numerals up there), it misses everything completely and doesn't spit out anything, usually just an error. Im guessing this is because the region is small and therefore that border of accuracy I mentioned above just overlaps the entire image and therefore it cannot read anything, OR I have to set a parameter I am missing to let it read numbers as numbers and not just defined everything as words English... does this make sense?

If anyone has some insight into this I would be very grateful. I can provide examples of the images via message or examples of code via message to if anyone wants.

Share this post


Link to post
Share on other sites



This is probably the wrong forum, you should either have posted in ptrex's thread, or in general help[ and support.

There have been problems with ocr and numbers, often with 1 being interpreted as L etc.

as for your "border of accuracy", if thats true, then just get to know GDI+ or similar, and extend the picture to have the numbers in the middle. I do not know how, but its possible.

Mat

Share this post


Link to post
Share on other sites

I am using Minicap's screen captor. I can make the image larger, but it still has the border problems. If that is indeed the problem.

Share this post


Link to post
Share on other sites

I am using Minicap's screen captor. I can make the image larger, but it still has the border problems. If that is indeed the problem.

Its not larger that I mean, What I mean is that you edit the image to have white space around the sides, creating a broder, and hopefully meaning the numbers are in the middle. It should be possible with GDI+

Mat

Share this post


Link to post
Share on other sites

And I can implement GDI+ simple commands via Autoit?

Share this post


Link to post
Share on other sites

Wow, I apologise if I offended you with my questions. I don't know any GDI+ - didn't even know about it until I googled it after your post.

I don't even know if you are referring to GDI+'s helpfile or autoit's help system in your last post. GDI looks like its just C++ classes, and I don't know how to implement C in Scite... (though I do know some C++)

Share this post


Link to post
Share on other sites

I take that last comment back - I found the GDI methods in Scite. I will look into them.

Share this post


Link to post
Share on other sites

look in the helfile was what I was hinting at... Look at user defined functions => GDIPLUS management.

Mat

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Hey Matt - any thoughts why its not just this simple to draw a rectangle on it:

$sFileName = "D:\My OCR\Testing2.gif"
    _GDIPlus_Startup ()
    
    Local $hGraphics
    
    $hImage = _GDIPlus_ImageLoadFromFile("D:\My OCR\OCR_tgt.gif") ; creates the GDI object
    
    $iX = _GDIPlus_ImageGetWidth ($hImage)
    $iY = _GDIPlus_ImageGetHeight ($hImage)
    

    
    _GDIPlus_GraphicsDrawRect ($hImage, 0, 50, 50, 50)
    
    _GDIPlus_ImageSaveToFile($hImage, $sFileName)
    
    _GDIPlus_ImageDispose ($hImage)
    _GDIPlus_ShutDown ()

It just doesn't draw anything for me. I've wiggled the pixel dimensions around to make sure I wasn't breaking any boundaries.

Edited by S0789300

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

No Idea :D

GDI+ is not my strong point. actually... I have never really used it before :D, but I have seen what can be done with it, and this should be easy.

How about posting in the General help and support forum with the question rather than example scripts? Chances are, no one who wants to help will find it here.

Mat

Edit: WOW... I just posted in example scripts and... tadaa! im in genereal help and support! Its magic!

Edited by Mat

Share this post


Link to post
Share on other sites

No Idea :D

GDI+ is not my strong point. actually... I have never really used it before :D, but I have seen what can be done with it, and this should be easy.

How about posting in the General help and support forum with the question rather than example scripts? Chances are, no one who wants to help will find it here.

Mat

Edit: WOW... I just posted in example scripts and... tadaa! im in genereal help and support! Its magic!

Thanks for moving the thread to the correct forum.

Share this post


Link to post
Share on other sites

Thanks for moving the thread to the correct forum.

Still hasn't answered your question though! Rename the title to GDI+ Edit image or something. That way the local GDI+ guru will answer!

Mat

Share this post


Link to post
Share on other sites

How do I change the title of the thread?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0