Bird
0
0
Raspberry Piprogramming~10 mins

picamera2 library basics 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 Picamera2 class from the picamera2 library.

Raspberry Pi
from picamera2 import [1]
Drag options to blanks, or click blank then click option'
APicamera2
BCamera
CCamera2
DPiCamera
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'PiCamera' which is from the older picamera library.
Using 'Camera' or 'Camera2' which are not valid class names.
2fill in blank
medium

Complete the code to create a Picamera2 object and start the camera preview.

Raspberry Pi
picam2 = Picamera2()
picam2.[1]()
Drag options to blanks, or click blank then click option'
Apreview
Bstart
Cstart_preview
Dopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using start_preview() which is not a method in picamera2.
Using preview() which does not exist.
3fill in blank
hard

Fix the error in the code to capture an image and save it to a file.

Raspberry Pi
picam2 = Picamera2()
picam2.start()
image = picam2.[1]()
image.save('test.jpg')
Drag options to blanks, or click blank then click option'
Acapture_image
Bget_image
Ctake_picture
Dcapture
Attempts:
3 left
💡 Hint
Common Mistakes
Using capture_image() which does not exist.
Using get_image() which is not the correct method.
4fill in blank
hard

Fill both blanks to create a preview window and wait for 5 seconds before stopping the camera.

Raspberry Pi
import time
picam2 = Picamera2()
picam2.[1]()
time.[2](5)
picam2.stop()
Drag options to blanks, or click blank then click option'
Astart
Bsleep
Cwait
Dpause
Attempts:
3 left
💡 Hint
Common Mistakes
Using wait() or pause() which are not functions in the time module.
Using stop() before waiting.
5fill in blank
hard

Fill all three blanks to configure the camera for a 640x480 preview and capture an image.

Raspberry Pi
picam2 = Picamera2()
config = picam2.create_preview_configuration({'size': ([1], [2])})
picam2.configure(config)
picam2.start()
image = picam2.[3]()
Drag options to blanks, or click blank then click option'
A640
B480
Ccapture
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height values.
Using start() instead of capture() to get an image.