Correct logic in RTMPOSE when using generic model to detect person
This commit is contained in:
@@ -720,13 +720,31 @@ namespace ANSCENTER {
|
||||
|
||||
// --- Top-down path ---
|
||||
if (personDetector) {
|
||||
std::vector<Object> persons = personDetector->RunInference(inputImage, camera_id);
|
||||
if (persons.empty()) {
|
||||
ANS_DBG("ANSONNXRTMPOSE", "DetectObjects: detector found 0 persons cam='%s'",
|
||||
std::vector<Object> detections = personDetector->RunInference(inputImage, camera_id);
|
||||
if (detections.empty()) {
|
||||
ANS_DBG("ANSONNXRTMPOSE", "DetectObjects: detector found 0 detections cam='%s'",
|
||||
camera_id.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
// person.onnx may be a multi-class detector (e.g. a generic
|
||||
// COCO YOLO with 80 classes). The COCO 'person' class is id=0
|
||||
// by convention. Drop everything else BEFORE pose / dedup so
|
||||
// we don't waste cycles on cars, dogs, signs, etc.
|
||||
std::vector<Object> persons;
|
||||
persons.reserve(detections.size());
|
||||
for (auto& d : detections) {
|
||||
if (d.classId != 0) continue;
|
||||
if (d.box.width <= 0 || d.box.height <= 0) continue;
|
||||
persons.push_back(std::move(d));
|
||||
}
|
||||
if (persons.empty()) {
|
||||
ANS_DBG("ANSONNXRTMPOSE",
|
||||
"DetectObjects: %zu detections but 0 persons (classId==0) cam='%s'",
|
||||
detections.size(), camera_id.c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
// IoU dedup — Ultralytics E2E NMS in person.onnx is too lax
|
||||
// (training-time IoU≈0.7 default), letting near-duplicate
|
||||
// boxes through. Drop duplicates BEFORE running pose so we
|
||||
@@ -741,7 +759,6 @@ namespace ANSCENTER {
|
||||
std::vector<Object> out;
|
||||
out.reserve(persons.size());
|
||||
for (const auto& person : persons) {
|
||||
if (person.box.width <= 0 || person.box.height <= 0) continue;
|
||||
Object pose = engine->estimate(inputImage, person.box);
|
||||
if (pose.kps.empty()) continue;
|
||||
pose.cameraId = camera_id;
|
||||
|
||||
Reference in New Issue
Block a user