To Substitute nvinfer->input_tensor_from_meta

Hardware Platform (Jetson / GPU) NX
• DeepStream Version 6.01
• JetPack Version (valid for Jetson only) 4.6
• TensorRT Version 8.0
I want to use a rectangle area of the input tensor for real inference, and the rectangle position and size depends the input tensor itself. So firstly I need to copy the tensor from GPU and calculate the rectangle, then I should put the data in the rectangle back to GPU(nvinfer->input_tensor_from_meta ?) . Simply speaking, to substitue the original meta_data just before inference.
Please tell me how to do. in gst-nvinfer.cpp or in gstnvdspreprocess.cpp?
And, on YUY2 usb input, what’s the colorformat?
switch (init_params->networkInputFormat) {
case NvDsInferFormat_RGB:
case NvDsInferFormat_BGR:
if(nvinfer->transform_config_params.compute_mode == NvBufSurfTransformCompute_VIC) {
color_format = NVBUF_COLOR_FORMAT_RGBA;
}
else {
color_format = NVBUF_COLOR_FORMAT_RGB;
}
break;
case NvDsInferFormat_GRAY:
if(nvinfer->transform_config_params.compute_mode == NvBufSurfTransformCompute_VIC) {
color_format = NVBUF_COLOR_FORMAT_NV12;
}
else {
color_format = NVBUF_COLOR_FORMAT_GRAY8;
}

Does that mean YUY2---->GRAY8 or NV12 ?

====>Please tell me how to do. in gst-nvinfer.cpp or in gstnvdspreprocess.cpp?
You can use the preprocess to customize your input.
https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvdspreprocess.html
====>Does that mean YUY2---->GRAY8 or NV12 ?
No, it’s type of YUV4:2:2, UYUV. You can refer the link below:
https://forums.developer.nvidia.com/t/nvvideoconvert-uyvy-support-on-xavier/81626#5387008

thank you for quick reply

I am testing nvdspreprocess plugin on jetson nx, but it displays:
(p3) shisun@nx:/opt/nvidia/deepstream/deepstream-6.0/sources/gst-plugins/gst-nvdspreprocess$ gst-launch-1.0 uridecodebin uri= file:///samples/streams/sample_1080p_h264.mp4 ! m.sink_0 nvstreammux name=m batch-size=1 width=1920 height=1080 ! nvdspreprocess config-file=config_preprocess.txt ! nvinfer config-file-path=config_infer.txt input-tensor-meta=1 batch-size=1 ! nvmultistreamtiler width=1920 height=1080 ! nvvideoconvert ! nvdsosd ! nvvideoconvert ! nveglglessink
Failed to load config file: No such file or directory
** ERROR: <gst_nvinfer_parse_config_file:1303>: failed
WARNING: erroneous pipeline: no element “nvdspreprocess”

I think it needs to compile nvdspreprocess.cpp. so,
shisun@nx:/opt/nvidia/deepstream/deepstream-6.0/sources/gst-plugins/gst-nvdspreprocess$ make
-fPIC -DHAVE_CONFIG_H -std=c++17 -Wall -Werror -DDS_VERSION=“6.0.0” -I /usr/local/cuda-10.2/include -I include -I …/…/includes -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include
g++ -o libnvdsgst_preprocess.so gstnvdspreprocess.o gstnvdspreprocess_allocator.o nvdspreprocess_property_parser.o -shared -Wl,-no-undefined -L/usr/local/cuda-10.2/lib64/ -lcudart -ldl -L/opt/nvidia/deepstream/deepstream-6.0/lib/ -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta -lnvbufsurface -lnvbufsurftransform -lcuda -Wl,-rpath,/opt/nvidia/deepstream/deepstream-6.0/lib/ -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0
gstnvdspreprocess.o: In function batch_transformation(NvBufSurface*, NvBufSurface*, CustomTransformParams&)': gstnvdspreprocess.cpp:(.text+0x4788): undefined reference to NvBufSurfTransformAsync’
gstnvdspreprocess.o: In function gst_nvdspreprocess_on_frame(_GstNvDsPreProcess*, _GstBuffer*, NvBufSurface*)': gstnvdspreprocess.cpp:(.text+0x68b0): undefined reference to NvBufSurfTransformSyncObjWait’
gstnvdspreprocess.cpp:(.text+0x68bc): undefined reference to `NvBufSurfTransformSyncObjDestroy’
collect2: error: ld returned 1 exit status
Makefile:80: recipe for target ‘libnvdsgst_preprocess.so’ failed
make: *** [libnvdsgst_preprocess.so] Error 1

What’s the problem please? or can DS6.0 apply the preprocess plug-in?
Thank you.

You can check it in your env.
1.use gst-inspect-1.0 nvdspreprocess cli
2.check the libnvdsgst_preprocess.so in the /opt/nvidia/deepstream/deepstream-6.1/lib path

Thank you.