How do I make the nvv4l2camerasrc plugin for gst-lanch-1.0 support the gray12 format?

I have a developer suite of agx orin, which connects to the black and white imx565 sensor through CSI, and can capture raw data using v4l2-ctl. However, due to the requirement of the project function, hardware acceleration is required, so the nvv4l2camerasrc plug-in of gstream should be used. But it does not support gray12 format, how to customize the nvv4l2camerasrc plugin to support gray12.
I refer to the following link, after some modifications still can not crawl, the error is as follows:
Gstnvv4l2camerasrc with GRAY8 support - Jetson Xavier NX - NVIDIA Developer Forums
Macrosilicon USB - Jetson & Embedded Systems / Jetson Nano - NVIDIA Developer Forums
erro:
xxx@xxx-desktop:~$ gst-launch-1.0 nvv4l2camerasrc num-buffers=1 device=/dev/video0 ! ‘video/x-raw(memory:NVMM),format=GRAY12,width=4128,height=3008,framerate=29/1’ ! fakesink
WARNING: erroneous pipeline: could not link nvv4l2camerasrc0 to fakesink0, nvv4l2camerasrc0 can’t handle caps video/x-raw(memory:NVMM), format=(string)GRAY12, width=(int)4128, height=(int)3008, framerate=(fraction)29/1

gstnvv4l2camerasrc.cpp

/* Capture caps of plugin */
#define CAPTURE_CAPS \
  "video/x-raw(memory:NVMM), " \
  "width = (int) [ 1, MAX ], " \
  "height = (int) [ 1, MAX ], " \
  "format = (string) { GRAY12 }, " \
  "interlace-mode = (string) { progressive, interlaced }, " \
  "framerate = (fraction) [ 0, MAX ];"
  NvBufSurfaceAllocateParams param = {{0}};
  param.params.width = self->width;
  param.params.height = self->height;
  param.params.layout = NVBUF_LAYOUT_PITCH;
  param.params.memType = NVBUF_MEM_DEFAULT;
  param.params.gpuId = 0;
  param.params.colorFormat = NVBUF_COLOR_FORMAT_GRAY12;

nvbufsurface.h

  NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_709,
  /** Specifies Non-linear RGB BT.2020 colorspace - BGRA-10-10-10-2 planar. */
  NVBUF_COLOR_FORMAT_BGRA_10_10_10_2_2020,
  /** Specifies Optical flow SAD calculation Buffer format */
  NVBUF_COLOR_FORMAT_A32,
  /** Specifies BT.601 colorspace - 10 bit YUV 4:2:2 interleaved. */
  NVBUF_COLOR_FORMAT_UYVP,
  /** Specifies BT.601 colorspace - 10 bit YUV ER 4:2:2 interleaved. */
  NVBUF_COLOR_FORMAT_UYVP_ER,
  NVBUF_COLOR_FORMAT_GRAY12,
  NVBUF_COLOR_FORMAT_LAST
} NvBufSurfaceColorFormat;

Please help me.

Hi,
GRAY12 is not supported in NvBufSurface. We support NVBUF_COLOR_FORMAT_GRAY8. Please check if your source supports GRAY8 or other NvBufSurface format.

We currently only use 12bit data, is there a way to modify gstream or nvv4l2camerasrc source code to achieve rggb12 or gray12

xxx@xxx-desktop:~/work/1.16.3$ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'RG12' (12-bit Bayer RGRG/GBGB)
                Size: Discrete 4128x3008
                        Interval: Discrete 0.034s (29.000 fps)

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