In trying to activate one of my 2 Logitek HD Pro C920 cameras in the tutorial for openCV, I run the python script as indicated, changing the device number to match what I see from running v4l2-ctl –list-devices in the virtual environment … here is what I see:
HD Pro Webcam C920 (usb-0000:01:00.0-1.1):
/dev/video4
/dev/video5
/dev/media6
In the script (opencv_test_usb_camera.py ) when I use 4 (i.e. video_capture = cv2.VideoCapture(4)), I get “Could not load the Qt platform plugin “xcb” in …(long directory)… even though it was found” … “failed to start because no Qt platform plugin could be initialized”
When I try 5 (i.e. video_capture = cv2.VideoCapture(5)), I get “can’t open camera by index”.
I have 2 of these USB cameras, and disconnected one and connected the other … different video IDs, but same result.
I am doing this inside the virtual environment. Any ideas of what I’m doing wrong? Thanks!
Hello again, I think you must be following this guide:
- Set Up USB Camera for OpenCV Projects with Raspberry Pi – https://randomnerdtutorials.com/set-up-usb-camera-opencv-raspberry-pi/
Are you running that command on a Remote Desktop Connection?
- Raspberry Pi: Set Up Remote Desktop Connection (RDP) – Windows PC
- Raspberry Pi: Set Up Remote Desktop Connection (RDP) – Mac OS
You must have the Raspberry Pi desktop open, if you are just using an SSH connection it will not work.
If you are already on the Raspberry Pi Desktop, try to install the following package:
sudo apt install libxcb-xinerama0
Then, run the script again (it should be with the (4) parameter, but if it doesn’t work try with (5) )
Let me know your results!
Hi Rui, Thank you for your quick response, and sorry for my delayed response (I still don’t understand the notification system — I was expecting an email stating I had a response, like some of the other areas I have interest in. After realizing I hadn’t heard for a while, I went in and checked and found your response of a week ago!).
So, I was connecting my RPi-4 to a monitor but only via the CLI (I was using libcamera-hello with an RPi Camera Model3 and it comes up fine in the CLI … bummer that the old Camera rev 1.3 and picamera is no longer available – been using it for years and picamera2 doesn’t have some nice features of picamera … so that’s why I’m exploring a USB camera via your tutorials; if you have any tutorials on picamer2, please let me know :–).
So I changed the RPi to boot into the desktop and then after activating the Virtual Env., I ran the python script, and it works :–) … well, it works on the attached monitor, but I’m having problems with the remote access.
As you instructed, I did the sudo apt install -y xrdp in the RPi, and found then ran the Remote Desktop Connection on my Windows PC, but it comes up with a blank blue screen … eventually stating “login successful, starting connection, … connection problem, giving up. Sorry to create yet another issue, but any idea what I’m doing wrong ?
I am using the Logitek webcam, not the Model3 RPi camera) …also I see the xrdp services running:
xrdp-sesman.service loaded active running xrdp session manager
xrdp.service loaded active running xrdp daemon
as for libxcb-xinerama0, it is “already newest version”, and “set to manually installed”.
You should have received an email, but it might have been lost in spam or it was grouped with another Forum response at the same time.
I’ll be publishing a guide with Picamera2 and I think it might work with that camera board version. It should be posted in 2-3 weeks.
Exactly, it must always be run with a virtual environment.
That’s really weird… This remote system always worked flawlessly for me… Are you in the same network with both devices, right?
Thanks Rui … yup … 2 weird things (notifications: I got some notifications e.g. some of yours and William Lucid’s, but not all; and the “blue screen” issue. :–(
Glad to hear you are going to address Pcamera2. 2 issues I have with it are that unlike Pcamera, it doesn’t allow rotations other than 180 (which is a problem for me since I have 2 cameras mounted at 90 degrees! I found a postprocessing routine, but haven’t implemented it), and getting the Model 3 to be in HD mode (I can get it to capture in HD with libcamera-hello, but that’s just a testing program – see below ). I really appreciate all the great stuff you guys generate !! … you really understand how to explain and teach :–)
works:
controls = {“Saturation”: 1, “LensPosition”: 1} # “LensPosition”: 0 –> infinity focus; 1 = 1 mtr; 5 = 1/5 = 20 cm
camera_config = picam2.create_still_configuration(transform=libcamera.Transform(hflip=1, vflip=1), controls=controls) # 180 deg rotation
picam2.configure(camera_config)
doesn’t work:
controls = {“Saturation”: 0, “LensPosition”: 1, “HdrMode”: controls.HdrModeEnum.MultiExposureUnmerged}
I haven’t experimented with that feature, so I can’t really help you on that subject at them moment. Picamera2 still definitely has a long way to go…
Good Morning Joe,
This article might help with your “Remotedesktop” blue screen:
Setup a Remote Desktop Connection for LAN / WAN Access
From the article:
“TIP: By default, Windows PC’s use the same port for RDC. So if you plan to use RDC on more than one computer within your LAN, you’ll also need to configure an internal port forwarding rule for each additional machine.”
Regards,
William
… tried that, but still “blue screen” … according to the link Rui sent, it says “when you are inside of your LAN, Remote Desktop Connection should perform optimally, allowing you to manage another computer without leaving your desk.”
The operative word is “should” ;–)
Thinking it might be a router issue, I setup my little soft AP (made thanks to Rui&Sara’s tutorials), and tried from my laptop, but same issue. SSH’ing into the RPi, and doing a sudo service xrdp status, I get the following as the 1st of many errors:
[ERROR] xrdp_mcs_send: xrdp_iso_send failed
The issue seems to be related to certificates, which are over my head (on trying the remote desktop from my PC, it says the identity of the RPi cannot be verified … it claims the name in the certificate of my RPi is arm-build.pitowers.org … and when I view this certificate (following a button to do so), it shows it’s valid in 2022/23. I followed the buttons to Install a new certificate on the remote machine, but after doing it, it comes back to the same screen saying identity can’t be verified, and “it may be unsafe to proceed” …. When I installed in on the “local machine”, the certificate shows being valid up to 2032, but comes back to the same screen saying identity can’t be verified, etc …. tried rebooting … no change.
Hi Joe,
Prompted ChatGPT about installing new certificate and the error message
Confirmed an expired certificate could cause a blue screen or other error messages.
Rasp Pi Forum –SSL Certificate Problem
William