adaptech-cz / Tesseract4Android

Fork of tess-two rewritten from scratch to support latest version of Tesseract OCR.
Apache License 2.0
718 stars 110 forks source link

Which method returns text orientation? #44

Open atgorvi opened 2 years ago

atgorvi commented 2 years ago

There is mode "Orientation and script detection only. PSM_OSD_ONLY" in TessBaseAPI, which method returns text orientation OSD_Issue ?

Robyer commented 2 years ago

I don't think result of this mode (as many other things) is exposed in the Java API. You may need to see how it's accessed in the C++ code and expose it for yourself by modifying the library.

So, cpp files in tesseract4android/src/main/cpp/tesseract and java files in tesseract4android/src/main/java/com/googlecode/tesseract/android must be modified/added.

chilex111 commented 1 year ago

Hi, I want to pass in an image captured from the camera of the device, but when I do that, I don't get the text at all, the only time I get the right text is if I save the image in the asset folder or I pick it from the gallery. Please how can I get this to work for the camera photo?

Robyer commented 1 year ago

@chilex111 Hi, you are writing comment to completely unrelated issue. Also, for such questions you should use StackOverflow and not Github issues.

I will just say here that generally you should convert the image you get from Camera into standard Bitmap and then give that to Tesseract by calling setImage(bitmap). There is no direct support for giving the Image object which you receive from Camera2 API directly to Tesseract.

john-khgoh commented 2 weeks ago

@Robyer I believe this feature has now been added to tesseract-ocr: https://github.com/tesseract-ocr/tesseract/pull/4070

Robyer commented 2 weeks ago

@john-khgoh That is separate feature. There is no issue in Tesseract itself, current version of this (Tesseract4Android) library just doesn't expose the full Tesseract's C/C++ API to Java. It's because I directly used the same Java API from tess-two project and kept it (mostly) as is.

It's possible to expose more methods/features from Tesseract, or even create a completely new API at Java side, but I just didn't have the need for that on my own.