Fix issue that generate two or more objects with the same LP numbers/user name in the same image frame
This commit is contained in:
@@ -123,6 +123,7 @@ namespace ANSCENTER
|
||||
void Destroy();
|
||||
void SetMaxSlotsPerGpu(int n) { m_maxSlotsPerGpu = n; }
|
||||
private:
|
||||
struct CameraData; // Forward declaration for ensureUniqueUserIdWithHighestConfidence
|
||||
int m_maxSlotsPerGpu{ 1 }; // set by dllmain based on GPU topology
|
||||
int GetUser(int userId, UserRecord& userRecord);
|
||||
int GetUser(int userId, const std::string& userCode,const std::string& userName, UserRecord& userRecord);
|
||||
@@ -140,7 +141,7 @@ namespace ANSCENTER
|
||||
bool InitializeAgeGenderModel(const std::string& deviceName);
|
||||
bool InitializeEmotionModel(const std::string& deviceName);
|
||||
bool InitializeHeadPoseModel(const std::string& deviceName);
|
||||
void ensureUniqueUserIdWithHighestConfidence(std::vector<FaceResultObject>& resultObjects);
|
||||
void ensureUniqueUserIdWithHighestConfidence(std::vector<FaceResultObject>& resultObjects, CameraData* camData = nullptr);
|
||||
Object GetLargestObject(const std::vector<Object>& objects);
|
||||
bool AreFacesSimilar(const FaceResultObject& face1, const FaceResultObject& face2);
|
||||
size_t GenerateFaceHash(const FaceResultObject& face, const std::vector<FaceResultObject>& detectedObjects);
|
||||
@@ -232,6 +233,16 @@ namespace ANSCENTER
|
||||
int attributeFrameCounter = 0; // counts frames for attribute skip logic
|
||||
std::unordered_map<int, CachedFaceAttributes> cachedAttributes; // trackId → cached attrs
|
||||
|
||||
// Identity persistence: accumulated confidence per (trackId, userId) pair.
|
||||
// Each frame adds the recognition confidence to the running total.
|
||||
// When two trackIds claim the same userId, the one with the higher
|
||||
// accumulated score wins — preventing single-frame flickering.
|
||||
struct TrackIdentity {
|
||||
std::string userId;
|
||||
float accumulatedScore = 0.0f;
|
||||
};
|
||||
std::unordered_map<int, TrackIdentity> trackIdentities; // trackId → accumulated identity
|
||||
|
||||
// Adaptive interval state
|
||||
int currentAttributeInterval = 5; // current adaptive interval
|
||||
int stableFrameCount = 0; // frames with no new/lost trackIds
|
||||
@@ -246,6 +257,7 @@ namespace ANSCENTER
|
||||
_detectionQueue.clear();
|
||||
attributeFrameCounter = 0;
|
||||
cachedAttributes.clear();
|
||||
trackIdentities.clear();
|
||||
currentAttributeInterval = 5;
|
||||
stableFrameCount = 0;
|
||||
previousTrackIdCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user