gali8 / Tesseract-OCR-iOS

Tesseract OCR iOS is a Framework for iOS7+, compiled also for armv7s and arm64.
http://www.nexor.it
MIT License
4.21k stars 948 forks source link

Works well with saved photo but not with camera #339

Open Siggs2000 opened 7 years ago

Siggs2000 commented 7 years ago

Running into an odd issue when using this library reading a printed nutrition facts label (for testing purposes)

It works great with a saved image of one but when I try to snap one with the device camera, I get output that looks like this:

" \134n\134n \134n\134n               \134n                         \134n\134n                       \134n\134n          \134n\134n                                                                 \134n\134n                                \134n\134n \134n\134n             \134n\134n                              \134n\134n \134n\134n                \134n                    \134n             \134n                 \134n             \134n                           \134n                   \134n          \134n        \134n \134n                            \134n            \134n\134n \134n\134n \134n\134n                          \134n\134n                                   \134n                                    \134n                                     \134n\134n                                \134n                             \134n\134n                   \134n                  \134n                        \134n                             \134n                     \134n         \134n\134n   \134n\134n \134n\134n \134n\134n"

I'm being careful to not have glare, frame it properly, etc.

I'm using eng language, G8OCREngineModeTesseractCubeCombined for engine mode and G8PageSegmentationModeAutoOSD for page segment mode (those are the settings that gave me the best results for a saved image of a nutrition facts label. I'm using this type of label for now because I figured it would be good for testing since they are all the same, have normal fonts and are black and white.

pod version 4.0.0 iOS version 10.3.3

Note: I looked into the possibility that the image was rotated and so I also implemented some code to check for that and rotate properly using this stackoverflow solution: https://stackoverflow.com/a/32476637/1634565

Any help is greatly appreciated!

abheek96 commented 7 years ago

I would really like to know that how to input the image directly from the camera. I'm only able to process the images saved in the library. What functions did you use? Would really appreciate your help on this!