Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Raspberry Pi - Camera Module
Identify the error in this code snippet:
from picamera2 import Picamera2
picam2 = Picamera2()
picam2.capture_file('photo.jpg')
picam2.start()
Astart() method does not exist in Picamera2
BPicamera2 class is not imported correctly
Ccapture_file() called before start(), causing an error
DFile name must be a full path, not just 'photo.jpg'
Step-by-Step Solution
Solution:
  1. Step 1: Check method call order

    capture_file() is called before starting the camera, which is incorrect.
  2. Step 2: Understand consequences

    This causes an error because the camera must be started before capturing.
  3. Final Answer:

    capture_file() called before start(), causing an error -> Option C
  4. Quick Check:

    Start camera before capture_file() to avoid errors [OK]
Quick Trick: Call start() before capture_file() to avoid errors [OK]
Common Mistakes:
MISTAKES
  • Calling capture_file() before start()
  • Assuming start() method is missing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes