Opencv: Releasing VideoCapture / Webcam doesn't work

Created on 27 Jul 2015  路  3Comments  路  Source: opencv/opencv

Transferred from http://code.opencv.org/issues/3672

|| Martijn van der Veen on 2014-05-02 21:02
|| Priority: Normal
|| Affected: branch 'master' (3.0-dev)
|| Category: python bindings
|| Tracker: Bug
|| Difficulty: Medium
|| PR: 
|| Platform: x64 / Linux

Releasing VideoCapture / Webcam doesn't work

Using python (3.4) bindings on Ubuntu 14.04 with build-in webcam using v4l4, master branch:

In [2]: cap = cv2.VideoCapture(0)
HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP

In [3]: a,b = cap.read() # although error, reading frame works (a=True, b=np.array)

In [4]: cap.release()

In [5]: cap.isOpened()
Out[5]: False

In [6]: cap = cv2.VideoCapture(0)
HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV

In [7]: a,b = cap.read()
VIDIOC_STREAMON: Bad file descriptor


After calling .release(), webcam light stays on and webcam stays unreachable for other programs (e.g., Cheese).

History

Martijn van der Veen on 2014-05-02 21:24
(Btw, the webcam _is_ released when python exits, but in some cases that's not enough - e.g., for running programs that need to release the webcam now and then.)
Alexander Smorkalov on 2014-05-04 15:58
-   Category set to python bindings
Andrew Senin on 2014-05-06 14:21
Hello Martijn, 

Since our resources are limited please consider investigating this issue and creating a fixing pull request (http://code.opencv.org/projects/opencv/wiki/How_to_contribute). All help to the project is highly appreciated!
-   Difficulty set to Medium
-   Assignee set to Martijn van der Veen
-   Status changed from New to Open
Maksim Shabunin on 2015-04-27 09:12
-   Target version changed from 3.0-beta to 3.0
Maksim Shabunin on 2015-04-28 13:42
Can not reproduce with the 3.0-rc1 release. Webcam is successfully released and reopened.

Can you, please, try to reproduce it with the latest version? Probably it has been fixed already.
-   Assignee changed from Martijn van der Veen to Maksim Shabunin
Maksim Shabunin on 2015-04-28 13:42
-   Status changed from Open to Incomplete
3.4 auto-transferred bug python bindings normal

All 3 comments

I assume nobody has picked this up? This bug is affecting me as well for OpenCV for Java. I am on a tight deadline but can work around this bug. After I complete my tasks here, I could look into this. If its possible, I could pick this up in three months.

@brianmichalk1 feel free to pick this up if you can provide a fix via a Pullrequest

Have come over this bug, in c++, affects using OpenBR, which is dependent upon OpenCV 2.4.
If this bug is resolved in OpenCV 3.
will this issue be resolved in OpenCV 2.4.*?
OpenBR: v 1.1.0
Leptonica: v 1.74.1
OpenCV: v. 2.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dpo picture dpo  路  3Comments

koleckar picture koleckar  路  3Comments

kwstanths picture kwstanths  路  3Comments

littletiger311 picture littletiger311  路  3Comments

opencv-pushbot picture opencv-pushbot  路  3Comments