Error in OpenCV edge detection : driver has changed pixel format

Hello,
I got errors trying to run :

bazel run apps/tutorials/opencv_edge_detection

I am using a stereo camera
MJPEG:2560X960@ 60fps/2560X720@60fps /1280X480@60fps/640X240@60fps (ELP Synchronization Dual Undistortion Lens usb camera Module Lens MJPEG 60fps 2560X960 OV9750 CMOS Stereo Webcam HD for 3D VR Camera [ELP-960P2CAM-V83] - $87.00 : ELP USB Webcam)
The camera work perfectly in vlc with the following bash and parameters :
vlc v4l2:///dev/video0

Codec MJPEC
Resolution 2560x960
Decoded format Planar 4:2:2 YUV full scale

When I am trying to use 720x1280 resolution the error is :
PANIC packages/sensors/V4L2Camera.cpp@144: [V4L2Camera] Unsupported height, 720, driver changed to 480

And when I use 240x640 the error is :

2020-04-29 08:30:21.403 PANIC packages/sensors/V4L2Camera.cpp@149: 
[V4L2Camera] Error: driver has changed pixel format to: 1196444237
 Isaac application terminated unexpectedly   

Here is the tutorial sample with just a modification on img size and frequency :

{
  "name": "opencv_edge_detection",
  "modules": [
      "//apps/tutorials/opencv_edge_detection:edge_detector",
      "sensors:v4l2_camera",
      "viewers"
  ],
  "config": {
    "v4l2_camera": {
      "driver": {
        "device_id": 0,
        "rows": 240,
        "cols": 640,
        "rate_hz": 60
      }
    },
    "websight": {
      "WebsightServer": {
        "port": 3000,
        "ui_config": {
          "windows": {
            "Edge Detection": {
              "renderer": "2d",
              "dims": {
                "width": 1344,
                "height": 376
              },
              "channels": [
                {
                  "name": "opencv_edge_detection/edge_detector/viewer/Color"
                }
              ]
            },
            "Original Image": {
              "renderer": "2d",
              "dims": {
                "width": 1344,
                "height": 376
              },
              "channels": [
                {
                  "name": "opencv_edge_detection/v4l2_camera/viewer/Color"
                }
              ]
            }
          }
        }
      }
    }
  },
  "graph": {
    "nodes": [
      {
        "name": "v4l2_camera",
        "components": [
          {
            "name": "message_ledger",
            "type": "isaac::alice::MessageLedger"
          },
          {
            "name": "driver",
            "type": "isaac::V4L2Camera"
          },
          {
            "name": "viewer",
            "type": "isaac::viewers::ColorCameraViewer"
          }
        ]
      },
      {
        "name": "edge_detector",
        "components": [
          {
            "name": "message_ledger",
            "type": "isaac::alice::MessageLedger"
          },
          {
            "name": "edge_detector",
            "type": "isaac::opencv::EdgeDetector"
          },
          {
            "name": "viewer",
            "type": "isaac::viewers::ColorCameraViewer"
          }
        ]
      }
    ],
    "edges": [
      {
        "source": "v4l2_camera/driver/frame",
        "target": "edge_detector/edge_detector/input_image"
      },
      {
        "source": "v4l2_camera/driver/frame",
        "target": "v4l2_camera/viewer/color_listener"
      },
      {
        "source": "edge_detector/edge_detector/output_image",
        "target": "edge_detector/viewer/color_listener"
      }
    ]
  }
}

Do I need to use the following to switch to YUV ?

struct ColorCameraProto {
  # Actual image captured by the camera. The pixel type depends on the type of camera. Most commonly
  # it could be a single 8-bit integer for a greyscale camera, or a three 8-bit integers for a
  # color camera.
  image @0: ImageProto;
  # The choices available for color space
  enum ColorSpace {
    greyscale @0;
    rgb @1;
    bgr @2;
    yuv @3;
    rgba @4;
  }
  # Color space used by the image
  colorSpace @1: ColorSpace;
  # Intrinsic camera parameters
  pinhole @2: PinholeProto;
  distortion @3: DistortionProto;
}

Here is the EdgeDetector.cpp code untouched :

