I want to create a NvBuffer, and wrap it with a VPIImage to use with stereoDisparity.
Looking here https://docs.nvidia.com/vpi/algo_stereo_disparity.html I see that VPI disparity requires a disparity output of VPI_IMAGE_FORMAT_Y16_ER_BL, but looking here https://docs.nvidia.com/jetson/l4t-multimedia/nvbuf__utils_8h_source.html I don’t see an equivalent color type. I need it to output 16B so as to not lose subpixel information in the disparity, so I can’t just convert to GRAY8.
NvBuffer doesn’t support Y16 ER BL.
You can add some post-processing before wrapping it to NvBuffer format.
For example, we apply the below conversion before exporting the disparity to Y8.
cvDisparity.convertTo(cvDisparity, CV_8UC1, 255.0 / (32 * stereoParams.maxDisparity), 0);
Yes, I could do that but if I use Y8 then I lose the subpixel information from disparity. I need to either store it as floating point, or 16 bit to keep the subpixel information.
Disparity from VPI is scaled by 32, as there are 32 subdivisions per pixel. That means the output range of the disparity is 32*max_disp, which is greater than can be saved in 8 bits
You can work with the output GPU buffer directly so you don’t need to cast it into Y8.