Camera Capture YUV: Jetson-utils

Hi,

I will work in future with a YUV Camera and my aim is to display the pictures in a fast way and use opencv functions.
I already used the Capture function of jetson-inference for decode mp4-videos. My question is now concerning this link jetson-inference/aux-image.md at master · dusty-nv/jetson-inference · GitHub under “IMAGE FORMAT”. There it is said that a “variety of other format are defined for image acquisition” including YUV fomats.
But also the Capture function of jetson-utils just accepts RGB formats.
That is my question. Can the Capture function can be fixed that it accepts YUV formats?
If NOT: What would be another approach to reach my aim? If anyone is experienced with that, I am very glad to get more information of how fixing this.

The question is similar to this one - How to convert yuv to rgb8/rgb8a/rgb32/rgb32f to use Imagenet/detectnet/segnet in jetson-inference - but I can not take a solution from the answer. Therefor please give me more detailed help.
I am looking forward to your help!

Best greetings, J. W.

I suggest asking this question on one of the Jetson forums.

1 Like

Hi @user152011, jetson-utils should handle cameras that transmit video in YUV formats, and typically it converts these to an RGB/RGBA format in the Capture() function. Are you saying that you want the YUV data returned from Capture() ?

I haven’t really tested that use-case, but I traced the code again and it looks like you can request any IMAGE_FORMAT that the cudaConvertColor() function supports the conversion of: jetson-utils/gstBufferManager.cpp at 8b6c5ca4b2b52d51f5415ce033ee52563ddf3f2c · dusty-nv/jetson-utils · GitHub

Seeing as cudaConvertColor() doesn’t support converting YUV formats to other YUV formats (only YUV->RGB/RGBA), I would request the original YUV format the pipeline uses such that no colorspace conversion is required.

1 Like

Hi dusty_nv!

Thank you for your answer! First of all it seems to be good news! But I have to try! I will reply here if the topic will be still open (It could take more than 14 days).

  • Yes. So the input is YUV 4:2:2 and in the end I would like to have to have a YUV format that can be split in 3 channels by OpenCV. But if I understand your last sentence correctly, it is not possible to convert YUV 4:2:2 into such a more handy YUV format, right?

Does it mean that I have to comment the marked line 435 and instead I return the latestYUV which has then the YUV 4:2:2 format? But then I don’t receive YUV in 3 channels, do I?

One question beyond that: Why is the NV12 format used by the Capture function? For me it seems like a temporary format as well the input format is RGB or YUV. The command to use NV12 is given by the gstreamer pipeline jetson-utils/gstCamera.cpp at 8b6c5ca4b2b52d51f5415ce033ee52563ddf3f2c · dusty-nv/jetson-utils · GitHub , is that correct?

Thank you again! I am looking forward to your answer!

It appears in the source of cudaConvertColor(), there is RGB/RGBA → I420 and RGB/RGBA → YV12 implemented. There is no cross-YUV conversion, but you could request RGB8 for example from Capture(), then use cudaConvertColor() to convert it to I420/YV12 if those are friendlier formats for you.

The CSI and hw decoder elements use NV12 so it skips the temporary format conversion by reading it directly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.