Complete the code to import the Picamera2 class from the picamera2 library.
from picamera2 import [1]
The Picamera2 class is the main class to control the camera in the picamera2 library.
Complete the code to create a Picamera2 object and start the camera preview.
picam2 = Picamera2()
picam2.[1]()start_preview() which is not a method in picamera2.preview() which does not exist.The start() method initializes and starts the camera capture.
Fix the error in the code to capture an image and save it to a file.
picam2 = Picamera2() picam2.start() image = picam2.[1]() image.save('test.jpg')
capture_image() which does not exist.get_image() which is not the correct method.The correct method to capture an image is capture(). It returns an image object that can be saved.
Fill both blanks to create a preview window and wait for 5 seconds before stopping the camera.
import time picam2 = Picamera2() picam2.[1]() time.[2](5) picam2.stop()
wait() or pause() which are not functions in the time module.stop() before waiting.Use start() to begin the camera and time.sleep(5) to wait 5 seconds.
Fill all three blanks to configure the camera for a 640x480 preview and capture an image.
picam2 = Picamera2()
config = picam2.create_preview_configuration({'size': ([1], [2])})
picam2.configure(config)
picam2.start()
image = picam2.[3]()start() instead of capture() to get an image.The preview size is set to 640x480. The method to capture an image is capture().
