0

Задача стоит найти qr code гдето в левом углу файла.

from pyzbar.pyzbar import decode
from PIL import Image #pip install Pillow 

d = decode(Image.open('photo.jpg'))

print(d[0].data.decode('ascii'))

Возникает ошибка: IndexError: list index out of range. Как исправить. Может есть другие готовые решения?

1 ответ 1

0

Решил проблему обрезанием картинки до нужной области.

from pyzbar.pyzbar import decode
from PIL import Image #pip install Pillow
import os

img = Image.open('001.jpg')
area = (150, 1680, 410, 2000)
cropped_img = img.crop(area)
cropped_img.save('002.jpg')

d = decode(Image.open('002.jpg'))

print(d[0].data.decode('ascii'))

os.remove("002.jpg")

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.