We are using CSI camera on Orin NX, using V4L2 to interface the camera. The pixel format set to is JXY2 12/16 bit, and the frames are put in cv::Mat with OpenCV CV_16UC1. Can you please help to understand how this 12 bit is encoded to 16 bit, I see the decimal range of these images are ranging from 8 to 32759 (in bits: 1000 to 111111111110111) (black to white). Its neither in the16 bit range of 0 to 65535 nor 12 bit of 0 to 4096. It would be great if someone could throw light on this.
I still don’t understand what’s JXY2 format types looks like,
this is not a default format, please refer to public sources for v4l2 pixel formats,
for example, $public_sources/kernel_src/kernel/kernel-5.10/include/uapi/linux/videodev2.h
Thank you for the information. I am using Allied vision alvium 1800c-319m camera, and whose v4l2 --list-formats-ext for 12 bit is what the picture above shows.
When I change it to a default format Y12, the set format is not reflected (though no error is thrown with the set) and shows the previous pixel format itself.
"
struct v4l2_format format;
ioctl(fd, VIDIOC_G_FMT, &format);
printf(“Current Pixel Format: %c%c%c%c\n”,
format.fmt.pix.pixelformat & 0xFF,
(format.fmt.pix.pixelformat >> 8) & 0xFF,
(format.fmt.pix.pixelformat >> 16) & 0xFF,
(format.fmt.pix.pixelformat >> 24) & 0xFF); // This outputs Current Pixel Format: GREY (because previously this format was set)
format.fmt.pix.pixelformat = v4l2_fourcc(‘Y’, ‘1’, ‘2’, ’ '); //format.fmt.pix.pixelformat = V4L2_PIX_FMT_Y12; // tried this too
if (ioctl(fd, VIDIOC_S_FMT, &format) == -1) {
perror(“Failed to set format”);
close(fd);
}
printf(“New Pixel Format: %c%c%c%c\n”,
format.fmt.pix.pixelformat & 0xFF,
(format.fmt.pix.pixelformat >> 8) & 0xFF,
(format.fmt.pix.pixelformat >> 16) & 0xFF,
(format.fmt.pix.pixelformat >> 24) & 0xFF); // This outputs Current Pixel Format: GREY (though it is changed to Y12)
"
whereas v4l2_fourcc(‘J’, ‘X’, ‘Y’, '2 ') is accepted and it changes the pixel format, and in which I see the range of 0 to 32579 neither 12 bit range nor 16 bit range.
please refer to Orin TRM for [2.4.5 RAW Memory Formats]. the data is in MSBs and LSBs are replicated from MSBs.
FYI, Orin series using T_R16 to handle Raw10, it is a 16-bit unsigned word format, packing two per 32-bit word.
there’re some MSBs replicated.