rmtheis / tess-two

Fork of Tesseract Tools for Android
Apache License 2.0
3.76k stars 1.38k forks source link

Which place is appropriate for initializing TessBaseAPI #176

Closed krupalshah closed 7 years ago

krupalshah commented 7 years ago

Hi, I am confused about placing TessBaseAPI.init(...). Does the engine learn about characters it read after initialization? Then, I would like to put initialization part in Application class and access using application class singleton. If not, I would like to avoid leaks as nullifying instances after work is done. Can you please advice on this?

rmtheis commented 7 years ago

Does the engine learn about characters it read after initialization?

It depends what you mean by "learn about". No changes are made to the training data based on your OCR results, so no learning takes place in a "training" sense.

I would like to put initialization part in Application class and access using application class singleton. If not, I would like to avoid leaks as nullifying instances after work is done. Can you please advice on this?

You can avoid a memory leak by calling end() on your TessBaseAPI instance when you're done with it. I'd suggest calling this in your Activity's onDestroy() method to ensure that it gets called.