Answer the question
In order to leave comments, you need to log in
Why does WARN crash when working with a camera in OpenCV, Python?
There is a code that scans a QR code:
import cv2
import numpy as np
import pyzbar.pyzbar as pyzbar
cap = cv2.VideoCapture(0)
while True:
_, frame = cap.read()
decodedObjects = pyzbar.decode(frame)
for obj in decodedObjects:
print("Data", obj.data)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1)
if key == 27:
break
print("Data", obj.data)
return obj.data
Answer the question
In order to leave comments, you need to log in
1) So you use return outside of the function? And what are you waiting for, except for an error?
2) Check the success of the returned result, and only then process the frame:
ret, frame = cap.read()
if ret:
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question