简体   繁体   中英

Pyzbar does not recognize CODE-128 barcode

I am trying to read text encoded in barcode - I am using pyzbar like this:

from pyzbar import pyzbar
import cv2

img = cv2.imread("example/path")
barcodes = pyzbar.decode(img, symbols=[pyzbar.ZBarSymbol.CODE128])

print(barcodes)

It normally works, but in the last batch of barcodes that I have received, pyzbar cannot read them - output of pyzbar.decode is [] . There is one example:

在此处输入图像描述

I have tried to put it into online decoder and it decodes it just fine (it also says the barcode type is CODE-128). Anybody knows, how can I read it in Python, please?

This picture shows a lot of ringing (contours reinforced in black). That could be the reason for the failure. Try blurring the image before a read. Binarization also works seamlessly.

在此处输入图像描述

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM