I’m using the below code to resize NvBuffer
bool PreviewConsumerThread::doResize(int inputFd, int *outputFdPtr) {
/* create resize NvBuffer */
NvBufferCreateParams resizeBufParams = {0};
int32_t resizeWidth = RESIZE_SIZE.width();
int32_t resizeHeight = RESIZE_SIZE.height();
resizeBufParams.payloadType = NvBufferPayload_SurfArray;
resizeBufParams.width = resizeWidth;
resizeBufParams.height = resizeHeight;
resizeBufParams.layout = NvBufferLayout_Pitch;
resizeBufParams.colorFormat = NvBufferColorFormat_ABGR32;
resizeBufParams.nvbuf_tag = NvBufferTag_NONE;
if (-1 == NvBufferCreateEx(outputFdPtr, &resizeBufParams)) {
printf("Failed to create resize NvBuffer\n");
return false;
}
/* do resize */
NvBufferTransformParams resizeTransParams;
memset(&resizeTransParams, 0, sizeof(resizeTransParams));
resizeTransParams.transform_flag = NVBUFFER_TRANSFORM_FILTER;
resizeTransParams.transform_filter = NvBufferTransform_Filter_Bilinear;
if (-1 == NvBufferTransform(inputFd, *outputFdPtr,
&resizeTransParams)) {
printf("Failed to convert the resize buffer\n");
return false;
}
return true;
}
it works well if my target size is > 240x136. If width is <= 240 or height <= 136, it will just throw
NvDdkVicConfigure Failed
nvbuffer_transform Failed
My input image is 3864x2180, I roughly calculated the ratio is around 16 for both width and height. Is this a hard limit for the algorithm? When I’m using opencv resize with bilinear interpolation, it’s ok to resize to any image size. Not sure what’s the rationale behind this implementation.