Fix double stop in ANSVideoPlayer
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <unordered_map>
|
||||
// ---------------------------------------------------------------------------
|
||||
// Check ONNX model opset version by reading the protobuf header directly.
|
||||
@@ -3121,6 +3122,41 @@ namespace ANSCENTER {
|
||||
std::lock_guard<std::mutex> plateLock(_plateIdentitiesMutex);
|
||||
auto& identities = _plateIdentities[cameraId];
|
||||
|
||||
// Leak diagnostic — [OCR_Leak] heartbeat fires at most once per 60 s
|
||||
// process-wide. Reports the three per-camera state containers that
|
||||
// _could_ accumulate: _plateIdentities (keyed by cameraId), its sum
|
||||
// of inner-vector sizes, _colourCache, _imageSizeTrackers. All three
|
||||
// have stated bounds; heartbeat confirms they actually hold.
|
||||
// cams — number of distinct cameraId keys in _plateIdentities
|
||||
// ids_tot — sum of per-camera identity-vector sizes (should plateau)
|
||||
// clr — _colourCache size (bounded at COLOUR_CACHE_MAX_SIZE=200)
|
||||
// imgtrk — _imageSizeTrackers size (one entry per cameraId)
|
||||
// All size() reads outside locks are diagnostic snapshots; brief
|
||||
// races are acceptable (we're looking at trends over minutes).
|
||||
{
|
||||
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_OD this=%p cams=%zu ids_tot=%zu clr=%zu imgtrk=%zu",
|
||||
(void*)this,
|
||||
_plateIdentities.size(),
|
||||
ids_tot,
|
||||
_colourCache.size(),
|
||||
_imageSizeTrackers.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Option B: Auto-detect mode by counting detections.
|
||||
// 1 detection → crop/pipeline mode → return instant result, no accumulated scoring
|
||||
// 2+ detections → full-frame mode → use accumulated scoring for dedup
|
||||
|
||||
Reference in New Issue
Block a user