# IP camera connection with jetson.utils.gstCamera

**URL:** <https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064>\
**Category:** Jetson Nano\
**Tags:** camera\
**Created:** [September 23, 2020, 12:41am UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064 "2020-09-23T00:41:40Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![terry.l.lee](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@terry.l.lee](https://forums.developer.nvidia.com/u/terry.l.lee)\
**Post date:** [September 23, 2020, 12:41am UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/1 "2020-09-23T00:41:40Z")

</div>

I’m having some issue with the jetson.utils.gstCamera command. The same IP camera is working with gst-launch-1.0 command on the terminal.

Not working comment:  
camera = jetson.utils.gstCamera(640, 480, “rtspsrc location=rtsp://192.168.3.162:554/media/video1 latency=0 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=BGRx, width=640, height=480”)

Error message:  
[gstreamer] gstCamera failed to create pipeline  
[gstreamer] (could not parse caps “video/x-raw, format=(string) , width=(int)640, height=(int)480”)  
[gstreamer] gstCamera – failed to create device rtspsrc location=rtsp://192.168.3.162:554/media/video1 latency=0 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=BGRx, width=640, height=480

Working command:  
gst-launch-1.0 rtspsrc location=rtsp://192.168.3.162:554/media/video1 ! rtph264depay ! h264parse ! avdec\_h264 ! videoconvert ! gtksink

I went through a lot of blogs and was not able to find a solution. Did I missed simple ?  
Thanks,  
Terry

---

<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:** [September 23, 2020, 2:47am UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/3 "2020-09-23T02:47:12Z")

</div>

Hi,  
Please check the source code:

> <https://github.com/dusty-nv/jetson-utils/blob/916023814a1ac1401380c5d4313454c78c0a5f40/camera/gstCamera.cpp>

The default implementation supports _nvarguscamerasrc_ and _v4l2src_. Your case is _rtsprc_ and you may need to customize the code.

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [September 23, 2020, 2:48pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/4 "2020-09-23T14:48:24Z")

</div>

As @DaneLLL mentioned, gstCamera does not support RTP/RTSP - however, the newer videoSource interface in jetson.utils does. It has a similar API:

- [jetson-inference/aux-streaming.md at master · dusty-nv/jetson-inference · GitHub](https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-streaming.md#rtp)
- [jetson-inference/aux-streaming.md at master · dusty-nv/jetson-inference · GitHub](https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-streaming.md#python)

---

<div class="post-metadata">

**Author:** ![terry.l.lee](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@terry.l.lee](https://forums.developer.nvidia.com/u/terry.l.lee)\
**Post date:** [September 23, 2020, 9:15pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/5 "2020-09-23T21:15:15Z")

</div>

Thanks a lot for the information. I would not have figure it out that the “jetson.utils.gstCamera” does not support IP camera without your helps.

I tried out the new jetson.utils with:  
input = jetson.utils.videoSource(“rtsp://0000:0000aaaa@192.168.3.162:554”, “my\_video.mp4” )

It return error of : [gstreamer] gstDecoder – failed to create decoder for rtsp://192.168.3.162:554

Did you miss anything ?

My goal is to run object detection with IP camera.  
I’m currently able to do so by the following steps.

1. using opencv to acquire images
2. convert to rgba with: frame\_rgba = cv2.cvtColor(frame, cv2.COLOR\_BGR2RGBA)
3. convert to cuda with: image = JTUils.cudaFromNumpy(frame\_rgba)
4. object detection with :detections = self.net.Detect(image, image.width, image.height)

While this work, i’m concerning that the process is not efficient. The process of converting image could take a lot of time then needed. Could you comment on the best way to accomplish this task?  
Thanks,

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [September 24, 2020, 2:02pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/6 "2020-09-24T14:02:25Z")

</div>

> [@terry.l.lee](#):
>
> input = jetson.utils.videoSource(“rtsp://0000:0000aaaa@192.168.3.162:554”, “my\_video.mp4” )

It is not expecting the second argument of `“my_video.mp4”`. What I would try running first, is the `video-viewer` sample, which you can see being used for RTSP input here:

[https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-streaming.md#rtsp](https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-streaming.md#rtsp)

Then if you can view the stream, you can modify your application to use similar code to video-viewer.py.

---

<div class="post-metadata">

**Author:** ![terry.l.lee](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@terry.l.lee](https://forums.developer.nvidia.com/u/terry.l.lee)\
**Post date:** [September 24, 2020, 7:43pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/7 "2020-09-24T19:43:57Z")

</div>

I’m not having much luck with video-viewer.

video-viewer rtsp://0000:0000aaaa@192.168.3.162:554  
return message of:  
[gstreamer] gstDecoder – Could not open resource for reading.  
[gstreamer] gstDecoder – try manually setting the codec with the --input-codec option  
[gstreamer] gstDecoder – failed to create decoder for rtsp://0000:0000aaaa@192.168.3.162:554  
video-viewer: failed to create input stream

It does work in openCV with:  
cap = cv2.VideoCapture(“rtsp://0000:0000aaaa@192.168.3.162:554/cam/realmonitor?channel=1&subtype=0”)

Anything else that I can try? Did I miss some installation?  
Thanks,

---

<div class="post-metadata">

**Author:** ![dusty\_nv](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/dusty_nv/32/14043_2.png) [@dusty\_nv](https://forums.developer.nvidia.com/u/dusty_nv)\
**Post date:** [September 24, 2020, 7:48pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/8 "2020-09-24T19:48:16Z")

</div>

Can you try running it as `video-viewer --input-codec=h264 rtsp://0000:0000aaaa@192.168.3.162:554` (assuming your RTSP is encoded with H.264)

---

<div class="post-metadata">

**Author:** ![terry.l.lee](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@terry.l.lee](https://forums.developer.nvidia.com/u/terry.l.lee)\
**Post date:** [September 25, 2020, 6:37pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/9 "2020-09-25T18:37:33Z")

</div>

> [@dusty\_nv](#):
>
> `video-viewer --input-codec=h264 rtsp://0000:0000aaaa@192.168.3.162:554`

**It’s working**. Thanks a lot.  
I need to add "/media/video1 " at the end.  
video-viewer --input-codec=h264 rtsp://0000:0000aaaa@192.168.3.162:554/media/video1

Could you give me some idea on the processing time efficiency if openCV is used to capture images (detail at previous blog ) for object detection ?

---

<div class="post-metadata">

**Author:** ![Honey\_Patouceul](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/honey_patouceul/32/389777_2.png) [@Honey\_Patouceul](https://forums.developer.nvidia.com/u/Honey_Patouceul)\
**Post date:** [September 25, 2020, 7:07pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/10 "2020-09-25T19:07:57Z")

</div>

> [@terry.l.lee](#):
>
> Could you give me some idea on the processing time efficiency if openCV is used to capture images (detail at previous blog ) for object detection ?

Not sure what you mean.  
If you use jetson-utils for receiving/decoding the RTSP stream, what do you mean with ‘openCV is used to capture images’ ?  
Jetson-utils would use gstreamer for providing a RGB image than can be used instead of opencv\_video BGR.  
Opencv videoio may not be so efficient on jetson. Jetson-utils might be faster for providing frames.

---

<div class="post-metadata">

**Author:** ![terry.l.lee](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@terry.l.lee](https://forums.developer.nvidia.com/u/terry.l.lee)\
**Post date:** [September 25, 2020, 7:36pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/11 "2020-09-25T19:36:58Z")

</div>

Since I will do some image manipulation such as selected an area, rotate resize add display… before sending it to network. I wanted to see if using opencv to capture images is an feasible option or not.  
If I understand correctly, it will work. However, there will be extra processing time.  
Thanks a lot for your help,  
Terry

---

<div class="post-metadata">

**Author:** ![Honey\_Patouceul](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/honey_patouceul/32/389777_2.png) [@Honey\_Patouceul](https://forums.developer.nvidia.com/u/Honey_Patouceul)\
**Post date:** [September 25, 2020, 7:53pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/12 "2020-09-25T19:53:36Z")

</div>

I see.  
For C++ processing with opencv CUDA, you might check [this example](https://forums.developer.nvidia.com/t/gpu-acceleration-support-for-opencv-gstreamer-pipeline/143909/3).  
However, for further opencv python processing, you may also check:

> [@cudaToNumpy -\> cv2.imshow not responding, no video output, no Error - csi camera](https://forums.developer.nvidia.com/t/cudatonumpy-cv2-imshow-not-responding-no-video-output-no-error-csi-camera/144170/11):
>
> OK, I did a test, and what I found is that if there is no call to cv2.waitKey(), then cv.imshow() never shows a window. However if you just do cv2.waitKey(1), it returns almost immediately (in 1ms), without actually waiting for user to press a key. This camera test works for me: import cv2 import jetson.inference import jetson.utils input\_stream = jetson.utils.videoSource("csi://0") while True: cuda\_img = input\_stream.Capture() jetson.utils.cudaDeviceSynchronize() print(cuda\_img) cv\_i…

…someone else may better advise.

---

<div class="post-metadata">

**Author:** ![terry.l.lee](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@terry.l.lee](https://forums.developer.nvidia.com/u/terry.l.lee)\
**Post date:** [September 25, 2020, 9:30pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/13 "2020-09-25T21:30:42Z")

</div>

Very helpful links. I did not know that you can use cuda to speed up the processing.  
The current openCV in the default install for me is: 4.1.1  
Would you need if openCV 4.4.0 version is needed for CUDA to work on openCV?

---

<div class="post-metadata">

**Author:** ![Honey\_Patouceul](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/honey_patouceul/32/389777_2.png) [@Honey\_Patouceul](https://forums.developer.nvidia.com/u/Honey_Patouceul)\
**Post date:** [September 26, 2020, 11:37am UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/14 "2020-09-26T11:37:52Z")

</div>

The opencv lib provided by JetPack doesn’t support CUDA. You have to build your own version enabling CUDA.  
Many opencv versions would work, but I’d suggest to use 4.4.  
You may try one of these scripts for downloading/building:

> **[GitHub - mdegans/nano\_build\_opencv: Build OpenCV on Nvidia Jetson Nano](https://github.com/mdegans/nano_build_opencv)**
>
> Build OpenCV on Nvidia Jetson Nano

> **[JEP/script at master · AastaNV/JEP](https://github.com/AastaNV/JEP/tree/master/script)**
>
> Contribute to AastaNV/JEP development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![terry.l.lee](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@terry.l.lee](https://forums.developer.nvidia.com/u/terry.l.lee)\
**Post date:** [September 27, 2020, 1:34am UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/15 "2020-09-27T01:34:45Z")

</div>

Thanks for sharing. It will save me a lot of time trying to find out.

---

<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 15, 2021, 4:11pm UTC](https://forums.developer.nvidia.com/t/ip-camera-connection-with-jetson-utils-gstcamera/155064/17 "2021-10-15T16:11:36Z")

</div>

Closed on October 15, 2021, 4:11pm UTC


