Hi all,
I’m really new to CUDA and such low level API, so would need to ask some help to get around.
Im trying to overlay text on CUeglFrame using the nvivafilter (my goal is very simple: white text on semi transparent light grey background over live video).
I started from an example from “nvsample_cudaprocess” in “source_release.tbz2” found here: GStreamer videocuda and nvivafilter plugins source code
In the code in case of CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR format it gets a reference to the CUeglFrame’s frame.pPitch and then manipualtes a given pixel like this:
char * pElement = (char*)pDevPtr + row * pitch + col * 2;
pElement[0] = 0;
pElement[1] = 0;
Based on some documentation I found here:
https://docs.nvidia.com/cuda/cuda-driver-api/structCUeglFrame__v1.html#structCUeglFrame__v1
and here:
https://docs.nvidia.com/cuda/archive/10.2/cuda-driver-api/structCUeglFrame.html
I guess these attributes are the U and V components of a pixel represented in YUV format. But I was not able to find much more information and whats even more worrisome for me is that there is no ‘frame’ property in the CUeglFrame struct based on the documentation.
Is there any more descriptive documentation about this topic or a developer guide / some kind of tutorial? Or maybe some example code out there?
Thanks in advance!
Bests,
Peter
Hi,
We have sample code in jetson_multimedia_api. Please check
nvidia@dhcp-10-19-107-227:~$ ls /usr/src/jetson_multimedia_api/samples/common/algorithm/cuda/
Makefile NvAnalysis.cu NvAnalysis.h NvCudaProc.cpp NvCudaProc.h
Yo can run the sample and check
/usr/src/jetson_multimedia_api/samples/03_video_cuda_enc
Hi,
I looked around these places and there are a lot of useful stuff! Thanks!
However as I see those examples are using frames with RGB and BGR color encoding I did not see any mentions of YUV.
Also as I see it operates on eglFrame.frame.pPitch[0] where in my case with the YUV the example codes are using eglFrame.frame.pPitch[1], however I still not found any convincing documentation I guess pPitch’s element at index 0 corresponds to RGB color space and the on the index 1 it is YUV.
I would be assured if I would have some documentation which describes this eglFrame.frame type and its values (based on my experiments and the code snippets I saw I believe if the eglColorFormat is CU_EGL_COLOR_FORMAT_RGBA the I should care about the frame.pPitch[0] and if the format is CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR then I found the data in frame.pPitch[1] but this is just speculation :D )
I saw the following definition for ‘CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR’ in:
Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio
same as YUV420Planar.
So does it mean that eglFrame.frame.pPitch[0] is the Y component and the eglFrame.frame.pPitch[1][0] and eglFrame.frame.pPitch[1][1] are the V and U components respectively?
Thanks for the help!
Bests,
Peter
Hi,
RGB/BGR format is not supported on Jetson platforms. 24-bit BGR is not supported. It is limitation of hardware VIC engine. Please use RGBA.
For CU_EGL_COLOR_FORMAT_YUV420_SEMIPLANAR, It is two-plane format. Y data is in one plane and UY data is in the other plane. Data pointer to Y plane is frame.pPitch[0], an dpointer to UY plane is frame.pPitch[1].
1 Like
Thanks DaneLLL! Then it seem my theory was kind of on point :D
Can you link a some documentation which describes these data structures? I mean the closest thing I found was from Rice but I guess it would be better to have this information from the NVidia directly.