Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: unable to open video source: 0 #26

Open
Jihong-Zhu opened this issue Sep 25, 2024 · 1 comment
Open

Warning: unable to open video source: 0 #26

Jihong-Zhu opened this issue Sep 25, 2024 · 1 comment

Comments

@Jihong-Zhu
Copy link

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:[email protected]] global cap_v4l.cpp:999 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
[ERROR:[email protected]] 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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant