# Raspberry PI Camera v2.1 gstreamer opens in Python but not in C++, Jetpack 4.2.2

**URL:** <https://forums.developer.nvidia.com/t/raspberry-pi-camera-v2-1-gstreamer-opens-in-python-but-not-in-c-jetpack-4-2-2/82428>\
**Category:** Jetson Nano\
**Created:** [September 27, 2019, 9:59am UTC](https://forums.developer.nvidia.com/t/raspberry-pi-camera-v2-1-gstreamer-opens-in-python-but-not-in-c-jetpack-4-2-2/82428 "2019-09-27T09:59:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![itadmin](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@itadmin](https://forums.developer.nvidia.com/u/itadmin)\
**Post date:** [September 27, 2019, 9:59am UTC](https://forums.developer.nvidia.com/t/raspberry-pi-camera-v2-1-gstreamer-opens-in-python-but-not-in-c-jetpack-4-2-2/82428/1 "2019-09-27T09:59:11Z")

</div>

Hello,

I am trying to use the CSI camera Raspberry Pi v.2.1 with the newest Jetson Nano SD Image JP 4.2.2.

If I use python to open the gstreamer pipeline it shows the image.

If I use C++ to open the gstreamer I get following error, altough I am using th exact same gstreamer pipeline.

Does anyone one know why? I believe Python is just a wrapper for underlying C++ libs that have been compiled with OpenCV ++. Using precompiled OpenCV from the SD Image.  
Thanks

**C++ Code**

```auto
std:string pipeline = "nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink";
cv::VideoCapture capture(pipeline, cv::CAP_GSTREAMER);

```

**C++ Error Output**

```auto
VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream: Device or resource busy

(Face1:8669): GLib-GObject-WARNING **: 20:01:11.862: cannot register existing type 'GstInterpolationMethod'

(Face1:8669): GLib-GObject-CRITICAL **: 20:01:11.863: g_param_spec_enum: assertion 'G_TYPE_IS_ENUM (enum_type)' failed

(Face1:8669): GLib-GObject-CRITICAL **: 20:01:11.863: validate_pspec_to_install: assertion 'G_IS_PARAM_SPEC (pspec)' failed
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp, line 887
VIDEOIO(cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index))): raised OpenCV exception:

/home/nvidia/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp:887: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3264 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3264 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode = 2 
   Output Stream W = 1920 H = 1080 
   seconds to Run = 0 
   Frame Rate = 29.999999 
GST_ARGUS: PowerService: requested_clock_Hz=13608000
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
GST_ARGUS: Cleaning up
CONSUMER: Done Success
GST_ARGUS: Done Success
Failed to open camera.

GST_ARGUS: 
PowerServiceHwVic::cleanupResources

Process finished with exit code 255

```

**Python Code**

```auto
import sys
import cv2

def read_cam():
    cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img = cap.read();
            cv2.imshow('demo',img)
            cv2.waitKey(10)
    else:
     print "camera open failed"

    cv2.destroyAllWindows()

if __name__ == ' __main__':
    read_cam()

```

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [October 1, 2019, 4:05am UTC](https://forums.developer.nvidia.com/t/raspberry-pi-camera-v2-1-gstreamer-opens-in-python-but-not-in-c-jetpack-4-2-2/82428/2 "2019-10-01T04:05:10Z")

</div>

Hi,  
We have verified the [steps](https://devtalk.nvidia.com/default/topic/1057460/jetson-tx2/custom-built-opencv-3-4-0-following-nvidia-advice-not-working/post/5363355/#5363355).  
Please check if you can run the sample.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 18, 2021, 5:45pm UTC](https://forums.developer.nvidia.com/t/raspberry-pi-camera-v2-1-gstreamer-opens-in-python-but-not-in-c-jetpack-4-2-2/82428/3 "2021-10-18T17:45:26Z")

</div>

Closed on October 18, 2021, 5:45pm UTC


