amazon-archives / tesserpy

ARCHIVED: A Python API for Tesseract
https://github.com/rigorgt/tesserpy
GNU Lesser General Public License v2.1
20 stars 10 forks source link

Is it possible to pass 'init only' params to the constructor? #5

Closed mollierobbert closed 9 years ago

mollierobbert commented 9 years ago

Some parameters are 'init only' (see ControlParams). Is it possible to pass those to the constructor, like in the C API?

squidpickles commented 9 years ago

At the moment, no. The only parameters passed to Init are datapath, language, and oem. The longer form of Init supports (what would in Python be) a list of paths to config files, and a dict of key-value pairs to override the config files.

I'll add this as a feature request.

mollierobbert commented 9 years ago

Great, thank you. I'd be happy to help if you can give me some pointers.

squidpickles commented 9 years ago

It's not too bad... I should find some time to do this in the next day or two (I hope!), but should you be interested:

Basically, these lines of tesserpy.cpp build up parameters to pass to TessBaseApi::Init. It would just take adding a couple of items to the kwargs list, then building up char* arrays, and key/value vectors from passed in list and dict. Conversion shouldn't be too hard, and the lifetime of the values should (I need to confirm in Tesseract's source) only need to be as long as the Init call itself.

If you need this right away and want to do the work yourself, let me know, otherwise I'll get started on it soon.

I'm (perversely) glad to see you running into the limits of this little toy, and slowly pushing them a little further out...

mollierobbert commented 9 years ago

Glad to hear it's not too much trouble. I won't have time for it until Monday, so I won't be of much help if you're planning to add this over the weekend (that's really quick!).