Why does Tesseract CLI show 'cannot create output file' on Windows 7?

2

1

I have installed (Or at least I think I ran an installer) tessearct-ocr on my my machine running 64-bit Windows 7. I am trying to interact with the program through cmd. to convert a .png image to text.

I have tried

tesseract filename.png filename

and got the error message cannot create output file.

Does anyone know of a good tutorial that describes the various commands? I can't seem to find beginner based information in the documentation.

I would describe myself as a beginner user who is keen to learn how to use cmd to run commands.

andrew

Posted 2011-01-19T00:50:33.533

Reputation: 847

DOS? For real? Or do you mean CMD? – Paused until further notice. – 2011-01-19T02:13:21.607

Oh sorry I do mean Cmd. – andrew – 2011-01-19T02:15:58.897

Answers

2

Was the command line formed right?

Looking at the tesseract-ocr documentation, this command is used on Windows:

tesseract <image> <outputbasename> [-l lang] [configs]

In command line syntax, the < and > characters mean that you need to specify the parameter,
the [ and ] characters indicate an optional parameter, the text in between describes the parameter.

So, it requires you to provide an image and an outputbasename:

  • image: Given this name, it should be a absolute or relative path to a supported file; from what I see JPEG, PNG and Tiff are supported, so filename.png here is fine.

  • outputbasename: Given this name, it's asking for a base which is most of the times a directory. But given the operation it would sound more logical to output text to a file than a directory unless you are going to output multiple files. So filename is fine if it's a base directory, but you could also try filename.txt just in case. Worst case it's going to create a directory called filename.txt! ;-)

From what I see, the commandline tesseract filename.png filename is just fine.

A site like Command Windows might be interesting if you want to learn more about the Command Prompt, from there you might me interested in Command Prompt References and Batch Script Tutorials.


Cool! But where does the error come from and how can I solve it?

Permission errors can be solved with Process Monitor, by filtering the statuses with ACCESS DENIED.

But, my guess here is that you can avoid that as I suspect an UAC error. Try running the command prompt as an administrator and try the command again in your user folder. If that doesn't work then try going trough Process Monitor and if that doesn't work then feel free to comment for more help... ;-)

Tamara Wijsman

Posted 2011-01-19T00:50:33.533

Reputation: 54 163

Thanks for the info about the meaning of <> and []. The weird thing now is that I am not getting any sort of message or any kind and I am not seing a file being created. – andrew – 2011-01-19T04:04:08.827

I don't even get an error when I mess up the path name of the source image. The only time a get an error is when I spell tesseract wrong. – andrew – 2011-01-19T04:05:43.520

What's interesting is that when I first started. If i typed tesseract then it told me about how it accepted arguments, now it doesn't do anything. – andrew – 2011-01-19T04:07:53.080

Do you get no error after using UAC? Have you tried specifying full paths for both parameters? Try to filter Process Monitor on Process Names that contain "tesseract" to see what files are being made and where. Messing up the source image giving no error is strange, was this the case when you spelled tesseract right? Seems to be badly written software if so... – Tamara Wijsman – 2011-01-19T04:10:32.390

Try downloading tesseract again, you might have overwritten the file. Does it give you completely nothing? The usual way to show information on Windows is with /? as a paremeter, but given that it is linux it could be -? or --help. – Tamara Wijsman – 2011-01-19T04:12:16.257

I tried running cmd as the administrator and it didn't help. What do you mean by try going through process monitor? – andrew – 2011-01-19T04:18:32.190

I had downloaded and installed it again and after that it entirely stopped working. Before when I just typed tesseract and nothing else it would tell me what the required info was. – andrew – 2011-01-19T04:20:01.827

I have even done tesseract a;skdfskk and that did not give me an error message. Only when I spell tesseract wrong does it think to give me an error message. Originally when I got the source file path wrong it gave me an error and then I fixed that and then it couldn't create out file – andrew – 2011-01-19T04:25:19.493

Ok i have completely removed the software. And then wrote tesseract in cmd which said that tesseract is not recognised as an external or internal command.So far so good. I then reinstall the programme from a fresh download from the site. Run cmd as me C:\User\Andy> tesseract D:\Documents\Web_Development\Sandbox\php\images\myimage.png D:\Documents\Web_Development\Sandbox\php\images\myimage this should create a text file containing the text of the image – andrew – 2011-01-19T04:39:20.377

It responded with 'Tesseract open source ocr engine with Leptonica' As far as I know, leptonica adds support for png's. It produced a text file but the results were horrible. The image it's self is a very clean image 300X17 pixels with some some sort of serif font – andrew – 2011-01-19T04:43:49.260

1Ok it's working. The problem is that I don't know why it was broken. Now I have to figure out how to improve the result which is terrible. Thanks for your help – andrew – 2011-01-19T04:48:07.523

Seems the executable was damaged somehow then, or there was something wrong in the previous location it was in. Anyhow, glad you got it fixed! The language and options you can specify can probably improve the results, good luck... :-) – Tamara Wijsman – 2011-01-19T14:23:42.187