Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Empty image detection #64

Closed
lubo opened this issue Apr 16, 2017 · 7 comments
Closed

Empty image detection #64

lubo opened this issue Apr 16, 2017 · 7 comments

Comments

@lubo
Copy link

lubo commented Apr 16, 2017

Currently, it seems like the only way to detect whether an image is empty or not is using image_to_string(...). However, this method is very inefficient on images containing thousands of characters or more. If it's possible, I'd be great to implement something like is_image_empty(image), which would return a bool describing, whether the image is empty or not.

@jflesch
Copy link
Member

jflesch commented Apr 17, 2017

Please keep in mind that Pyocr is just a wrapper for Tesseract and Cuneiform. Therefore, does Tesseract or Cuneiform provide such functionality ?

@lubo
Copy link
Author

lubo commented Apr 17, 2017

That's why I stated If it's possible. I don't know if they provide API for that, but Tesseract prints to stdout Emtpy page!!! when it detects one. I thought you could provide more info on that one.

@jflesch
Copy link
Member

jflesch commented Apr 17, 2017

I can't find any option related to what you are looking for. I doubt there is one. I think being able to tell there is no text implies that you must try to find text, which in turn implies running the full OCR process to be perfectly sure.

I'm going to close this ticket. Feel free to comment here if you find such option, and I will reopen this ticket.

@jflesch jflesch closed this as completed Apr 17, 2017
@jflesch
Copy link
Member

jflesch commented Apr 17, 2017

BTW, are you looking to know if there is no text at all (only images, photos, etc), or if the input image is actually empty ?
Both things are not the same at all. If you want to know whether there is text or not, using Tesseract makes senses. However, if you want to know if an image is entirely empty, you should look at image processing libraries (OpenCV, libpillowfight, etc).

@lubo
Copy link
Author

lubo commented Apr 17, 2017

I want to know if there is a text or not. If I wanted to know, whether an image is entirely empty, I would go for Google Cloud Vision for sure. Also, Google Cloud Vision can do something close to what I want, and it's that you can limit number of detected text annotations. But it still returns way more data than I need and it's kind of expensive for just saying whether there is a text or not.

@lubo
Copy link
Author

lubo commented Apr 17, 2017

I've been playing around with Tesseract CLI and just found out it returns Script and Script confidence in OSD-only PSM. Using this feature seems to be ~36x faster than using mode 3 on a image with ~12,000 characters (2.4 instead of 88.3 seconds). I see that these values are omitted in detect_os(handle).

@jflesch
Copy link
Member

jflesch commented Apr 17, 2017

Oh good point, I forgot about this, my bad :
https://github.com/openpaperwork/pyocr/#orientation-detection << "detect_orientation() MAY raise an exception if there is no text detected in the image." << this part actually concern Tesseract. Tesseract (3.03) does return an error when there is no text.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants