Recator draw imprecise face

This commit is contained in:
Barzan Hayati 2025-08-24 12:42:06 +00:00
parent 65b8f9b9a8
commit 3b9ff27524
2 changed files with 72 additions and 67 deletions

View File

@ -248,7 +248,17 @@ GstPadProbeReturn NvInferServerManager::pgie_pad_buffer_probe(
NvDsUserMeta *user_meta = (NvDsUserMeta *)l_user->data;
if (user_meta->base_meta.meta_type != NVDSINFER_TENSOR_OUTPUT_META)
continue;
extract_tensor_metadata(user_meta, networkInfo, batch_meta,
frame_meta);
}
}
// use_device_mem = 1 - use_device_mem;
return GST_PAD_PROBE_OK;
}
void NvInferServerManager::extract_tensor_metadata(
NvDsUserMeta *user_meta, NvDsInferNetworkInfo networkInfo,
NvDsBatchMeta *batch_meta, NvDsFrameMeta *frame_meta) {
/* convert to tensor metadata */
NvDsInferTensorMeta *meta =
(NvDsInferTensorMeta *)user_meta->user_meta_data;
@ -256,10 +266,8 @@ GstPadProbeReturn NvInferServerManager::pgie_pad_buffer_probe(
NvDsInferLayerInfo *info = &meta->output_layers_info[i];
info->buffer = meta->out_buf_ptrs_host[i];
if (use_device_mem && meta->out_buf_ptrs_dev[i]) {
cudaMemcpy(meta->out_buf_ptrs_host[i],
meta->out_buf_ptrs_dev[i],
info->inferDims.numElements * 4,
cudaMemcpyDeviceToHost);
cudaMemcpy(meta->out_buf_ptrs_host[i], meta->out_buf_ptrs_dev[i],
info->inferDims.numElements * 4, cudaMemcpyDeviceToHost);
}
}
/* Parse output tensor and fill detection results into objectList.
@ -302,23 +310,18 @@ GstPadProbeReturn NvInferServerManager::pgie_pad_buffer_probe(
// }
// std::cout << "]\n";
}
const NvDsInferLayerInfo &layer =
outputLayersInfo[0]; // or loop over all
const NvDsInferLayerInfo &layer = outputLayersInfo[0]; // or loop over all
uint detected_persons = 0;
float *data = static_cast<float *>(layer.buffer);
for (unsigned int jkl = 0; jkl < 100;
jkl++) { // 100 persons for each frame
jkl++) { // maximum 100 persons for each frame
if (data[jkl * 57 + 4] > threshold_body_detection) {
detected_persons++;
}
}
update_frame_with_face_body_meta(detected_persons, batch_meta, meta,
data, frame_meta);
}
}
// use_device_mem = 1 - use_device_mem;
return GST_PAD_PROBE_OK;
update_frame_with_face_body_meta(detected_persons, batch_meta, meta, data,
frame_meta);
}
void NvInferServerManager::update_frame_with_face_body_meta(

View File

@ -43,4 +43,6 @@ class NvInferServerManager {
static void update_frame_with_face_body_meta(uint, NvDsBatchMeta *,
NvDsInferTensorMeta *, float *,
NvDsFrameMeta *);
static void extract_tensor_metadata(NvDsUserMeta *, NvDsInferNetworkInfo,
NvDsBatchMeta *, NvDsFrameMeta *);
};