Nvv4l2camerasrc distorted image

I am trying nvv4l2camerasrc (patched to report YUYV/YUY2) with a USB camera, and not getting correct result. In fact, the video acquired is shown as attached (me shaking my head).

As you can see, moving objects in the frame dislayed with noise (looks like they are sliced horizontally, and half of the slices appear immediately and the rest appears 0.5-1 sec delayed).

I am using jetson nano board, jetpack 4.6.1.
The pipelines I am using is as follows.

Only the nvv4l2camerasrc one has this problem, but v4l2src one does not have it (displayed fine).

Any idea?

  1. nvv4l2camerasrc version (has this problem):

$ gst-launch-1.0 nvv4l2camerasrc device=“/dev/video1” bufapi-version=false !
“video/x-raw(memory:NVMM), ${size}, format=(string)YUY2,
interlace-mode=(string)progressive,${fps}” !
nvvidconv ! ‘video/x-raw, format=(string)YUY2’ !
videoconvert !
xvimagesink

  1. v4l2src version (no problem):

$ gst-launch-1.0 v4l2src device=“/dev/video1” !
“video/x-raw, ${size}, format=(string)YUY2,
interlace-mode=(string)progressive,${fps}” !
nvvidconv ! ‘video/x-raw, format=(string)YUY2’ !
videoconvert !
xvimagesink

same result with below a bit simpler pipeline.
problem happenig in nvv4l2camerasrc?

$ v4l2-ctl -v pixelformat=YUYV
$ gst-launch-1.0 nvv4l2camerasrc device=“/dev/video1” !
“video/x-raw(memory:NVMM),${size},format=(string)YUY2” !
nvvidconv ! ‘video/x-raw(memory:NVMM),format=(string)I420’ !
nv3dsink

Hi,
Please try the jetson_multimedia_api sample and check if the issue is present:

/use/src/jetson_multimedia_api/samples/12_camera_v4l2_cuda

Would like to know if the sample works.

Hello.
Just tried: below is ok, no distortion.

$ ./camera_v4l2_cuda -d /dev/video1

Hi,
Please call NvBufferMemSyncForDevice() after ioctl(VIDIOC_DQBUF) and rebuild/replace

/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvv4l2camerasrc.so

The source code of nvv4l2camerasrc plugin is in
Jetson Linux R32.7.1 Release Page | NVIDIA Developer

L4T Driver Package (BSP) Sources

Please follow README to built it.

Thanks for the comment.
Not being sure doing it right, I put below just after ioctl(VIDIOC_DQBUF) call (only one place in the plugin source).

/* #### */
NvBufferMemSyncForDevice(nv_mem->nvcam_buf->dmabuf_fd, 0, (void *)&nv_mem->nvcam_buf->buffer);
/
#### */

However, I now seeing below errors on terminal, and displayed image is not fixed (same as before).

NvMapMemCacheMaint:1075334668 failed [99]
NvMapMemCacheMaint:1075334668 failed [99]
NvMapMemCacheMaint:1075334668 failed [99]
NvMapMemCacheMaint:1075334668 failed [99]
NvMapMemCacheMaint:1075334668 failed [99]
NvMapMemCacheMaint:1075334668 failed [99]
NvMapMemCacheMaint:1075334668 failed [99]
NvMapMemCacheMaint:1075334668 failed [99]

Hi,
(void **)&nv_mem->nvcam_buf->buffer is not correct. Please call NvBufferMemMap() to get the pointer and pass it to NvBufferMemSyncForDevice()

Hello, thanks.

I stole code from

jetson_multimedia_api/samples/12_camera_v4l2_cuda/camera_v4l2_cuda.cpp
nvbuff_do_cleachroma()

and it fixed the problem.

Looks like calling either or both of NvBufferMemSyncForCpu() or NvBufferMemSyncForDevice() fixes the problem.
What is the right way (calling both or which one)?

Hi,
Please only call NvBufferMemSyncForDevice()

ok, thanks

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