OpenCV and Webcam problem: Pixel format of incoming image is unsupported by OpenCV

Hello everyone.

I just installed OpenCV4Tegra on my TX2 and I can import cv2 in python, but an ERROR came out when I used cv2.VideoCapture(0) to capture video stream. The error tips as followed:

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> vs = cv2.VideoCapture(0)
VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV

My TX2 runs with JetPack 3.0, and the opencv is 3.2.0, the camera is the default camera come with TX2.

Any help will be much appreciated.

Please paste the result of

v4l2-ctl -d /dev/video0 --list-formats

You could reference to other topic related to opencv+gstreamer.

OpenCV support only BGR and Gray8. The default format from onboard camera does not belong to any of these. However, as I know, Opencv TOT supports more formats now.

problem solved.

  1. uninstall OpenCV4Tegra if installed
    sudo apt-get purge libopencv4tegra-dev libopencv4tegra
    sudo apt-get purge libopencv4tegra-repo
    sudo apt-get update

  1. install gstreamer support for OpenCV
    sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

  2. install OpenCV
    remain -DWITH_GSTREAMER_0_10=OFF

  3. use CMAKE GUI check if gstreamer installed

      base:                      YES (ver 1.8.3)
      video:                     YES (ver 1.8.3)
      app:                       YES (ver 1.8.3)
      riff:                      YES (ver 1.8.3)
      pbutils:                   YES (ver 1.8.3)
  1. use cv2 in python
gst = "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=6 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"
cap = cv2.VideoCapture(gst)

Hi,If I had already install opencv . how can I determine if I had gstreamer plugin? Beacuse I was directly install from Jetpack. So I do not know .

The versions included in JetPack (OpenCV4tegra for old releases and opencv-3.3.1 for recent ones) are built without gstreamer support.
You have to build and install your own version. You may check


Im getting the pixelformat issue while using logitech webcam.
What should I do?