Trying to understand jetson.utils.gstCamera

I have previously tinkered with images using OpenCV (like cropping an image, change to gray scale or draw squares and texts), but I am still new to jetson.utils.gstCamera.

Are there any ways to

  1. crop img, from the image obtained from:
    camera = jetson.utils.gstCamera(1280,720,‘/dev/video0’)
    img, width, height = camera.CaptureRGBA()
    I have tried img=img[x1:x2,y1:y2] but doesn’t work. Is it related to CUDA images?
    is there any way to convert them to a format that can be handled using OpenCV commands?

  2. draw a square or text similar to cv2 commands
    cv2.rectangles(image,point1,point2,color,thickness)
    cv2.putText(image,text,point,font,…)

Any help would be greatly appreciated
Thank you in advance

Hi,
We suggest check the source code gstCamera.pp in

Around line #144, you can see it is to launch a gstreamer pipeline. For customization, you can leverage gstreamer plugins. Please check gstreamer user guide. For doing crpping/scaling/format conversion, you can use nvvidconv plugin.

If your usecase is to run deep learning inference, suggest you check DeepStream SDK.

After the installation, you can see samples in

/opt/nvidia/deepstream/deepstream-5.0/

Please take a look and give it a try.

1 Like

Dear DaneLLL

Thank you for your help and for the link.
I will have a look at it and probably be back with a ton of questions!

Thank you again!!

Hi again,
Quick one: by any chance is it possible to get the module or a user guide for python?

@skillet, instead of using gstCamera directly, I would recommend migrating to using the newer videoSource API from jetson-inference - see here for more info:

There are some Python CUDA-based functions available for cropping, color conversion, resizing, ect that you can see used in the cuda-examples.py sample. For more info, see here:

https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-image.md

To pass the image buffer to cv2, use the cudaToNumpy() function:

https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-image.md#converting-to-numpy-arrays

1 Like

Thanks again, man!
Will try it and let you know how it went.
Cheers!!

Follow up!
It worked great!! Managed to crop the image and perform a simple test!
I really would not have managed that without your help.
Thanks a LOT!