How can I use tesseract from command line to read inside an opened window? - command-line

I'm trying to use tesseract from command line to run OCR on the content of an opened window. In particular I'm willing to read the text typed into a current opened Notepad window.
I've read the documentation and the wiki here: http://code.google.com/p/tesseract-ocr/w/list
but I didn't find anything that helped me in this project, further more I've also searched here for similar questions ( there are many about OCR) but nothing seems to work/ be applicable in my case.
Is it feasible?
I'm mainly a PHP coder (coding just for fun) and have no experience in non-web languages.
Thanks in advance.

Tesseract is designed to take a TIFF image as input and know nothing about the Windows or screen Device Contexts. So you would need to add code to locate the windows handle for the Notepad window , perform a screen capture and clip the window based on the current window size reported by Windows and save the resulting image to a file. This image will most likely be black and white which will make it easier to OCR as I suspect Tesseract 2.0 only works with B/W Images. The next problem will be Tesseract gving poor results due to the low DPI (resolution) of the source image.
To evaluate the suitability of your approach I would perform some manual tests by opening Notepad, taking screenshots, opening the screenshots in MSPaint, clipping the text you want to OCR, save the clipped image to a TIFF or BMP and send this file to Tesseract. This could save you a lot of time and effort if the results are not as good as you need or expect.

Related

Distortion in fonts after converted Ai file into png

guys.
I need some help with some Ai thingy. Recently I try converted Ai file into png and it works fine but later I found out that some of the fonts have changed and so the proportions become off. I tried to review back to my Ai design and everything was fine there, proportioned wise etc. I tried using other converter and none of it works. if it works, the same problem occurs. I need to know if anyone can help me with it.
In Illustrator, use "Export..." from File menu and select PNG as the file type. In the export settings, choose the highest DPI setting and consider the other options in that dialog if you are not happy with the result.
This will render out a PNG with the same fonts and should look like what the file looks like on your computer.

Swift saves bmp as “Flip row order”

I'm using Swift in iOS and used the code based on this SO post to save a UIImage as a bmp
Convert UIImage to NSData and convert back to UIImage in Swift?
The data I create and save is recognized as a bmp in Photoshop and Preview but can’t be read by the Adafruit PyPortal. The only diff I can find is that when I resave the bmp in Photoshop as a bmp again, it shows as “Flip row order” selected in the BMP options screen that appears right after the main save screen.
If I uncheck this option and save the file, the PyPortal can then read this resaved file. This post above was great for getting the UIImage into .bmp format, but I need to get this additional file change done programmatically on iOS, so opening in a third-party product, or working with shell commands won't work as a solution. I’ve not been able to find anything in Apple’s docs that looks like it corresponds to Flip row order and there isn’t much online about this option within Photoshop so it’s unclear even what this does.
For the curious I have samples of the bmp my app creates as well as options resaved or run through an online converter (both these options work on PyPortal).
https://drive.google.com/drive/folders/1DQYes-cJXKm3ue8Z9cACDLEN5bxnnkJc
Any suggestions are appreciated. Thx!
The “Flip row order” option tells the bmp reader software to read the first row of pixels first and the last row of pixels last. This is not the “normal” way most bmp reader interpret a bmp format image. Most implementations read from the last row first and then work its way up to the first row of pixels.
Your options are either, rewrite the bitmap creating software so that it matches the abilities of the bmp reader software or change the bmp reader software so it can read the bmp file.
I’m fully aware this doesn’t solve the issue but can help understanding what it going wrong and guide you in the right direction.

Using tesseract plugin in ionic 3 project to get text from image

I am getting wrong output, code run perfectly but don't know where is the problem
I believe the issue you are faced with is not related to only one point.
There could be problem with cropping: the characters appearing near to the borders may affect on the result.
There is a black line above the text which can also make troubles.
Also the blinking part of the text could become a trouble after preprocessing.
Here is a helpful link I would recommend to read for improving the OCR quality.
For example if your cases are always a single line text, then you can use -psm 7 to help Tesseract.

Is there a way to recognize text in a graphic or a picture with tesseract?

First, sorry for my English. I have a question regarding tesseract. Is there a way to recognize text in a graphic or a picture without having to clean the image you want to recognize? in what I read there to clean the image first, remove graphics and photographs and leave only the text. But I want the user to upload to the server and newspaper clippings you can recognize this news without human intervention. It can be tricky. But if you know any other way I could do as they are grateful. Thank you very much
No, you can't.
Tesseract is made for reading text and only text. When you perform OCR on a subject with both text and an image, Tesseract spits out things it finds in the image (garbled crap).
You can detect image regions and crop them out, though. I think that would be a better question to ask.

Default-Portrait.png for iPad: any way to make the file size smaller?

I'm making a Universal App using MonoTouch, and I'm adding my Default-Portrait.png file. That file alone (a 768x1004 .png file) is adding 711k to the size of the app. My app itself is only about 7 megs, so it's adding 10% just for the splash screen.
I could easily make this thing an 80k jpg file instead of a png, but the device doesn't seem to look for a .jpg file. Does anyone have tips for reducing the size of this launch art?
At this point, I'm thinking I might just leave the launch art out and load my own jpg and display it as soon as I have the ability to. That'll keep my app size down, but it's not as nice as having the launch art scale in immediately like most apps do.
Hmmm...given the screen of the iPad and the visual quality users are expecting, I'd just leave it like that.
But if you do want to reduce the disk space, try going to Project > Edit Project Settings > Build (tab at top), and searching for a parameter called "Compress PNG Files." Make sure that's checked. It'll run the pngcrush utility before loading the file onto disk (check the size of your IPA archive after to see if it had any effect).
pngcrush is nice as well, however that will not reduce the quality of you image. If reducing the quality of the image is an option for you, then you might try this tool: http://www.punypng.com/ - or just use an image editing tool to "optimize" the image ...
I recommend pngout if you want to really squeeze those PNGs down, and this won't cost you any quality. It simply removes unnecessary metadata (like pngcrush) and uses its own compression algorithm which is compatible with the regular decompressor used in PNG (zlib). It's really slow, though.
A simpler option is to try "Save for web" in your image manipulation program of choice. Exporting from Acorn (not just the regular save) sometimes gives me vastly smaller files. This is especially true for default images which have large, uniform areas in one colour (screenshots, a small logo in the middle of a black screen).
Is there any reason why you want to reduce the file size that badly? I don't think it matters in your case. I just checked 3 of my apps and the Default.png (of various portrait/landscape varieties) is between 29KB and 422KB, so whilst yours do seem a little heavy, your still way under the 3G download limit.
Are you positive it's adding that much to the size of the app? Did you compare a before and after?
Xcode uses pngcrush on the images for you. I know because I just tried to substitue jpegs for pngs and got the following result:
So, in short, there's not a lot to be done except simplify the image beforehand. Xcode will handle the rest.