Hi @bcao ! I wonder if it is possible to do it using pad probe. I tried it with no success. My probe function and its resulting image is appended below. I would expect 1000x2000 → 500x2000 crop, rotate and scale to 1200x300 image output but I still get 1000x2000.
static GstPadProbeReturn
dewarper_src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
{
GstBuffer *buf = (GstBuffer *) info->data;
GstMapInfo outmap = GST_MAP_INFO_INIT;
gst_buffer_map (buf, &outmap, GST_MAP_WRITE);
NvBufSurface* surface = (NvBufSurface *)outmap.data;
NvBufSurfTransformRect src_rect, dst_rect;
src_rect.top = 0;
src_rect.left = 0;
src_rect.width = (guint) surface->surfaceList[0].width / 2;
src_rect.height= (guint) surface->surfaceList[0].height;
dst_rect.top = 0;
dst_rect.left = 0;
dst_rect.width = 1200;
dst_rect.height= 300;
NvBufSurface *dst_surface = NULL;
NvBufSurfaceCreateParams create_params;
create_params.gpuId = surface->gpuId;
create_params.width = 1200;
create_params.height = 300;
create_params.size = 0;
create_params.colorFormat = surface->surfaceList[0].colorFormat;
create_params.layout = surface->surfaceList[0].layout;
create_params.memType = surface->memType;
NvBufSurfaceCreate(&dst_surface,1,&create_params);
NvBufSurfTransformParams transform_params;
transform_params.src_rect = &src_rect;
transform_params.dst_rect = &dst_rect;
NvBufSurfTransformConfigParams transform_config_params;
NvBufSurfTransform_Error err;
transform_config_params.compute_mode = NvBufSurfTransformCompute_Default;
transform_config_params.gpu_id = surface->gpuId;
transform_config_params.cuda_stream = NULL;
transform_params.transform_flag = NVBUFSURF_TRANSFORM_CROP_SRC | NVBUFSURF_TRANSFORM_FLIP;
transform_params.transform_flip = NvBufSurfTransform_Rotate270;
err = NvBufSurfTransformSetSessionParams (&transform_config_params);
// crop and rotate 270 to dst surface
err = NvBufSurfTransform (surface, dst_surface, &transform_params);
if (err != NvBufSurfTransformError_Success) {
g_print("NvBufSurfTransform failed with error %d while converting buffer", err);
return GST_PAD_PROBE_DROP;
}
// copy back to original surface
transform_params.transform_flag = 0;
err = NvBufSurfTransform (dst_surface, surface, &transform_params);
if (err != NvBufSurfTransformError_Success) {
g_print("NvBufSurfTransform failed with error %d while converting buffer", err);
return GST_PAD_PROBE_DROP;
}
surface->surfaceList[0].height = 300;
surface->surfaceList[0].width = 1200;
NvBufSurfaceDestroy(dst_surface);
gst_buffer_unmap (buf, &outmap);
return GST_PAD_PROBE_OK;
}