Fix double stop in ANSVideoPlayer

This commit is contained in:
2026-04-22 10:10:16 +10:00
parent 97d814936d
commit 57cc8e0a56
14 changed files with 492 additions and 70 deletions

View File

@@ -6,6 +6,7 @@
#include <json.hpp>
#include <algorithm>
#include <atomic>
#include <chrono>
// ---------------------------------------------------------------------------
@@ -1063,6 +1064,34 @@ namespace ANSCENTER
std::lock_guard<std::mutex> plateLock(_plateIdentitiesMutex);
auto& identities = _plateIdentities[cameraId];
// Leak diagnostic — [OCR_Leak] heartbeat, at most once per 60 s
// process-wide. Same fields as the ANSALPR_OD variant for direct
// comparison: cams, ids_tot, clr, imgtrk. If any of these climb
// monotonically, the corresponding state container is the leak.
{
using clk = std::chrono::steady_clock;
static std::atomic<long long> s_nextLog{0};
const long long tick = clk::now().time_since_epoch().count();
long long expected = s_nextLog.load(std::memory_order_relaxed);
if (tick >= expected) {
const long long deadline = tick +
std::chrono::duration_cast<clk::duration>(
std::chrono::seconds(60)).count();
if (s_nextLog.compare_exchange_strong(expected, deadline,
std::memory_order_relaxed)) {
size_t ids_tot = 0;
for (const auto& [cam, v] : _plateIdentities) ids_tot += v.size();
ANS_DBG("OCR_Leak",
"ANSALPR_OCR this=%p cams=%zu ids_tot=%zu clr=%zu imgtrk=%zu",
(void*)this,
_plateIdentities.size(),
ids_tot,
_colourCache.size(),
_imageSizeTrackers.size());
}
}
}
// Auto-detect mode by detection count.
// 1 detection → pipeline/single-crop mode → no dedup needed.
// 2+ detections → full-frame mode → apply accumulated scoring.