mchehab / zbar

ZBar is an open source software suite for reading bar codes from various sources, including webcams. As its development stopped in 2012, I took the task of keeping it updated with the V4L2 API. This is the main repository for it. There's a clone at at LinuxTV.org, and another one at gitlab.
https://linuxtv.org/downloads/zbar/
GNU Lesser General Public License v2.1
970 stars 203 forks source link

QR code can't be detected #173

Open xuhdev opened 3 years ago

xuhdev commented 3 years ago

zbar reports WARNING: barcode data was not detected in some image(s) with the following image:

index

But I guess it should be a valid QR code?

wqh17101 commented 3 years ago

you should invert the color first in your preprocessing. and you can get the result. before invert i got nothing. i got below after i inverted the color decoded QRCODE symbol "https://developer.ibm.com/exchanges/data/all/airline/"

xuhdev commented 3 years ago

Hmm, thanks. Do you think the image was made improperly, or this is a bug in zbar for not being able to decode?

wqh17101 commented 3 years ago

As you can see after comparing the ori one with the inverted one, zbar can not found the bound of the ori one. image It is white.

image the normal one is black, and four Complete Square on the vertexes of the square is required which are used to locate the QRCODE

xuhdev commented 3 years ago

Got it. I tried to run zbar again with a black background this time:

zbarimg '-S*.enable' black-background.png

However, I still got the same error, for both of the following images:

black-background

Untitled

George-Miles commented 3 years ago

I just invert the image and it works fine.

Sent from my iPhone

On Apr 12, 2021, at 1:20 PM, Hong Xu @.***> wrote:

 Got it. I tried to run zbar again with a black background this time:

zbarimg '-S*.enable' black-background.png However, I still got the same error, for both of the following images:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wqh17101 commented 3 years ago

Got it. I tried to run zbar again with a black background this time:

So why did you think that inverting the img is the same as setting the background black ? here is some info for QR CODE , and you can read it to learn more about QRCODE. As i metioned before, inverting can work fine. image

As we all known that QR Code uses color to store info, and for the default , we can assume that black or other dark colors for '1' and white for '0'. So after inverted, it means different thing. For example , you will get 0 after inverting 1 not 1 itself.

In a word, your original picture uses the inverted setting which is made improperly. So we can not decode by default setting, and then trying to invert is a good idea.

wqh17101 commented 3 years ago

When the background is darker than the QR Code's foreground, it's called an inverted Code. These types of Codes typically have a dark background such as black, navy or dark grey. While a few scanners can read an inverted Code, some apps are not able to scan them.

xuhdev commented 3 years ago

I tried the black-backgrounded version because you said the reason it could not be recognized is

As you can see after comparing the ori one with the inverted one, zbar can not found the bound of the ori one.

It's just good to be sure that zbar can't recognize inverted QR code. Consider this as a feature request to recognize an inverted QR code and feel free to close if this is out of scope :)

diegodorado commented 2 months ago

I run into this issue, and appearently there is support for inverted images now, only not enabled by default (not sure why)

run it with zbarimg -Stest-inverted