Я попытался использовать пакет zbar и также просмотрел документацию.
У меня есть требование, когда у меня есть 3 штрих-кода на изображениях формата EAN13. (Код во всех трех штрих-кодах одинаков).
Когда я запустил приведенный ниже код на изображении, результат, который я получил, был только один штрих-код:
def detectBarCode(image):
# find the barcodes in the image and decode each of the barcodes
barcodes = pyzbar.decode(image)
# loop over the detected barcodes
for barcode in barcodes:
if barcode.type == 'EAN13':
# extract the bounding box location of the barcode and draw the
# bounding box surrounding the barcode on the image
(x, y, w, h) = barcode.rect
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
# the barcode data is a bytes object so if we want to draw it on
# our output image we need to convert it to a string first
barcodeData = barcode.data.decode("utf-8")
barcodeType = barcode.type
# draw the barcode data and barcode type on the image
text = "{} ({})".format(barcodeData, barcodeType)
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
0.5, (0, 0, 255), 2)
# print the barcode type and data to the terminal
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
В соответствии с моим вариантом использования, мне нужно вывести как 3 разатот же штрих-код.Я пытался настроить логику, но безуспешно.Пожалуйста, дайте мне знать, если у кого-нибудь есть предложение достичь желаемых результатов.