Hi all,
I am fairly new to the Raspberry Pi world and need some help getting my camera module up and running.
So I use a Raspberry Pi 5 with Raspberry Pi OS 12 installed and have a Raspberry Pi camera module 2 connected to it. The Raspberry Pi is controlled via Windows Remote Desktop Connection on a laptop with Windows 11.
Now I want to start the camera preview, and I have already learned that I should use the Qt preview for the remote connection. So far so good, and when I type “rpicam-hello --qt-preview” in the command window, I can see a preview without a problem. But I want to control the camera with a Python script, and the code I use is as follows:
from picamera2 import Picamera2, Preview
cam = Picamera2()
cam.start_preview(Preview.QT)
Unfortunately, the preview window only opens for a fraction of a second, and then the program ends. Below I attached the output – maybe it will be helpful.
Does anybody know why the Python code is not working properly? What am I doing wrong?
(I already read that there are other ways to start a preview within a Python script, using e.g. pygame. But I really like the code above, as it is simple and easy to understand…)
Thank you so much for your support!
[0:35:15.637703093] [3119] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[0:35:15.651293471] [3141] INFO RPI pisp.cpp:662 libpisp version v1.0.4 6e3a53d137f4 14-02-2024 (14:00:12)
[0:35:15.660914610] [3141] INFO RPI pisp.cpp:1121 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/imx219@10 to CFE device /dev/media2 and ISP device /dev/media0 using PiSP variant BCM2712_C0
[0:35:15.662230813] [3119] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[0:35:15.676380016] [3144] INFO RPI pisp.cpp:662 libpisp version v1.0.4 6e3a53d137f4 14-02-2024 (14:00:12)
[0:35:15.688955186] [3144] INFO RPI pisp.cpp:1121 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/imx219@10 to CFE device /dev/media2 and ISP device /dev/media0 using PiSP variant BCM2712_C0
------------------
(program exited with code: 0)
Press return to continue
I am fairly new to the Raspberry Pi world and need some help getting my camera module up and running.
So I use a Raspberry Pi 5 with Raspberry Pi OS 12 installed and have a Raspberry Pi camera module 2 connected to it. The Raspberry Pi is controlled via Windows Remote Desktop Connection on a laptop with Windows 11.
Now I want to start the camera preview, and I have already learned that I should use the Qt preview for the remote connection. So far so good, and when I type “rpicam-hello --qt-preview” in the command window, I can see a preview without a problem. But I want to control the camera with a Python script, and the code I use is as follows:
from picamera2 import Picamera2, Preview
cam = Picamera2()
cam.start_preview(Preview.QT)
Unfortunately, the preview window only opens for a fraction of a second, and then the program ends. Below I attached the output – maybe it will be helpful.
Does anybody know why the Python code is not working properly? What am I doing wrong?
(I already read that there are other ways to start a preview within a Python script, using e.g. pygame. But I really like the code above, as it is simple and easy to understand…)
Thank you so much for your support!
[0:35:15.637703093] [3119] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[0:35:15.651293471] [3141] INFO RPI pisp.cpp:662 libpisp version v1.0.4 6e3a53d137f4 14-02-2024 (14:00:12)
[0:35:15.660914610] [3141] INFO RPI pisp.cpp:1121 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/imx219@10 to CFE device /dev/media2 and ISP device /dev/media0 using PiSP variant BCM2712_C0
[0:35:15.662230813] [3119] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[0:35:15.676380016] [3144] INFO RPI pisp.cpp:662 libpisp version v1.0.4 6e3a53d137f4 14-02-2024 (14:00:12)
[0:35:15.688955186] [3144] INFO RPI pisp.cpp:1121 Registered camera /base/axi/pcie@120000/rp1/i2c@88000/imx219@10 to CFE device /dev/media2 and ISP device /dev/media0 using PiSP variant BCM2712_C0
------------------
(program exited with code: 0)
Press return to continue
Statistics: Posted by DanGan — Mon Mar 11, 2024 6:44 pm