[Tutor] Here's what you need

Tiger12506 keridee at jayco.net
Tue Jul 3 00:04:18 CEST 2007


Dear elis:

    I just read the large volume of messages that you have sent causing mild 
confusion and misunderstanding relating to your OCR project. You have 
expressed wishes to learn python quickly, and to take a class. Therefore, I 
suggest you look here - any of these are more than enough of a 'class'.

http://www.freenetpages.co.uk/hp/alan.gauld/
http://www.diveintopython.org/
http://www.byteofpython.info/
http://www.python.org/doc/current/tut/tut.html

If you feel that these 'beginner' tutorials are beneath you, consider that 
after you read these tutorials and ask questions about the material they 
present on this list, you would have a good feeling for what is "built-in" 
to python, and which constructs present the best speed, and would have 
received as much learning from them as from any class you take.

Now as for PIL, I do not have much experience. Even so, a short 20 second 
trip to google gave me this, which gives all of the advice about getdata, 
getpixel, load, etc. that this list has provided so far, and everything else 
that you need.
http://www.pythonware.com/library/pil/handbook/index.htm

Reading the forum link that you posted in one of your messages, I was 
shocked that you would find OCR easier than reading the RAM where the game 
messages are stored. I am pulling my hair out at the fact that you don't 
have the programming background to cower at using OCR for this type of 
project. If you are curious, (I would very much so recommend this), visit 
some C/C++ tutorials and learn a little about what compiled languages are. 
You will learn all about pointers, the stack, function calls, etc.  You will 
thank yourself someday.
(Sorry if this is too diminuitive - I'm shaking from the arggghhh!!! 
feeling)

Okay, now that i've had that little rant, do this:  Write a script that does 
what you want, the OCR, the converting to text, etc., without caring how 
long it takes to run. No one can fix code that you haven't written. Just try 
as hard as you can. Here are guidlines to how you should approach this if 
you don't know how.
Step 1) Save a picture of the screen to a bmp file. (Print screen button, 
then paste into MSPaint)
        2) Use PIL to load the image in.
        3) Use getpixel or getdata - It doesn't matter at this stage! Just 
get code that *runs*
        4) Loop through the pixels building either a dictionary or a nested 
list like in your post
        5) Create an origin (darn what's the word???) a template, a 
beginning, a reference (ahh that's good) a reference list, one that you can 
compare the dict or list in #4 against to get characters.
        6) Use the compare in #5 to build a string of characters that you 
print out (using print)

If you have any troubles with these steps towards writing a working script, 
then write to this list, being sure to explain how you thought what you 
wrote would work, how it doesn't fit the result you want to acheive, the 
complete code (since you seem to cause confusion with fragments of code) as 
an attachment(!) ( Don't worry it won't be *that* long), any error messages 
you get, which step you are on (by description, not number, thank you), and 
a complete overview of what you are trying to acheive (That would be - 
"Write a Optical Character Recognition script that reads the screen of a 
game and converts it into the equivalent text")

HTH you and the other members of the list,
Jacob S.

P.S. Google is your friend, my friend 



More information about the Tutor mailing list