How to Replace NvBufSurf using cv::Mat

Please provide complete information as applicable to your setup.

• Hardware Platform GPU
• DeepStream Version 6.1
• Issue Type questions

Hi there,
as @ fanzh suggested in this topic, I get everything inside nvinfer and do alignment successfully. Now I have two questions:
Q1: how can I cover original data in mem->surf?
I copy the data to host by

cudaMemcpy((void *)src_data,
        (void *)surface->surfaceList[frameIndex].dataPtr,
        surface->surfaceList[frameIndex].dataSize,
        cudaMemcpyDeviceToHost);

I convert src_data to a cv::Mat by

cv::Mat frame = cv::Mat((gint)surface->surfaceList[frameIndex].height, 
      (gint)surface->surfaceList[frameIndex].width, 
      CV_8UC3, src_data, 
      surface->surfaceList[frameIndex].pitch);

then I do alignment on the frame. after all, I get a finished cv:Mat suppose its name warpImg, I tried to copy the warpImg to cover the original data by

cudaMemcpy((void *)surface->surfaceList[frameIndex].dataPtr,
        warpImg.ptr(0),
        sizeInBytes,
        cudaMemcpyHostToDevice);

It fails of course. I find that the src_data from mem->surf is uncontinuous, for example, its pitch is 512, and its width is 112 as well as its channel 3. there is a gap at the end of each row. However, the warpImg is continuous as it calls cv::create.
So the question is: How to cover the original data.

Q2: How to make the crop object bigger?
I know that nvinfer use the bbox to crop object. However, I didn’t find relevant codes about the output resolution. for example, my trt model takes a 112*112 input, the output img’s resolution will be 112*112 too. How to change the output img bigger?

Hope you guys can give me some advice :-)

thanks in advance.

to get rid of the isContinuous problem, I use a loop to copy values from warpImg to frame, and as I save the frame to local, there is no problem and the frame is uncontinuous.
But after I try to copy the frame back to device by

cudaMemcpyAsync((void *)surface->surfaceList[frameIndex].dataPtr,
        frame.ptr(0),
        sizeInBytes,
        cudaMemcpyHostToDevice);

the mem->surf doesn’t change at all! the cudamemcpy returns 0 which indicates success. Why?

Hope you guys could give me some hints.

some references:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.