/*
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.

NVIDIA CORPORATION and its licensors retain all intellectual property
and proprietary rights in and to this software, related documentation
and any modifications thereto. Any use, reproduction, disclosure or
distribution of this software and related documentation without an express
license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#include "EdgeDetector.hpp"

#include <memory>
#include <utility>

#include "engine/core/assert.hpp"

#include "engine/gems/image/conversions.hpp"
#include "engine/gems/image/utils.hpp"
#include "messages/math.hpp"

#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"

namespace isaac {
namespace opencv {

void EdgeDetector::start() {
  tickOnMessage(rx_input_image());
}

void EdgeDetector::tick() {
  const int kernel_size = get_kernel_size();
  switch (kernel_size) {
    case 1:
    case 3:
    case 5:
    case 7:
      break;
    default:
      LOG_ERROR("Invalid Kernel size for edge detector, Must be 1, 3, 5 or 7. Aborting.");
      return;
  }

  auto input = rx_input_image().getProto();
  ImageConstView3ub input_image;
  bool ok = FromProto(input.getImage(), rx_input_image().buffers(), input_image);
  ASSERT(ok, "Failed to deserialize the input image");

  const size_t rows = input_image.rows();
  const size_t cols = input_image.cols();
  Image1ub output_image(rows, cols);
  cv::Mat image =
      cv::Mat(rows, cols, CV_8UC3,
              const_cast<void*>(static_cast<const void*>(input_image.data().pointer())));
  cv::Mat gradient = cv::Mat(rows, cols, CV_8U, static_cast<void*>(output_image.data().pointer()));

  cv::Mat scratch, scratch_gray_scale;
  cv::GaussianBlur(image, scratch, cv::Size(kernel_size, kernel_size), 0, 0, cv::BORDER_DEFAULT);
  cv::cvtColor(scratch, scratch_gray_scale, cv::COLOR_RGB2GRAY);

  cv::Mat gradient_x, gradient_y;
  cv::Mat abs_gradient_x, abs_gradient_y;
  cv::Sobel(scratch_gray_scale, gradient_x, CV_16S, 1, 0, kernel_size);
  cv::Sobel(scratch_gray_scale, gradient_y, CV_16S, 0, 1, kernel_size);
  cv::convertScaleAbs(gradient_x, abs_gradient_x);
  cv::convertScaleAbs(gradient_y, abs_gradient_y);
  cv::addWeighted(abs_gradient_x, 0.5, abs_gradient_y, 0.5, 0, gradient);

  auto output = tx_output_image().initProto();

  auto in_pinhole = input.getPinhole();
  const Vector2d focal = FromProto(in_pinhole.getFocal());
  const Vector2d center = FromProto(in_pinhole.getCenter());

  auto out_pinhole = output.initPinhole();
  ToProto(focal, out_pinhole.getFocal());
  ToProto(center, out_pinhole.getCenter());
  out_pinhole.setCols(in_pinhole.getCols());
  out_pinhole.setRows(in_pinhole.getRows());

  auto in_distortion = input.getDistortion();
  auto out_distortion = output.initDistortion();
  auto distortion_coeff = FromProto(in_distortion.getCoefficients());
  out_distortion.setModel(in_distortion.getModel());
  ToProto(distortion_coeff, out_distortion.getCoefficients());

  output.setColorSpace(ColorCameraProto::ColorSpace::GREYSCALE);
  ToProto(std::move(output_image), output.getImage(), tx_output_image().buffers());
  tx_output_image().publish(rx_input_image().acqtime());
}

}  // namespace opencv
}  // namespace isaac

Thank you for your help !

And when I try v4l2 utils I get :

v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Index       : 0
	Type        : Video Capture
	Pixel Format: 'MJPG' (compressed)
	Name        : Motion-JPEG
		Size: Discrete 2560x960
			Interval: Discrete 0.017s (60.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 2560x720
			Interval: Discrete 0.017s (60.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 1280x480
			Interval: Discrete 0.017s (60.000 fps)
			Interval: Discrete 0.033s (30.000 fps)
		Size: Discrete 640x240
			Interval: Discrete 0.017s (60.000 fps)
			Interval: Discrete 0.033s (30.000 fps)

Format Video Capture:

	Width/Height      : 2560/960
	Pixel Format      : 'MJPG'
	Field             : None
	Bytes per Line    : 0
	Size Image        : 4915200
	Colorspace        : sRGB
	Transfer Function : Default (maps to sRGB)
	YCbCr/HSV Encoding: Default (maps to ITU-R 601)
	Quantization      : Default (maps to Full Range)

I found this parameter but don’t know where to put it : V4L2_PIX_FMT_MJPEG

See following post for solution :