Bird
0
0
Raspberry Piprogramming~10 mins

QR code reading in Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library needed for QR code reading.

Raspberry Pi
import [1]
Drag options to blanks, or click blank then click option'
Atime
Bnumpy
Ccv2
Dos
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like numpy or time.
Forgetting to import the QR code reading library.
2fill in blank
medium

Complete the code to initialize the QR code detector.

Raspberry Pi
detector = cv2.[1]()
Drag options to blanks, or click blank then click option'
Aimread
BQRCodeDetector
CCascadeClassifier
DVideoCapture
Attempts:
3 left
💡 Hint
Common Mistakes
Using VideoCapture which is for camera input.
Using CascadeClassifier which is for face/object detection.
3fill in blank
hard

Fix the error in the code to read a frame from the camera.

Raspberry Pi
ret, frame = cap.[1]()
Drag options to blanks, or click blank then click option'
Aread
Bcapture
Cget
Dgrab
Attempts:
3 left
💡 Hint
Common Mistakes
Using capture() which does not exist.
Using get() which retrieves properties, not frames.
4fill in blank
hard

Fill both blanks to decode the QR code from the frame.

Raspberry Pi
data, bbox, _ = detector.[1](frame)
if data [2] "":
    print(f"QR Code data: {data}")
Drag options to blanks, or click blank then click option'
AdetectAndDecode
B!=
C==
DdetectMultiScale
Attempts:
3 left
💡 Hint
Common Mistakes
Using detectMultiScale which is for object detection.
Checking if data equals empty string instead of not equals.
5fill in blank
hard

Fill all three blanks to capture video, detect QR codes, and exit on pressing 'q'.

Raspberry Pi
cap = cv2.[1](0)
while True:
    ret, frame = cap.[2]()
    data, bbox, _ = detector.[3](frame)
    if data != "":
        print(f"QR Code: {data}")
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
Drag options to blanks, or click blank then click option'
AVideoCapture
Bread
CdetectAndDecode
Dimread
Attempts:
3 left
💡 Hint
Common Mistakes
Using imread which reads images from files, not camera.
Not releasing the camera or destroying windows.