Challenge - 5 Problems
Raspberry Pi Camera Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Raspberry Pi camera capture code?
Consider the following Python code using the picamera library to capture an image. What will be the output after running this code?
Raspberry Pi
import picamera with picamera.PiCamera() as camera: camera.resolution = (1024, 768) camera.capture('image.jpg') print('Image captured with resolution:', camera.resolution)
Attempts:
2 left
💡 Hint
Check the resolution set before capturing the image.
✗ Incorrect
The code sets the camera resolution to (1024, 768) before capturing the image. The print statement outputs this resolution.
🧠 Conceptual
intermediate1:30remaining
Which option correctly explains the role of 'camera.capture()' in Raspberry Pi image capture?
In Raspberry Pi Python code using the picamera library, what does the method 'camera.capture()' do?
Attempts:
2 left
💡 Hint
Think about what 'capture' means in photography.
✗ Incorrect
'camera.capture()' takes a still photo and saves it to the specified file.
🔧 Debug
advanced2:30remaining
What error does this Raspberry Pi camera code raise?
Analyze the following code snippet. What error will it raise when executed on a Raspberry Pi with a camera module?
import picamera
camera = picamera.PiCamera()
camera.capture('photo.jpg')
camera.close()
camera.capture('photo2.jpg')
Raspberry Pi
import picamera camera = picamera.PiCamera() camera.capture('photo.jpg') camera.close() camera.capture('photo2.jpg')
Attempts:
2 left
💡 Hint
Consider what happens after calling camera.close()
✗ Incorrect
After closing the camera, trying to capture another image raises a RuntimeError because the camera resource is released.
📝 Syntax
advanced2:00remaining
Which option contains the correct syntax to capture an image with a delay using picamera?
You want to capture an image after a 5-second delay to allow the camera to adjust. Which code snippet is syntactically correct?
Attempts:
2 left
💡 Hint
Check for missing colons and order of operations.
✗ Incorrect
Option A correctly uses a with statement with colon, sleeps before capture, and captures the image properly.
🚀 Application
expert3:00remaining
How many images are saved after running this Raspberry Pi camera script?
Given the following Python script using picamera, how many image files will be saved on disk after execution?
import picamera
with picamera.PiCamera() as camera:
camera.resolution = (640, 480)
for i in range(3):
camera.capture(f'image_{i}.jpg')
camera.capture('final.jpg')
Raspberry Pi
import picamera with picamera.PiCamera() as camera: camera.resolution = (640, 480) for i in range(3): camera.capture(f'image_{i}.jpg') camera.capture('final.jpg')
Attempts:
2 left
💡 Hint
Count all capture calls in the code.
✗ Incorrect
The loop captures 3 images named image_0.jpg, image_1.jpg, image_2.jpg, plus one final capture named final.jpg, totaling 4 images.
