StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
import cv2 from pyzbar.pyzbar import decode # Initialize the video capture object cap = cv2.VideoCapture(0) if not cap.isOpened(): print("Failed to open the camera.") exit() while True: # Read a frame from the camera ret, frame = cap.read() if not ret: print("Failed to capture a frame.") break # Decode QR codes in the frame qr_codes = decode(frame) # Process each detected QR code for qr_code in qr_codes: # Extract the decoded data data = qr_code.data.decode('utf-8') # Draw a bounding box around the QR code x, y, w, h = qr_code.rect cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2) # Display the decoded data cv2.putText(frame, data, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2) # Print the decoded data print("QR Code:", data) # Release the video capture object and close the windows cap.release() cv2.destroyAllWindows() exit() # Display the frame cv2.imshow('QR Code Reader', frame) # Check for key press to exit if cv2.waitKey(1) & 0xFF == ord('q'): break # Release the video capture object and close the windows cap.release() cv2.destroyAllWindows()
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Your account is signed in on the device(s) below. Sign out of at least one of them to continue signing in on this device.
Your account is signed in on the device(s) below. Sign out directly on one of those devices, or wait until the sign-in again time shown below.
If you cant access those devices, please contact the administrator to sign them out for you.
Input your email to receive reset password link, or if you remember your password, you can click