I am currently running ubuntu 18.04 and I have a picamera connected to my rpi. When I use the main display and connect the rpi to my screen via HDMI, I can access the camera using the opencv library using cv2.videoCapture(0) with the code included below.
However, when I do the same using a remote virtual desktop (using xfce4 desktop environment, tightvnc, port 5901) I cannot access my picamera. When I run a check using the same code, it does not detect my camera, hence it does not display the video. When I enter "ls /dev" while connected remotely, I see the /dev/video0 device in the terminal on my remote desktop, which is my camera. What is causing my picamera to not work on the remote desktop and how do I solve this?
Also a keyboard and mouse connected directly to my rpi does affect anything on my remote screen, perhaps that has something to do with why my camera is not detected? Perhaps someone could help me with using devices attached directly to my rpi while accessing it remotely. Thank you for any help.
Code used to test camera
import cv2 cams_test = 3 for i in range(0, cams_test): cap = cv2.VideoCapture(i) test, frame = cap.read() print("i : "+str(i)+" /// result: "+str(test)) cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() if ret == True: rect, frame = cap.read() cv2.imshow('camera', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break if ret == False: cap.release() cv2.destroyAllWindows() cap.release() cv2.destroyAllWindows()