Revert imprecise face component id

This commit is contained in:
Barzan Hayati 2025-08-25 21:36:13 +00:00
parent 54e775f304
commit 6c8624d6cd
3 changed files with 27 additions and 19 deletions

View File

@ -7,8 +7,10 @@
#define MAX_DISPLAY_LEN 64
#define PGIE_CLASS_ID_PERSON 0
#define CLASS_ID_IMPRECISE_FACE 1
#define IMPRECISE_FACE_CLASS_ID 1
#define PGIE_DETECTED_CLASS_NUM 1
#define BODY_COMPONENT_ID 1
#define IMPRECISE_FACE_COMPONENT_ID 2
gint NvInferServerManager::frame_number = 0;
unsigned int NvInferServerManager::PGIE_NET_WIDTH = 1;
@ -321,13 +323,13 @@ void NvInferServerManager::extract_tensor_metadata(
detected_persons++;
}
}
update_frame_with_face_body_meta(detected_persons, batch_meta, meta, data,
update_frame_with_face_body_meta(detected_persons, batch_meta, data,
frame_meta);
}
void NvInferServerManager::update_frame_with_face_body_meta(
uint detected_persons, NvDsBatchMeta *batch_meta, NvDsInferTensorMeta *meta,
float *data, NvDsFrameMeta *frame_meta) {
uint detected_persons, NvDsBatchMeta *batch_meta, float *data,
NvDsFrameMeta *frame_meta) {
for (uint index = 0; index < detected_persons; index++) {
// imprecise_face_obj_meta is the imprecise face
NvDsObjectMeta *imprecise_face_obj_meta =
@ -351,7 +353,8 @@ void NvInferServerManager::update_frame_with_face_body_meta(
imprecise_face_obj_meta
->obj_label[sizeof(imprecise_face_obj_meta->obj_label) - 1] =
'\0'; // Ensure null-termination
imprecise_face_obj_meta->unique_component_id = meta->unique_id; // 1
imprecise_face_obj_meta->unique_component_id =
IMPRECISE_FACE_COMPONENT_ID; // meta->unique_id
// imprecise_face_obj_meta->unique_component_id
// Meaning: The ID of the component (PGIE, SGIE, Tracker,
@ -370,7 +373,7 @@ void NvInferServerManager::update_frame_with_face_body_meta(
imprecise_face_obj_meta->confidence = data[index * 57 + 4];
// imprecise_face_obj_meta->object_id = UNTRACKED_OBJECT_ID;
imprecise_face_obj_meta->class_id =
CLASS_ID_IMPRECISE_FACE; // 0 for body detection
IMPRECISE_FACE_CLASS_ID; // 0 for body detection
NvOSD_RectParams &rect_params_imprecise_face =
imprecise_face_obj_meta->rect_params;
NvOSD_TextParams &text_params_imprecise_face =
@ -426,7 +429,8 @@ void NvInferServerManager::update_frame_with_face_body_meta(
sizeof(body_obj_meta->obj_label) - 1);
body_obj_meta->obj_label[sizeof(body_obj_meta->obj_label) - 1] =
'\0'; // Ensure null-termination
body_obj_meta->unique_component_id = meta->unique_id;
body_obj_meta->unique_component_id =
BODY_COMPONENT_ID; // meta->unique_id;
body_obj_meta->confidence = data[index * 57 + 4];
// body_obj_meta->object_id = UNTRACKED_OBJECT_ID;
body_obj_meta->class_id = PGIE_CLASS_ID_PERSON; // 0 for body detection
@ -451,8 +455,8 @@ void NvInferServerManager::update_frame_with_face_body_meta(
/* display_text requires heap allocated memory. */
text_params_body.display_text = g_strdup(pgie_class_str[0]);
/* Display text above the left top corner of the object. */
text_params_body.x_offset = rect_params_body.left;
text_params_body.y_offset = rect_params_body.top - 30;
text_params_body.x_offset = rect_params_body.left - 30;
text_params_body.y_offset = rect_params_body.top - 50;
/* Set black background for the text. */
text_params_body.set_bg_clr = 1;
text_params_body.text_bg_clr = NvOSD_ColorParams{0, 0, 0, 1};

View File

@ -47,8 +47,7 @@ class NvInferServerManager {
static void *set_metadata_ptr(float *);
static gpointer copy_user_meta(gpointer, gpointer);
static void release_user_meta(gpointer, gpointer);
static void update_frame_with_face_body_meta(uint, NvDsBatchMeta *,
NvDsInferTensorMeta *, float *,
static void update_frame_with_face_body_meta(uint, NvDsBatchMeta *, float *,
NvDsFrameMeta *);
static void extract_tensor_metadata(NvDsUserMeta *, NvDsInferNetworkInfo,
NvDsBatchMeta *, NvDsFrameMeta *);

View File

@ -7,9 +7,11 @@
#define GPU_ID 0
#define MAX_DISPLAY_LEN 64
#define PGIE_CLASS_ID_PERSON 0
#define FACE_COMPONENT_ID 2
#define FACE_CLASS_ID 1
#define THRESHOLD_LANDMARKS 0.1
#define FACE_DETECTED_CLASS_NUM 1
#define BODY_COMPONENT_ID 1
#define IMPRECISE_FACE_COMPONENT_ID 2
unsigned int NvTrackerManager::PGIE_NET_WIDTH = 1;
unsigned int NvTrackerManager::PGIE_NET_HEIGHT = 1;
@ -20,6 +22,7 @@ FaceCandidTrace *NvTrackerManager::face_candidate_trace =
new FaceCandidTrace(); // nullptr; // Definition
gint NvTrackerManager::frame_number = 0;
const gchar face_class_str[FACE_DETECTED_CLASS_NUM][32] = {"FACE_TRACKER"};
NvTrackerManager::NvTrackerManager() {
const auto &config = ConfigManager::get_instance().get_config();
@ -49,7 +52,6 @@ bool NvTrackerManager::create_nv_tracker() {
float NvTrackerManager::get_face_score(float *user_meta_data) {
return (user_meta_data[8] + user_meta_data[11] + user_meta_data[14]) / 3;
;
}
bool NvTrackerManager::check_existence(int object_id, int source_id, float area,
@ -101,6 +103,7 @@ GstPadProbeReturn NvTrackerManager::tracker_src_pad_buffer_probe(
GstBuffer *buf = (GstBuffer *)info->data;
guint num_rects = 0;
guint person_count = 0;
guint face_count = 0;
NvDsObjectMeta *obj_meta = NULL;
NvDsMetaList *l_frame = NULL;
NvDsMetaList *l_obj = NULL;
@ -127,12 +130,12 @@ GstPadProbeReturn NvTrackerManager::tracker_src_pad_buffer_probe(
// << " score = " << obj_meta->confidence
// << " object_id = " << obj_meta->object_id
// << std::endl;
} else {
face_count++;
// std::cout << "obj_meta->class_id = "
// << obj_meta->class_id << std::endl;
// std::quick_exit(0);
}
// else{
// std::cout << "obj_meta->class_id = "
// << obj_meta->class_id << std::endl;
// std::quick_exit(0);
// }
NvDsUserMeta *user_meta = NULL;
NvDsMetaList *l_user_meta = NULL;
@ -227,7 +230,8 @@ GstPadProbeReturn NvTrackerManager::tracker_src_pad_buffer_probe(
NvDsObjectMeta *face_obj =
nvds_acquire_obj_meta_from_pool(batch_meta);
face_obj->unique_component_id =
FACE_COMPONENT_ID; // Use a new component ID
IMPRECISE_FACE_COMPONENT_ID; // 1; // Use a new
// component ID
face_obj->rect_params = *face_rect_params;
face_obj->rect_params.has_bg_color = 0;
@ -249,6 +253,7 @@ GstPadProbeReturn NvTrackerManager::tracker_src_pad_buffer_probe(
user_meta_data); // manager->face_score;
face_obj->confidence = face_candidate->face_score; // 1.0;
face_candidate->object_id = obj_meta->object_id;
face_candidate->source_id = frame_meta->source_id;
bool add_status = face_candidate_trace->add(face_candidate);