2

I am only running this simple code in my Raspberry Pi 4:

from imutils.video import VideoStream

# initialize the video streams and allow them to warmup
print("[INFO] starting cameras...")
webcam = VideoStream(src=0).start()

I can run this code without any problem with the Raspberry Pi camera, but I get error with my Logitech C310 webcam.

The error is: VIDIOC_QBUF: Invalid argument

The camera works perfectly when used with fswebcam in the terminal. I also tried using it with online webcam test, and it works. My only problem is the camera can't be used with my Python code. I also tried using it with opencv and it returned None.

Hardware: Raspberry Pi 4 4GB

OS: Raspbian Buster

Hope anyone can help me, thank you.

Dat_Dude
  • 35
  • 1
  • 7

1 Answers1

0

I solved a similar problem with a Logitech C920 by lowering the resolution. At the maximum resolution (1920x1080) I also get the VIDIOC_QBUF: Invalid argument error, however by lowering the resolution I am able to read the frames:

from cv2 import cv2
cam = cv2.VideoCapture(0)

# Change the camera setting using the set() function
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)

retval, frame = cam.read()

# do stuff with the captured image here
cam.release()
Jens Ehrich
  • 573
  • 1
  • 6
  • 19