メンターの報酬に合わせる
1.件名:PYTHONで内臓WebカメラからQRコードの読み取りができません
2.準備:インストールしたプログラム
Opencv-python,pyqrcode,pypng,python_barcode,pyzbar
※Microsoft storeからpython3.8をダウンロード
※いずれも pip showでインストール情報を確認
3.使用環境
OS:Windoiws10
PC:Sureface Go2
4.状況:
①ソースコード1(下記添付データご参照ください)を実行にてWebカメラ起動を確認できました
②ソースコード2(下記添付データご参照ください)を実行してもコマンドプロンプトが一瞬表示のみで強制終了します
③ソースコード2実行時のコマンドプロンプトを確認結果下記エラーを確認しました
FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
④環境変数のpath設定にpyzbarフォルダを追加しました
⑤ソースコード2を再度実行しても③のエラーが発生します
⑥pyzbarフォルダ内にあるlibiconv.dllをsystem32へコピーしました
⑦ソースコード2を再度実行すると下記エラー発生します
FileNotFoundError: Could not find module 'libzbar-64.dll' (or one of its dependencies). Try using the full path with constructor syntax.
⑧pyzbarフォルダ内にあるlibzbar-64.dllをsystem32へコピーしました
⑨ソースコード2を再度実行しても⑦のエラーが発生します
⑩ここで行き詰りました
以上、大変申し訳ございませんがご教授お願い致します
(添付データ)
①ソースコード1
import cv2
cap = cv2.VideoCapture(1)
while True:
# 1フレームずつ取得する。
ret, frame = cap.read()
#フレームが取得できなかった場合は、画面を閉じる
if not ret:
break
# ウィンドウに出力
cv2.imshow("Frame", frame)
key = cv2.waitKey(1)
# Escキーを入力されたら画面を閉じる
if key == 27:
break
cap.release()
cv2.destroyAllWindows()
②ソースコード2
from pyzbar.pyzbar import decode
import cv2
cap = cv2.VideoCapture(1)
font = cv2.FONT_HERSHEY_SIMPLEX
while cap.isOpened():
ret,frame = cap.read()
if ret == True:
d = decode(frame)
if d:
frame = cv2.putText(frame,d[0].data.decode('utf-8'),(10,50),font,1,(0,255,255),2,cv2.LINE_AA)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
③pyzbarのインストール情報
Name: pyzbar
Version: 0.1.8
Summary: Read one-dimensional barcodes and QR codes from Python 2 and 3.
Home-page: https://github.com/NaturalHistoryMuseum/pyzbar/
Author: Lawrence Hudson
Author-email: quicklizard@googlemail.com
License: MIT
Location: c:\users\h1989\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages
Requires:
Required-by:
既読0