Ask Your Question
0

VIDIOC_QBUF error causing webcam image tearing

asked 2013-03-25 15:20:11 -0600

DuskFyre gravatar image

updated 2013-03-25 16:46:51 -0600

Hello everyone!

I am trying to have a webcam stream video using OpenCV. I'm using the basic camera.py python code to access it.

The image is generally very good, but there is frequently a frame in which there is image tearing. At the same time, I get an error in terminal: "VIDIOC_QBUF: Invalid argument". Additionally, on initial startup, I get about 5-15 errors stating: "VIDIOC_QUERYMENU: Invalid argument"

The strangest part about this is that I may occasionally get an "Input/Output Error" in terminal. Once this occurs, the video streams perfectly with no more tearing.

I am using the Logitech C270 Webcam on the Raspberry Pi. Using different resolutions does not help the problem.

Code:

import cv2.cv as cv

cv.NamedWindow("camera", 1)
capture = cv.CaptureFromCAM(-1)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_WIDTH, 320)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_HEIGHT, 240)

while True:
    img = cv.QueryFrame(capture)
    cv.ShowImage("camera", img)
    if cv.WaitKey(30) == 27:
        break
edit retag flag offensive close merge delete

Comments

I believe the "VIDIOC_QUERYMENU" error messages are coming from v4l - video 4 linux - driver. I've personally never been able to resolve them, but aside from those error messages on start up the image capturing works fine.

HD_Mouse gravatar imageHD_Mouse ( 2013-03-25 15:43:35 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-03-25 15:30:33 -0600

I am guessing this are just mistakes due to the USB connection of your webcam. Prolly it takes some times more than 30 ms to actually put the frame content on the window, and give the window time to refresh, which actually causes the error.

I have done some research and two solutions have been suggested on other fora:

  1. Increase the time to 50 ms seems to work for most USB webcams fluently.
  2. Sometimes it seems that the webcam driver is outdated. Try updating.

Hopefully someone has experienced same problems, I havent met it yet.

edit flag offensive delete link more

Comments

Hmm, I increased the wait time, but that does not appear to help the problem; even when I set it to a very high wait such as 500ms. Updating the drivers isn't really a possibility here, since I am using the Raspberry Pi and am rather new to its operation

DuskFyre gravatar imageDuskFyre ( 2013-03-25 15:55:19 -0600 )edit

If you are using raspberry pi, i am guessing the problem is the limited work memory the system has. Are you sure reducing the fra

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-26 09:23:28 -0600 )edit

Question Tools

Stats

Asked: 2013-03-25 15:20:11 -0600

Seen: 8,137 times

Last updated: Mar 25 '13