Is it possible to encode a ROI in YUV video?

Please provide the following info:
Hardware Platform: DRIVE AGX Xavier™ Developer Kit
Software Version: DRIVE Software 10
Host Machine Version: native Ubuntu 18.04
SDK Manager Version: Example: 1.0.1.5538

Hi all,

We are interested in encoding with H265 but only in a specific ROI.
In the documentation, we saw the enableROIEncode property here: https://docs.nvidia.com/drive/nvvib_docs/NVIDIA%20DRIVE%20Linux%20SDK%20Development%20Guide/baggage/structNvMediaEncodeInitializeParamsH265.html

We tried in the source code by modifying the values in the Rect structure to define a ROI but this property didn’t work, the output has the same resolution as the input (1936x1216), just in case we are using NV12 images.

Then, I tried by also modifying the encodeHeight and encodeWidth to output 1280x720 and the output had this resolution but the image was the upper-left corner instead of lower-right (specified in ROI).
In other words, the encodeWidth and encodeHeight crop the image but always starting from top-left corner, the ROI parameters are not being used by the encoder.

Sample code, input is 1936x1216, output 1280x720 top-left:

ctx->configParams.encodeHeight = 720;
ctx->configParams.encodeWidth = 1280;

ctx->sourceRect.x0 = 656;
ctx->sourceRect.x1 = 1936;
ctx->sourceRect.y0 = 456;
ctx->sourceRect.y1 = 1216;
ctx->encoderInitParamsH265.enableROIEncode = 1;

ctx->testEncoder = NvMediaIEPCreate (ctx->device, NVMEDIA_IMAGE_ENCODE_HEVC, &ctx->encoderInitParamsH265, //init params
ctx->surfaceType, // inputFormat
ctx->maxInputBuffering, // maxInputBuffering
ctx->maxOutputBuffering, // maxOutputBuffering
ctx->instanceId);

ret = NvMediaIEPSetConfiguration (ctx->testEncoder, &ctx>configH265Params);

According to the methods used to configure the H265 encoded, how do we configure the ROI? The flag is not enabling the ROI, method documentation here: https://docs.nvidia.com/drive/nvvib_docs/NVIDIA%20DRIVE%20Linux%20SDK%20Development%20Guide/baggage/group__image__encode__api.html#ga621a4181548d8d04a142ef13297ab09f

From the examples, we found that you mention that the ROI feature only works for BGR, then, is the ROI feature not supported for NV12?

I know that the note there only mentions BGR but we are interested in any possible way to enable this operation. Encoder example documentation here: https://docs.nvidia.com/drive/active/5.1.0.2L/nvvib_docs/index.html#page/DRIVE_OS_Linux_SDK_Development_Guide%2FNvMedia%2Fnvmedia_nvmvid_enc.html%23

Thanks in advance.
Best Regards.

I previously asked about this. 5.15.2 documentation seems to have been updated as a result to mention that ROI encoding is “an internal feature”.

1 Like