Bird
0
0
Raspberry Piprogramming~10 mins

Why camera enables vision-based projects in Raspberry Pi - Test Your Understanding

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

Complete the code to capture an image using the Raspberry Pi camera.

Raspberry Pi
import picamera
with picamera.PiCamera() as camera:
    camera.[1]('image.jpg')
Drag options to blanks, or click blank then click option'
Aopen
Bstart
Crecord
Dcapture
Attempts:
3 left
💡 Hint
Common Mistakes
Using start() instead of capture()
Using open() which is not a camera method
2fill in blank
medium

Complete the code to set the resolution of the camera before capturing an image.

Raspberry Pi
import picamera
with picamera.PiCamera() as camera:
    camera.[1] = (640, 480)
    camera.capture('image.jpg')
Drag options to blanks, or click blank then click option'
Aformat
Bsize
Cresolution
Dquality
Attempts:
3 left
💡 Hint
Common Mistakes
Using size instead of resolution
Using format which is for file type
3fill in blank
hard

Fix the error in the code to correctly initialize the camera and capture an image.

Raspberry Pi
import picamera
camera = picamera.PiCamera()
camera.[1]('photo.jpg')
Drag options to blanks, or click blank then click option'
Acapture
Bcapture()
Ccapture('photo.jpg')
Attempts:
3 left
💡 Hint
Common Mistakes
Not calling PiCamera() as a function
Calling capture without parentheses
4fill in blank
hard

Fill both blanks to create a dictionary of image filenames with their resolutions, filtering only images with width greater than 800.

Raspberry Pi
images = {'img1.jpg': (1024, 768), 'img2.jpg': (640, 480), 'img3.jpg': (1280, 720)}
filtered = {filename: res for filename, res in images.items() if res[0] [1] [2]
Drag options to blanks, or click blank then click option'
A>
B<
C800
D1024
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >
Using 1024 instead of 800
5fill in blank
hard

Fill all three blanks to create a dictionary of images with width greater than 700 and height less than 800.

Raspberry Pi
images = {'a.jpg': (800, 600), 'b.jpg': (640, 480), 'c.jpg': (1024, 900)}
filtered = {filename: res for filename, res in images.items() if res[0] [1] [2] and res[1] [3] 800}
Drag options to blanks, or click blank then click option'
A>
B700
C<
D600
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up > and <
Using wrong threshold numbers