deo Posted March 11, 2007 Share Posted March 11, 2007 (edited) First Off, I was having trouble finding an OCR script on here that could be considered reliable. Most of the OCR's I've seen only counts the width of the characters. The downside of that is that with some fonts, different letters will have the same credentials, therefore rendering the script useless.I wanted an OCR that would be able to differentiate between all characters, not just based off of a X coord, but a Y coord as well. Second, I was having trouble getting any help on the subject and thought that this community could use something useful and reliable. So I spent the weekend working on this and have decieded to release this to everyone in hopes that it will help someone else.Here's how it works:The script will scan from left to right, and from BOTTOM to Top. The bottom-left pixel for each letter will be given a coord of (0,0) and will scan and detect from there.Example: Instead of performing multiple loops and checking arrays, this script check's to see what the character is after it's done scanning a single letter.In order for this script to work, a "baseline" must be specified. This baseline is the very-bottom pixel of ANY letter of the area you are scanning. This would include lowercase "g", "j", "p", "q", "y", etc. Because it scans from bottom to top, the baseline is the start of the scan. The actual width doesnt matter, as long as its wider than the text you want to scan, but the baseline has to be EXACT. The baseline should equal Y position + Height of area to scan.This is my first script, so the code might not be as advanced as some of the guru's around here, so feel free to give me feedback on what could make this script better/faster.The downside of this script is that it only has the ability to read one line of text, it doesnt support multi-line text.Anyway, download it and try it out. Please let me know what you think.~DeoDeoOcr.rar Edited March 11, 2007 by deo Link to comment Share on other sites More sharing options...
deo Posted March 11, 2007 Author Share Posted March 11, 2007 I also want to make mention that with $Debug set to 1, and if the parameters are correct, the script will build a definition's list (in the form of a Switch/Case) for the font specified. Link to comment Share on other sites More sharing options...
McGod Posted March 11, 2007 Share Posted March 11, 2007 Shouldn't this be in example scripts? [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
deo Posted March 11, 2007 Author Share Posted March 11, 2007 Hmm, didnt quite think of that. Mod's feel free to move if you wish. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 11, 2007 Moderators Share Posted March 11, 2007 (edited) Easy to look through that's for sure... nice work, and I like what you were thinking when you wrote it. I have to say that I'd still like to see a bit different optimization, and arrays in the _CheckChar() function, but all in all, you could actually make this sounder than others for sure. When I get a bit more time, I'll have a "deeper" look. Also... Didn't you mean to post this in the scripts and scraps forum? If so, I'm sure a mod will have no problems moving it for you. Edit: Ooops, someone already stated the forum... and I even gave it it's old name lol. Edited March 11, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
deo Posted March 11, 2007 Author Share Posted March 11, 2007 When I get a bit more time, I'll have a "deeper" look.Yes, please do. I'd like to make this as optimized and fast as it can possibly be. Im sure alot of people would appreciate something like this. I sure would have a few days ago Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 11, 2007 Moderators Share Posted March 11, 2007 Yes, please do. I'd like to make this as optimized and fast as it can possibly be. Im sure alot of people would appreciate something like this. I sure would have a few days ago It seems to be font and or size specific. What font and size did you use? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
deo Posted March 11, 2007 Author Share Posted March 11, 2007 Its a FFF font (http://fontsforflash.com/). If you want to give it a different font, you will need to specify the $CharMaxWidth & $CharMaxHeight, and the base line has to be exact for detection to take place. The area that you're scanning needs to be the height of the font itself. Link to comment Share on other sites More sharing options...
deo Posted March 12, 2007 Author Share Posted March 12, 2007 Can a mod please move this thread to the example scripts forum? I think it would be more fitting there and I dont want to double post.... Link to comment Share on other sites More sharing options...
Rizzet Posted April 6, 2007 Share Posted April 6, 2007 (edited) Hi, im been playing little with your OCR and i like it alot. I put in a little "shade" in it, but havnt been tested enogh. Can you give me a fast curse how the cord system work... i tried to make my own Numbers to it but the OCR dont find it (in the Debug it find the 3 as a B but it doesnt print a B or a 3 ) Edited April 6, 2007 by Rizzet Link to comment Share on other sites More sharing options...
Rizzet Posted April 10, 2007 Share Posted April 10, 2007 I like your script alot, i have now learned how to use it and im using it in 1 of my scripts. but well with some "fonts" dont know why but it gets messed up and wont work. Now i found out that its not reseting the Y axel everytime its a new Y line so i made this little change and works fine now expandcollapse popupFor $tLeft = $Left To (($Width - 1) + $Left) $FilledLine = 0 For $tTop = $BaseLine To $BaseLine - $CharMaxHeight Step -1 If Hex(PixelGetColor($tLeft, $tTop), 6) = $CharColor Then If $Debug = 1 Then GUICtrlCreatePic("img\blue.bmp", $tLeft, $tTop+$BaseLine, 1, 1) GUISetState(@SW_SHOW) EndIf ;_msg($X & @CR & $Y) $A &= $X & $Y $FilledLine = 1 EndIf If ($Y < ($Height - 1)) Then $Y += 1 Else $Y = 0 EndIf Next $Y = 0 ;<--------------------------------------------------This is the change Now everytime it comes to a new line the Y resets to 0 If $X <= $CharMaxWidth Then ;Check for an empty vertical line If $FilledLine = 0 Then If $Debug = 1 Then GUICtrlCreatePic("img\red.bmp", $tLeft, $tTop, 1, 11) GUISetState(@SW_SHOW) EndIf If $A <> "" Then ;We found a space between letters, lets check and see what letter we found. $StringReturn &= _CheckChar() $A = "" EndIf $X = 0 Else $X += 1 EndIf Else $X = 0 EndIf Next Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now