Getting black lines when capturing camera RAW

Hi, first off I apologize if this is a duplicate of another thread or a common issue. I’ve been trying to find a solution to this problem but I haven’t been able to find anything and I’m not sure whether it’s because it’s an unique problem or because I’m not searching with the right keywords.

For background: I’m using a raspberry pi 4b (raspbian buster, 5.10.92), OpenCV 4.5.5 (compiled from source) and an OV9281 camera with inno-maker’s drivers (not the latest ones in github, since I couldn’t make them work) so I can experiment with their high fps (456) low resolution (320x200) mode. The camera outputs 8-bit grayscale RAW.

When using VLC to open the camera (using the ATSC 8-VSB video standard), I get what I’d expect (the camera is looking directly upwards into a fluorescent bulb). However, when I open the camera feed with opencv, every other pixel row is black.
My first impression was that OpenCV was not correctly decoding the RAW format and somehow interpreting every odd column as black. Now, the weird thing is that changing the camera driver’s mode to any other mode, even when the pixel format stays the same (8-bit grayscale), gets rid of the black rows
test_gain195

So after noticing this I guess that the driver is doing some kind of trick in the 320x200px mode that VLC “understands” or “masks” but OpenCV doesn’t. Maybe?

My code is the sample “videocapture_camera.cpp” code from the official repository, I’ve tried changing the apiPreference attribute in the VideoCapture constructor and setting CAP_PROP_CONVERT_RGB to 0 and trimmed the image processing, but nothing changed so in the end the code is essentially:

Mat frame;
VideoCapture capture(0);
for(;;) {
  capture >> frame;
  imshow("Frame",frame);
  waitkey(1);
}

So, has anyone else seen something like this or know what is causing this? Am I doing something extremely wrong? Any help is appreciated.

PS:
This is what v4l2-ctl --all returns:
Driver/interface/etc info:

        Driver name      : unicam
        Card type        : unicam
        Bus info         : platform:fe801000.csi
        Driver version   : 5.10.92
        Capabilities     : 0x85a00001
                Video Capture
                Metadata Capture
                Read/Write
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x05200001
                Video Capture
                Read/Write
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : unicam
        Model            : unicam
        Serial           :
        Bus info         : platform:fe801000.csi
        Media version    : 5.10.92
        Hardware revision: 0x00000000 (0)
        Driver version   : 5.10.92
Interface Info:
        ID               : 0x03000005
        Type             : V4L Video
Entity Info:
        ID               : 0x00000003 (3)
        Name             : unicam-image
        Function         : V4L2 I/O
        Flags         : default
        Pad 0x01000004   : 0: Sink
          Link 0x02000007: from remote pad 0x1000002 of entity 'vc_mipi_ov9281 10-0060': Data, Enabled, Immutable
Priority: 2

Camera info, 320x200 mode, black lines

Video input : 0 (Camera 0: ok)
Format Video Capture:
        Width/Height      : 320/200
        Pixel Format      : 'GREY' (8-bit Greyscale)
        Field             : None
        Bytes per Line    : 640
        Size Image        : 128000
        Colorspace        : Default
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :
User Controls

                       exposure 0x00980911 (int)    : min=8721 max=7718085 step=1 default=5939001 value=8721
                           gain 0x00980913 (int)    : min=0 max=254 step=1 default=16 value=254
                horizontal_flip 0x00980914 (bool)   : default=0 value=0
                  vertical_flip 0x00980915 (bool)   : default=0 value=0

Image Processing Controls

                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0
                     pixel_rate 0x009f0902 (int64)  : min=100638720 max=100638720 step=1 default=100638720 value=100638720 flags=read-only

Camera info, 640x400 mode, no black lines:

Video input : 0 (Camera 0: ok)
Format Video Capture:
        Width/Height      : 640/400
        Pixel Format      : 'GREY' (8-bit Greyscale)
        Field             : None
        Bytes per Line    : 640
        Size Image        : 256000
        Colorspace        : Default
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :

User Controls

                       exposure 0x00980911 (int)    : min=8721 max=7718085 step=1 default=5939001 value=5939001
                           gain 0x00980913 (int)    : min=0 max=254 step=1 default=16 value=16
                horizontal_flip 0x00980914 (bool)   : default=0 value=0
                  vertical_flip 0x00980915 (bool)   : default=0 value=0

Image Processing Controls

                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0
                     pixel_rate 0x009f0902 (int64)  : min=229062750 max=229062750 step=1 default=229062750 value=229062750 flags=read-only