diff --git a/plugins/alarm/actions/http_action.cpp b/plugins/alarm/actions/http_action.cpp index 2a6c7c7..89ebec6 100644 --- a/plugins/alarm/actions/http_action.cpp +++ b/plugins/alarm/actions/http_action.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -111,7 +112,7 @@ void HttpAction::Execute(AlarmEvent& event, std::shared_ptr /*frame*/) { const auto& det = event.detections[i]; if (i > 0) oss << ","; oss << "{\"cls_id\":" << det.cls_id - << ",\"score\":" << det.score + << ",\"score\":" << std::fixed << std::setprecision(2) << det.score << ",\"bbox\":{\"x\":" << det.bbox.x << ",\"y\":" << det.bbox.y << ",\"w\":" << det.bbox.w diff --git a/plugins/alarm/alarm_node.cpp b/plugins/alarm/alarm_node.cpp index e93a527..8a24b6e 100644 --- a/plugins/alarm/alarm_node.cpp +++ b/plugins/alarm/alarm_node.cpp @@ -952,7 +952,10 @@ private: Detection d; d.cls_id = -1; // Unknown: show stranger likelihood (1 - best_sim). Known: show match confidence (best_sim). - d.score = (rule.kind == FaceRule::Kind::Unknown) ? (1.0f - it.best_sim) : it.best_sim; + float rawScore = (rule.kind == FaceRule::Kind::Unknown) ? (1.0f - it.best_sim) : it.best_sim; + if (rawScore < 0.0f) rawScore = 0.0f; + if (rawScore > 0.99f) rawScore = 0.99f; + d.score = rawScore; d.bbox = it.bbox; d.track_id = it.person_track_id >= 0 ? it.person_track_id : it.best_person_id; dets.push_back(std::move(d));