Hardware Accelerated JPEG encode/decode on Jetson Xavier JP 5.1.3

Hi,
Hardware JPEG encoder supports YUV420 format, so possible solution will be like:

  1. Allocate NvBufSurface in YUV420
  2. Allocate NvBufSurface in RGBA and map to gpuMat
  3. Convert data from BGR gpuMat to the NvBufSurface in RGBA
  4. Call NvBufsurfTransform() to convert NvBufSurface in RGBA to NvBufSurface in YUV420
  5. Encode the NvBufSurface in YUV420

Please refer to the sample for mapping NvBufSurface in RGBA to gpuMat:
Error generated while running the code after connecting the camera - #15 by DaveYYY