Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
709 views
in Technique[技术] by (71.8m points)

python - cv2.VideoCapture.open() always returns FALSE

I am trying to access a Logitech c310 webcam on my beaglebone. It always returns false for any device ID, I am not sure why.

I use the following code.

>>> import cv2, numpy as np
>>> cam = cv2.VideoCapture(0)
>>> cam.open(0)
False

The camera does show up as video0 in dev/ and also in root@arm:~#lsusb, like below,

root@arm:~# lsusb
Bus 001 Device 002: ID 046d:081b Logitech, Inc. Webcam C310
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I could also access the camera with v4l2-ctl. Note that I am very new to OpenCV, so this may sound silly and I apologize for that in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
HIGHGUI ERROR: V4L: index 1 is not correct!
False
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array  type) in cvGetMat, file /home/kaushik/Desktop/OpenCV-2.4.1/modules/core/src/array.cpp, line 2482
Traceback (most recent call last):
File "x2.py", line 8, in <module>
cv2.imshow('frame', frame)
cv2.error: /home/kaushik/Desktop/OpenCV-2.4.1/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat

if you are getting this kind of an error then probably something is wrong with the indexing.

instead of cv2.VideoCapture(0) add:

cv2.VideoCapture(-1)

this will get you the first working camera. And if anything goes wrong, just post the stack trace here and i'll see if i can help you :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...