gelsightinc / gsrobotics

GelSight SDK for robotic sensors
GNU General Public License v3.0
80 stars 24 forks source link

Warning: unable to open video source: 0 #26

Open Jihong-Zhu opened 2 hours ago

Jihong-Zhu commented 2 hours ago

Using Ubuntu 24.04 LTS with python 3.8, and a virtual environment.

I replaced the lid with the grey one for GelsightMini and run

python3 optical_flow_marker_tracking.py

I've got an error

FOUND! video1 -> GelSight Mini R0B 28UU-WAEL: Ge
FOUND! video0 -> GelSight Mini R0B 28UU-WAEL: Ge
[ WARN:0@0.213] global cap_v4l.cpp:999 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
[ERROR:0@0.213] global obsensor_uvc_stream_channel.cpp:158 getStreamChannelGroup Camera index out of range
Warning: unable to open video source:  0
ERROR! reading image from camera
Traceback (most recent call last):
  File "optical_flow_marker_tracking.py", line 34, in <module>
    f0gray = cv2.cvtColor(f0, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.10.0) /io/opencv/modules/imgproc/src/color.cpp:196: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

It seems to me that it could not read from the camera?

But apparently, it found the camera on Gelsight.

Any help would be greatly appreciated.

Thanks

Jihong-Zhu commented 2 hours ago

Indeed, the camera won't open, somehow, I traced back to

class Camera 

def connect(self)

and replaced

self.cam = cv2.VideoCapture(self.dev_id)
if self.cam is None or not self.cam.isOpened():
      print('Warning: unable to open video source: ', self.dev_id)

with

self.cam = cv2.VideoCapture(-1)

Then it works