Please provide complete information as applicable to your setup.
**• Hardware Platform (Jetson / GPU) Jeson TX2
**• DeepStream Version 5.0
• JetPack Version (valid for Jetson only)
**• TensorRT Version 7.0.1
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
static void bbox_generated_probe_after_pgie(AppCtx *appCtx, GstBuffer *buf,
NvDsBatchMeta *batch_meta, guint index)
{
printf(“bbox_generated_probe_after_pgie … \n”);
NvBufSurface *input_buf = NULL;
GstMapInfo in_map_info;
memset (&in_map_info, 0, sizeof (in_map_info));
if (!gst_buffer_map (buf, &in_map_info, GST_MAP_READ)) {
g_print (“Error: Failed to map gst buffer\n”);
//goto error;
}
input_buf = (NvBufSurface *) in_map_info.data;
NvDsObjectMeta *obj_meta = NULL;
NvDsMetaList *l_frame = NULL;
NvDsMetaList *l_obj = NULL;
// 遍历batch 所有frame
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next)
{
printf("00000 \n");
NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);
int batch_id = frame_meta->batch_id;
guint num_rects = 0;
// 遍历所有的检测目标对象
for (l_obj = frame_meta->obj_meta_list; l_obj != NULL; l_obj = l_obj->next)
{
obj_meta = (NvDsObjectMeta *)(l_obj->data);
num_rects++;
printf("obj_meta->class_id = %d \n", obj_meta->class_id);
/* Conditions that user needs to set to encode the detected objects of
* interest. Here, by default all the detected objects are encoded.
* For demonstration, we will encode the first object in the frame */
if (obj_meta->class_id == 0)
{
NvBufSurfTransform_Error err;
NvBufSurfTransformConfigParams transform_config_params;
NvBufSurfTransformParams transform_params;
NvBufSurfTransformRect src_rect;
NvBufSurfTransformRect dst_rect;
NvBufSurface ip_surf;
cv::Mat in_mat;
ip_surf = *input_buf;
NvBufSurface *_tmp_surf;
NvBufSurfaceCreateParams create_params;
/* An intermediate buffer for NV12/RGBA to BGR conversion will be
* required. Can be skipped if custom algorithm can work directly on NV12/RGBA. */
create_params.gpuId = 0;
create_params.width = 600;
create_params.height = 600;
create_params.size = 0;
create_params.colorFormat = NVBUF_COLOR_FORMAT_RGBA;
create_params.layout = NVBUF_LAYOUT_PITCH;
create_params.memType = NVBUF_MEM_DEFAULT;
if (NvBufSurfaceCreate (&_tmp_surf, 1,
&create_params) != 0) {
GST_ERROR ("Error: Could not allocate internal buffer for dsexample");
}
ip_surf.numFilled = ip_surf.batchSize = 1;
ip_surf.surfaceList = &(input_buf->surfaceList[batch_id]);
gint src_left = GST_ROUND_UP_2((unsigned int)obj_meta->detector_bbox_info.org_bbox_coords.left);
gint src_top = GST_ROUND_UP_2((unsigned int)obj_meta->detector_bbox_info.org_bbox_coords.top);
gint src_width = GST_ROUND_DOWN_2((unsigned int)obj_meta->detector_bbox_info.org_bbox_coords.width);
gint src_height = GST_ROUND_DOWN_2((unsigned int)obj_meta->detector_bbox_info.org_bbox_coords.height);
cudaStream_t cuda_stream;
printf("input_buf->gpuId = %d \n", input_buf->gpuId);
cudaSetDevice(input_buf->gpuId);
cudaStreamCreate (&cuda_stream);
/* Configure transform session parameters for the transformation */
transform_config_params.compute_mode = NvBufSurfTransformCompute_Default;
transform_config_params.gpu_id = 0;
transform_config_params.cuda_stream = cuda_stream;
/* Set the transform session parameters for the conversions executed in this
* thread. */
err = NvBufSurfTransformSetSessionParams (&transform_config_params);
if (err != NvBufSurfTransformError_Success) {
//goto error;
}
/* Set the transform ROIs for source and destination */
src_rect = {(guint)src_top, (guint)src_left, (guint)src_width, (guint)src_height};
dst_rect = {0, 0, (guint)src_width, (guint)src_height};
/* Set the transform parameters */
transform_params.src_rect = &src_rect;
transform_params.dst_rect = &dst_rect;
transform_params.transform_flag =
NVBUFSURF_TRANSFORM_FILTER | NVBUFSURF_TRANSFORM_CROP_SRC |
NVBUFSURF_TRANSFORM_CROP_DST;
transform_params.transform_filter = NvBufSurfTransformInter_Default;
/* Memset the memory */
NvBufSurfaceMemSet (_tmp_surf, 0, 0, 0);
printf("2222 src_left = %d %d %d %d \n", src_left, src_top, src_width, src_height);
/* Transformation scaling+format conversion if any. */
err = NvBufSurfTransform (&ip_surf, _tmp_surf, &transform_params);
if (err != NvBufSurfTransformError_Success) {
//goto error;
}
/* Map the buffer so that it can be accessed by CPU */
if (NvBufSurfaceMap (_tmp_surf, 0, 0, NVBUF_MAP_READ) != 0){
//goto error;
}
/* Cache the mapped data for CPU access */
NvBufSurfaceSyncForCpu (_tmp_surf, 0, 0);
printf("3333 \n");
/* Use openCV to remove padding and convert RGBA to BGR. Can be skipped if
* algorithm can handle padded RGBA data. */
in_mat =
cv::Mat (src_height, src_width,
CV_8UC4, _tmp_surf->surfaceList[0].mappedAddr.addr[0],
_tmp_surf->surfaceList[0].pitch);
cv::Mat out_mat =
cv::Mat (cv::Size(src_width, src_height), CV_8UC3);
cv::cvtColor (in_mat, out_mat, cv::COLOR_RGBA2BGR);
static guint cnt = 0;
printf("write %d jpg \n", cnt);
cv::imwrite("imgs/out_" + std::to_string (cnt) + ".jpg", out_mat);
cnt++;
if (NvBufSurfaceUnMap (_tmp_surf, 0, 0)){
//goto error;
}
NvBufSurfaceUnMap(&ip_surf, 0, 0);
NvBufSurfaceDestroy(_tmp_surf);
cudaStreamDestroy (cuda_stream);
}
}
}
gst_buffer_unmap(buf, &in_map_info);
}
when invoke imwrite function cause crash. the logs like this:
write 0 jpg
Illegal instruction (core dumped)