Skip to content

Commit

Permalink
#43 use egl mapping in preprocessing and nms
Browse files Browse the repository at this point in the history
  • Loading branch information
tomskikh committed Jan 31, 2023
1 parent e317621 commit c8a09ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions libs/savantboost/pysavantboost/src/nms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace pysavantboost {

gst_buffer_map(buffer, &inmap, GST_MAP_READ);
auto *inputnvsurface = reinterpret_cast<NvBufSurface *>(inmap.data);
DSCudaMemory ds_cuda_memory = DSCudaMemory(inputnvsurface, 0);
DSCudaMemory ds_cuda_memory = DSCudaMemory(inputnvsurface, true);
gst_buffer_unmap(buffer, &inmap);

int frame_height = (int) inputnvsurface->surfaceList[batchID].planeParams.height[0];
Expand Down Expand Up @@ -98,4 +98,4 @@ namespace pysavantboost {
m.def("cut_rotated_bbox", &cut_rotated_bbox, "Returns numpy array with rotatted object");
}

}
}
10 changes: 5 additions & 5 deletions libs/savantboost/savantboost/deepstream/preprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ GstFlowReturn ObjectsPreprocessing::preprocessing(
if (status)
{
surface = (NvBufSurface *) in_map_info.data;
DSCudaMemory ds_cuda_memory = DSCudaMemory(surface, false);
batch_meta = gst_buffer_get_nvds_batch_meta(inbuf);

if (batch_meta == nullptr) {
Expand All @@ -119,6 +118,7 @@ GstFlowReturn ObjectsPreprocessing::preprocessing(

for (frame_meta_list_item = batch_meta->frame_meta_list; frame_meta_list_item != nullptr; frame_meta_list_item = frame_meta_list_item->next)
{
DSCudaMemory ds_cuda_memory = DSCudaMemory(surface, true);
frame_meta = (NvDsFrameMeta *) (frame_meta_list_item->data);
frame_height = (int) surface->surfaceList[frame_meta->batch_id].planeParams.height[0];
frame_width = (int) surface->surfaceList[frame_meta->batch_id].planeParams.width[0];
Expand Down Expand Up @@ -218,9 +218,9 @@ GstFlowReturn ObjectsPreprocessing::preprocessing(
if (preproc_object!=nullptr) delete preproc_object;
}
}


ds_cuda_memory.UnMapCudaPtr();
}
ds_cuda_memory.UnMapCudaPtr();
gst_buffer_unmap (inbuf, &in_map_info);
return GST_FLOW_OK;
}
Expand Down Expand Up @@ -250,9 +250,9 @@ GstFlowReturn ObjectsPreprocessing::restore_frame(GstBuffer* gst_buffer){
{
batch_meta = gst_buffer_get_nvds_batch_meta(gst_buffer);
surface = (NvBufSurface *) in_map_info.data;
DSCudaMemory ds_cuda_memory = DSCudaMemory(surface, false);
for (frame_list_item = batch_meta->frame_meta_list; frame_list_item != nullptr; frame_list_item = frame_list_item->next)
{
DSCudaMemory ds_cuda_memory = DSCudaMemory(surface, true);
frame_meta = (NvDsFrameMeta *) (frame_list_item->data);
frame_height = (int) surface->surfaceList[frame_meta->batch_id].planeParams.height[0];
frame_width = (int) surface->surfaceList[frame_meta->batch_id].planeParams.width[0];
Expand All @@ -267,8 +267,8 @@ GstFlowReturn ObjectsPreprocessing::restore_frame(GstBuffer* gst_buffer){
cudaFree(ref_frame);
cudaCheckError()
frames_map[(size_t) gst_buffer].erase(frame_meta->batch_id);
ds_cuda_memory.UnMapCudaPtr();
}
ds_cuda_memory.UnMapCudaPtr();
if (frames_map[(size_t) gst_buffer].empty())
{
frames_map.erase((size_t) gst_buffer);
Expand Down

0 comments on commit c8a09ad

Please sign in to comment.