title: OpenCV reading too few pixels per row from camera
body: <p>I am trying to fetch a video stream from a camera connected to the serial camera interface on my Raspberry pi 4. To read the video stream I'm using OpenCV and I have set the resolution to the maximum supported as listed by</p>
  <pre><code>pi@raspberrypi:~ $ ffmpeg -f v4l2 -list_formats all -i /dev/video0
  </code></pre>
  <p>The output from this can be seen here: <a href="https://imgur.com/a/z7tea4j" rel="nofollow noreferrer">https://imgur.com/a/z7tea4j</a><br><br>
  When scaling and showing the image using <code>imshow</code> it produces the strange output as seen here:
  <a href="https://i.stack.imgur.com/IN4VH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IN4VH.png" alt="enter image description here" /></a> <br><br>
  I have tried setting different resolutions and for lower resolutions the &quot;bug&quot; disappears, but the image doesn't entirely fit in the window, meaning some pixels are left out. I have also tried changing pixel format, to both H264 and MJPEG but this only gives me a <code>VIDIOC_STREAMON: Operation not permitted</code>.<br><br>
  My code:</p>
  <pre><code>int testCamera(){
      VideoCapture stream = VideoCapture(0);
      if (!stream.isOpened()) {
          std::cout &lt;&lt; &quot;failed to start video stream&quot; &lt;&lt; std::endl;
          return -1;
      }
      stream.set(CAP_PROP_FRAME_WIDTH, 4056);
      stream.set(CAP_PROP_FRAME_HEIGHT, 3040);
      int frameWidth = stream.get(CAP_PROP_FRAME_WIDTH);
      int frameHeight = stream.get(CAP_PROP_FRAME_HEIGHT);
      std::cout&lt;&lt;frameWidth&lt;&lt;&quot;x&quot;&lt;&lt;frameHeight&lt;&lt;std::endl; //Prints 4056x3040
   
      Mat frame;
      Mat resized;
      while(1){
          stream &gt;&gt; frame;
   
          resize(frame, resized, Size(1280, 720));
          imshow(&quot;frame&quot;, resized);
          if (waitKey(10) == 27) break;
      }
  }
  </code></pre>
  <p>Is this a hardware fault rather than a mismatch in OpenCV? Does anyone know how to fix this?</p>