Trying to connect RasberryPi - imshow() failed

Hello everyone,

We are currently working on our PiCarX robot kit with the Raspberry Pi and encountered a few challenges during setup. Initially, while setting up the remote desktop connection, we couldn’t log in with our root user, and a blue screen appeared. After some research, we followed these steps to resolve the login issue:

  1. Create a new user (since the Pi root user doesn’t seem to support RDP):
  2. sudo adduser
  3. Set and confirm the password.
  4. Hit enter for the default options.
  5. Retry RDP with the new user login.

This allowed us to log in remotely, but the problem persists when running OpenCV. Specifically, we’re encountering the following error:

Can’t initialize GTK backend in the function ‘cvInitSystem’

This happens when trying to run imshow(), and video images captured by the camera cannot be displayed. Here are the steps we’ve tried without success:

  • Exporting the display variable (export DISPLAY=:0).
  • Using pkill to kill conflicting processes.
  • SSH with the -X flag for X11 forwarding (ssh pi@luxonis.local -X).

Has anyone experienced similar issues with OpenCV or remote desktop on a Raspberry Pi? Any advice or troubleshooting steps would be greatly appreciated!

Thank you in advance!

Could you please let us know which operating system you are using and its version?

I’m not familiar with the specific program you are running, but if you are using Raspberry Pi OS, you can test the camera capture by running the command libcamera-hello. Alternatively, you can execute the example/display.py script from the vilib library, which will display the camera feed both on the desktop and in a web browser.

May be an x11 permissions issue with your new user. I’d suggest creating a new sd card and ensuring that stuff like ssh etc is enabled in the advanced options. You may continue with more problems unless the initial setup is correct.

Meanwhile, you could try ssh -Y instead of ssh -X

To force x11 permissions