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".
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. 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