Bird
0
0
Raspberry Piprogramming~20 mins

Raspberry Pi Camera setup - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Raspberry Pi Camera Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Raspberry Pi camera capture code?

Consider this Python code snippet using the picamera library to capture an image. What will it print?

Raspberry Pi
import picamera
from time import sleep

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.start_preview()
    sleep(2)
    camera.capture('/home/pi/image.jpg')
    print('Image captured at resolution:', camera.resolution)
AImage captured at resolution: (640, 480)
BImage captured at resolution: (1920, 1080)
CError: PiCamera not found
DImage captured at resolution: (320, 240)
Attempts:
2 left
💡 Hint

Check the resolution set before capture.

🧠 Conceptual
intermediate
1:30remaining
Which command enables the Raspberry Pi camera interface?

To use the Raspberry Pi camera module, you must enable the camera interface. Which command correctly enables it?

Asudo systemctl start camera.service
Bsudo apt-get install camera-enable
Csudo raspi-config and enable Camera under Interface Options
Dsudo modprobe bcm2835-v4l2
Attempts:
2 left
💡 Hint

Think about the Raspberry Pi configuration tool.

🔧 Debug
advanced
2:00remaining
Why does this Raspberry Pi camera capture code raise an error?

Look at this code snippet. It raises an error when run. What is the cause?

Raspberry Pi
import picamera

camera = picamera.PiCamera()
camera.capture('test.jpg')
camera.close()
AThe camera needs to be started with start_preview() before capture()
BThe capture() method requires a delay before calling
CThe file path 'test.jpg' is invalid without full path
DThe camera object must be used inside a with statement or closed properly
Attempts:
2 left
💡 Hint

Consider resource management and proper closing of the camera.

📝 Syntax
advanced
2:00remaining
Which option correctly sets the camera resolution and captures an image?

Choose the code snippet that correctly sets the resolution to 1280x720 and captures an image named 'photo.jpg'.

A
with picamera.PiCamera() as camera:
    camera.resolution = (1280, 720)
    camera.capture('photo.jpg')
B
with picamera.PiCamera() as camera:
    camera.set_resolution(1280, 720)
    camera.capture('photo.jpg')
C
camera = picamera.PiCamera()
camera.resolution = 1280, 720
camera.capture('photo.jpg')
camera.close()
D
with picamera.PiCamera() as camera:
    camera.resolution = [1280, 720]
    camera.capture('photo.jpg')
Attempts:
2 left
💡 Hint

Check the correct attribute name and data type for resolution.

🚀 Application
expert
2:30remaining
How many images are saved after running this Raspberry Pi camera burst capture code?

This code captures 5 images in a burst with 1 second delay between each. How many image files will be saved?

Raspberry Pi
import picamera
from time import sleep

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    for i in range(5):
        camera.capture(f'/home/pi/image_{i}.jpg')
        sleep(1)
A1
B5
C0
D6
Attempts:
2 left
💡 Hint

Count how many times the capture method is called in the loop.