OpenCV with Leopard imx185 and TX1

I’m using a Leopard imx185 camera CSI-2 together with TX1 and OpenCV4Tegra. I was given the following error:
“HIGHGUI ERROR: V4L2: pixel format of incoming image is unsupported by OpenCV”.
By using the command:
VideoCapture cap(“nvcamerasrc ! video/x-raw(memory:NVMM),
width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=2
! video/x-raw, format=(string)BGRx ! videoconvert ! ‘video/x-raw, format=(string)BGR’ ! appsink”);
instead of:
VideoCapture cap(0);
I apparently managed to fix this problem, but unfortunately camera doesn’t open
returns false.
How can I fix it?


this may help you:

int main(int argc, const char** argv)

    bool useCamera = true;//parser.get<bool>("camera");
    bool update_bg_model = true;
    char* gst = "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=2 ! videoconvert ! appsink";

    VideoCapture cap(gst);

    if( !cap.isOpened() )
        printf("can not open camera or video file\n%s", "");
        return -1;