PyImageSearch / imutils

A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.
MIT License
4.51k stars 1.03k forks source link

Unable to set resolution of webcam videostreams #206

Open whogben opened 4 years ago

whogben commented 4 years ago

Following this earlier issue, I am trying to set the resolution of a videostream coming off of a webcam: https://github.com/jrosebr1/imutils/issues/55

According to the resolution of that issue, the addition of kwargs was meant to resolve this, but looking at VideoStream.init(..) it appears kwargs are ignored for webcam video streams: https://github.com/jrosebr1/imutils/blob/master/imutils/video/videostream.py

Following the workaround described in the original issue, I have tried to set the information after starting the stream using openCV args:

self.video_stream = VideoStream(self.cam_idx, resolution=(width,height)).start()
self.video_stream.stream.set(cv2.CAP_PROP_FRAME_WIDTH, width)
self.video_stream.stream.set(cv2.CAP_PROP_FRAME_HEIGHT, height)

errors:

VIDIOC_DQBUF: Invalid argument
VIDIOC_STREAMON: Invalid argument
VIDIOC_STREAMON: Invalid argument

I'm out of ideas - is there a way to set a resolution for a webcam based VideoStream / is there a recommended workaround?

Thanks!

jaromrax commented 3 years ago
picam = VideoStream(0 ).start()
picam.stream.set(3, 640)
picam.stream.set(4, 480)

works fine to me.

matiasandina commented 2 years ago

Any updates on this? this still seems to not be solved