Bird
0
0
Raspberry Piprogramming~20 mins

Capturing still images in Raspberry Pi - 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 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)
ASyntaxError: invalid syntax
BImage captured with resolution: (640, 480)
CImage captured with resolution: (1024, 768)
DRuntimeError: camera not found
Attempts:
2 left
💡 Hint
Check the resolution set before capturing the image.
🧠 Conceptual
intermediate
1: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?
AIt captures a still image and saves it to a file.
BIt starts the camera preview on the screen.
CIt records a video stream to a file.
DIt sets the camera resolution.
Attempts:
2 left
💡 Hint
Think about what 'capture' means in photography.
🔧 Debug
advanced
2: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')
ASyntaxError: invalid syntax
BFileNotFoundError: photo2.jpg not found
CNo error, both images are captured successfully
DRuntimeError: Camera has been closed
Attempts:
2 left
💡 Hint
Consider what happens after calling camera.close()
📝 Syntax
advanced
2: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?
A
import picamera
import time
with picamera.PiCamera() as camera:
    time.sleep(5)
    camera.capture('delayed.jpg')
B
import picamera
import time
with picamera.PiCamera() as camera
    time.sleep(5)
    camera.capture('delayed.jpg')
C
import picamera
import time
camera = picamera.PiCamera()
time.sleep(5)
camera.capture('delayed.jpg')
camera.close()
D
import picamera
import time
with picamera.PiCamera() as camera:
    camera.capture('delayed.jpg')
    time.sleep(5)
Attempts:
2 left
💡 Hint
Check for missing colons and order of operations.
🚀 Application
expert
3: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')
A3
B4
C1
D0
Attempts:
2 left
💡 Hint
Count all capture calls in the code.