Arducam HQ cam with OpenCV on Raspberry Pi 4 - Failed to allocate required memory

  1. Where did you get the camera module(s)?

  2. Model number of the product(s)?

  3. What hardware/platform were you working on?
    Raspberry Pi 4 Debian Bullseye

  4. Instructions you have followed. (link/manual/etc.)
    cap = cv2.VideoCapture(0)
    cap.set(cv2.CAP_PROP_FRAME_WIDTH, 2028)
    cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1520)

  5. Problems you were having?
    [ WARN:0] global …/modules/videoio/src/cap_gstreamer.cpp (1824) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate required memory.
    [ WARN:0] global …/modules/videoio/src/cap_gstreamer.cpp (914) open OpenCV | GStreamer warning: unable to start pipeline
    [ WARN:0] global …/modules/videoio/src/cap_gstreamer.cpp (501) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

  6. The dmesg log from your hardware?
    [20599.818490] unicam fe801000.csi: Wrong width or height 3840x2160 (remote pad set to 2028x1520)
    [20599.818516] unicam fe801000.csi: Failed to start media pipeline: -22
    [20599.868431] unicam fe801000.csi: Failed to start media pipeline: -22

  7. Troubleshooting attempts you’ve made?
    Libcamera works. Picamera2 works.

  8. What help do you need?
    How can I get cv2.VideoCapture(0) to work properly?