ANSFR: configurable slow-attribute refresh interval

New API SetANSRFAttributeInterval(Handle, frames) / UpdateAttributeInterval
(1..60, default 5) controls how often the slow attributes (age/gender +
emotions) refresh per camera; head pose and recognition are unaffected.
GetANSRFModelInfo now reports "attribute_interval". The adaptive logic's
stable-scene branch previously capped at a hardcoded 10 - it now doubles
the configured interval instead (default behaviour 10/5/2 unchanged).

Motivation: the v1.4 ViT age-gender model is heavier per attribute frame
than the old OpenVINO IR. Interval sweep on RTX 3070 (classroom.mp4,
~3.1 faces/frame) vs the v1.1 baseline at 16.0 ms / 62 fps:
  interval  5 (default): 19.9 ms / 50 fps  (+3.9 ms)
  interval 10:           17.1 ms / 58 fps  (+1.1 ms)
  interval 20:           16.5 ms / 61 fps  (parity)
Recommendation: default on 8 GB GPUs; interval 10 on small-VRAM machines.

ANSFR-UnitTest: --bench old|new [interval] runs the sweep.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 01:57:54 +10:00
co-authored by Claude Fable 5
parent 89b2efe182
commit f34817c620
4 changed files with 63 additions and 8 deletions
+20 -2
View File
@@ -1348,6 +1348,22 @@ namespace ANSCENTER {
}
}
bool ANSFacialRecognition::UpdateAttributeInterval(int frames) {
if (frames < 1 || frames > 60) {
LogThreadSafe("ANSFacialRecognition::UpdateAttributeInterval",
"Invalid interval " + std::to_string(frames) + " (expected 1..60)");
return false;
}
{
std::lock_guard<std::mutex> lock(_configMutex);
_attributeInterval = frames;
}
LogThreadSafe("ANSFacialRecognition::UpdateAttributeInterval",
"Attribute refresh interval set to " + std::to_string(frames) + " frames",
LogLevel::Info);
return true;
}
int ANSFacialRecognition::GetRecognizerModelType() const {
return static_cast<int>(_recognizer ? _activeRecModel : _requestedRecModel);
}
@@ -1373,6 +1389,7 @@ namespace ANSCENTER {
info["recognizer_loaded"] = (_recognizer != nullptr);
info["agegender_backend"] = agegenderBackend;
info["emotion_backend"] = emotionBackend;
info["attribute_interval"] = _attributeInterval;
return info.dump();
}
catch (const std::exception& e) {
@@ -3072,9 +3089,10 @@ namespace ANSCENTER {
}
camDataPtr->previousTrackIdCount = currentTrackIdCount;
// Adapt interval: stable scene → increase (max 10), changes → decrease (min 2)
// Adapt interval: stable scene → double the configured
// interval, changes → decrease (min 2)
if (camDataPtr->stableFrameCount > 30) {
camDataPtr->currentAttributeInterval = std::min(10, _attributeInterval * 2);
camDataPtr->currentAttributeInterval = _attributeInterval * 2;
} else if (camDataPtr->stableFrameCount > 10) {
camDataPtr->currentAttributeInterval = _attributeInterval;
} else {