During the migration from DeepStream 6.3 to 6.4, the dataSize attribute of surface->surfaceList[frame_meta->batch_id] changed

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 6.4
• TensorRT Version 8.6.1.6
• NVIDIA GPU Driver Version (valid for GPU only) 535.183.01 / CUDA 12.2
• Issue Type( questions, new requirements, bugs) questions

deepstream use:

GstMapInfo in_map_info;
    if (!gst_buffer_map(buf, &in_map_info, GST_MAP_READ)) {
        g_print("Error: Failed to map gst buffer\n");
        gst_buffer_unmap(buf, &in_map_info);
        return FALSE;
    }
    NvBufSurface* surface = (NvBufSurface*)in_map_info.data;
    cudaMemcpy(image, (void*)surface->surfaceList[frame_meta->batch_id].dataPtr, surface->surfaceList[frame_meta->batch_id].dataSize, cudaMemcpyDeviceToHost);
    gst_buffer_unmap(buf, &in_map_info);

server side:

ori = cv::Mat(IMAGE_HEIGHT * 1.5, IMAGE_WIDTH, CV_8UC1, (void *)image);

cv::cvtColor(ori, converted_mat, cv::COLOR_YUV2RGB_NV21);

In version 6.3, everything worked correctly, but during the migration to version 6.4, the dataSize value of surface->surfaceList[frame_meta->batch_id] changed from 1280 x 720 x 1.5 to 1280 x 720 x 1.8. The pitch size also changed from 1280 to 1536. Is there anything I might have missed?

yes, dataSize and pitch maybe will change. but the actual picture data is fixed. is there any bug caused by dataSize and pitch changing?

I didn’t have any issues saving images on the server side. However, after migrating to version 6.4 and adjusting the code to match the new dataSize,

deepstream use:

    GstMapInfo in_map_info;
    if (!gst_buffer_map(buf, &in_map_info, GST_MAP_READ)) {
        g_print("Error: Failed to map gst buffer\n");
        gst_buffer_unmap(buf, &in_map_info);
        return FALSE;
    }
    NvBufSurface* surface = (NvBufSurface*)in_map_info.data;
    cudaMemcpy(image, (void*)surface->surfaceList[frame_meta->batch_id].dataPtr, surface->surfaceList[frame_meta->batch_id].dataSize, cudaMemcpyDeviceToHost);
     // ds 6.3 dataSize -> 1280 * 720 * 1.5, ds 6.4 dataSize -> 1280 * 720 * 1.8
    gst_buffer_unmap(buf, &in_map_info);

server side:

// match dataSize
ori = cv::Mat(IMAGE_HEIGHT * 1.8, IMAGE_WIDTH, CV_8UC1, (void *)image);

cv::cvtColor(ori, converted_mat, cv::COLOR_YUV2RGB_NV21);

the resulting image looks like this

I am encountering problems with changing the color format. Could you please provide some advice?

if pitch is not equal to width, you need to remove the padding part. please refer to this faq for how to dump nv12 nvbufsurface. please refer to this topic for how to dump by opencv.

Thank you.

// pitchSize 1536
ori = cv::Mat(IMAGE_HEIGHT * 1.5, IMAGE_WIDTH, CV_8UC1, (void *)image, pitchSize);

cv::cvtColor(ori, converted_mat, cv::COLOR_YUV2RGB_NV21);

I resolved the issue by keeping the original height * 3/2 and width the same, and adjusting the pitch size.

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