I have recently purchased the Raspberry pi 5 and Raspberry pi AI camera as an absolute beginner. I have gone through all the demos in the terminal and it is working fine, but when I try to implamet it into my projects using Thonny, it doesn't seem to work. The camera preview never comes up and error messages pop up.
When I run this code:
from picamera2 import Picamera2
import time
# Initialize the camera
picam2 = Picamera2()
# Start preview (ensure the camera is available)
picam2.start_preview()
print("Camera preview started!")
# Allow some time for the preview to show up
time.sleep(5)
# Stop the preview after some time
picam2.stop_preview()
print("Preview stopped.")
This is the output:
Made X/EGL preview window
[1:12:28.402369763] [3916] INFO Camera camera.cpp:1003 Pipeline handler in use by another process
ERROR: *** failed to acquire camera /base/axi/pcie@120000/rp1/i2c@80000/imx500@1a ***