hi, i used the latest jetson multimedia api(38.2.0-20250821174705). but find sample12 displays garbled output on the monitor.
our camera’s output is 2592x1944 UYVY format, our monitor’s resolution is 1920x1080, i use below command
./v4l2_camera_cuda -d /dev/rear_camera -s 2592x1944 -f UYVY
it displayes garbled output on the monitor.
i also tried to modify egl render’s output resolution as 1920x1080, but not work, still displays garbled output.
below is the log output
/v4l2_camera_cuda -d /dev/rear_camera -s 2592x1944 -f UYVY
[INFO] (NvEglRenderer.cpp:110) Setting Screen width 2592 height 1944
WARN: request_camera_buff(): (line:359) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:359) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:359) Camera v4l2 buf length is not expected
WARN: request_camera_buff(): (line:359) Camera v4l2 buf length is not expected
^CQuit due to exit command from user!
please help analyze it .thx
i want to fulfil zero-copy function from camera dma-buf to cuda address. seems nvbuffer+egl_map already zero-copy. but i see NvBufSurfaceMapCudaBuffer() at jetson multimedia api, is that ok to fulfil zero-copy function with nvbuffer+NvBufSurfaceMapCudaBuffer?
Hi,
Data alignment of NvBufSurface is hard requirement. If you would like to avoid re-ordering frame data, please check if your data source can be adjusted to fit pitch, width, height of the NvBufSurface.
Hi,
our target is to fulfil zero-copy function from camera dma-buf to cuda address. i checked the patch, it use cuMemcpy2D to fix padding problem. is there any other method that can avoid to use cuMemcpy2D?
Hi,
If your frame data can fit pSurf->surfaceList[0].pitch and pSurf->surfaceList[0].width, you can eliminate calling cuMemcpy2D(). Please check if your data source can be adjusted to fit pitch, width, height of the NvBufSurface.
Hi,Dane
our camera resolution is 25921944, one line have 25922=5184 byte.
but nv buffer have 5376 byte(padding 192byte)
It seems that NvBuffer performs 256-byte alignment. Is this alignment value adjustable?
Hi, Dane
our camera is 2592x1944, and nv buf will padding the data to 2816*1952。seems camera don’t need to adjust, the only problem is how can cuda remove the padding efficiently? in your patch,cuMemcpy2d is a method, and cuda crop is another method. which method do you recommend and have the best performance?
Hi,
NvBufSurface is in 2816x1952 which is a hard requirement. So you would need to pad frame data into this data alignment. If frame data is in 2592x1944, hardware engines such as encoder or display controller cannot read it correctly, and you will see mis-ordering.
Hi,Dane
we don’t use camera data as encoder or display, we just use it with model inference, so if our frame data is 2592x1944, nvbufsurface is 2816x1952, and at cuda address side, we crop the size from 2816x1952 to 2592x1944, is that ok?
Hi, Dane
18_v4l2_camera_cuda_rgb is not zero-copy. below case seems like zero-copy, but i already test it with perf, it have many dcache operation that will takeup the cpu.
I almost tried all the samples of jetson_multimedia_api, seems NvBufSurface is the best method to fuiful zero-copy function.
Using Application-Allocated Buffers and Zero-Copy CUDA Memory (-u and -z options)
$ ./v4l2_camera_cuda_rgb -d /dev/video0 -u -z
userptr | | convert | | write
---------> || =========> || -------> file
|
kernel | user
Hi, Dane
I saw you mention data alignment many times, i am not sure whether my solution have problem, please help to check it.
our camera resolution is 2592x1944(camera don’t have padding function), if we use NvBufSurface, it will automaticlly padding to 2816x1952, now i know the display will mis-ordering, but we don’t use display, we just crop it from 2816x1952 to 2592x1944 with cuda kernel, after that gpu get the same image as the camera.
does this pipeline have some problem with the data alignment?
is there any example to use NvBufSurfaceMapCudaBuffer() api? i am not sure which address i should use?
typedef struct NvBufSurfaceMappedAddr {
/** Holds planewise pointers to a CPU mapped buffer. /
void * addr[NVBUF_MAX_PLANES];
/* Holds a pointer to a mapped EGLImage. /
void eglImage;
/ Holds a pointer to a mapped NVRM memory /
void nvmmPtr;
/ Holds a pointer to a mapped CUDA memory /
void cudaPtr;
/ Holds the reserved space for future use. */
void * _reserved[STRUCTURE_PADDING];
} NvBufSurfaceMappedAddr;