python

しょっちゅう忘れることを書いておく。

33

745 views

# coding:UTF-8

from pyzbar.pyzbar import decode
from PIL import Image
import cv2

image = "sample2.JPG"

result_img = cv2.imread(image)
records = decode(Image.open(image))

for record in records:
    print(record[0].decode('utf-8', 'ignore'))
    left = int(record[2][0])
    top = int(record[2][1])
    width = int(record[2][2])
    height = int(record[2][3])
    print(left, top, width, height)
    cv2.rectangle(result_img, (left, top), (left+width, top+height), (0, 0, 255))

cv2.imshow('test', result_img)
cv2.waitKey(0)

Page 15 of 56.

前のページ 次のページ



[添付ファイル]


お問い合わせ

プロフィール

マッスル

自己紹介

本サイトの作成者。
趣味:プログラム/水耕栽培/仮想通貨/激辛好き
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
仮想通貨はNEMが好き。
水耕栽培は激辛好きが高じて、キャロライナ・リーパーの栽培にチャレンジ中。

サイト/ブログ

https://www.osumoi-stdio.com/pyarticle/

ツイッター

@darkimpact0626