disable ALPR checker by default

This commit is contained in:
2026-05-05 04:37:23 +10:00
parent 91d81cbd88
commit d03c2c1138
8 changed files with 1192 additions and 12 deletions
+26 -3
View File
@@ -145,7 +145,16 @@ namespace ANSCENTER
// ALPRChecker toggle (Layer 2 + Layer 3):
// true = enabled for full-frame, auto-disabled for pipeline/crop
// false = force disabled everywhere (raw OCR pass-through)
bool _enableALPRChecker{ true };
// Default OFF — callers must opt in with SetALPRCheckerEnabled(true)
// to get tracker voting / skip-when-locked / spatial dedup. Keeps
// the out-of-the-box pipeline stateless so first-frame results match
// per-frame results exactly, and avoids surprises for callers that
// drive the engine with pre-cropped pipeline inputs.
// Atomic so the inference threads can read it without a lock while
// config threads (LabVIEW/UI/REST) flip it at runtime. Relaxed
// ordering is sufficient: we only need the read to be tear-free, and
// "next frame picks up the new value" is the intended contract.
std::atomic<bool> _enableALPRChecker{ false };
public:
[[nodiscard]] virtual bool Initialize(const std::string& licenseKey, const std::string& modelZipFilePath, const std::string& modelZipPassword, double detectorThreshold, double ocrThreshold, double colourTheshold=0);
@@ -193,8 +202,20 @@ namespace ANSCENTER
/// Enable/disable ALPRChecker (Layer 2 text stabilization + Layer 3 dedup):
/// true = enabled for full-frame, auto-disabled for pipeline/crop
/// false = force disabled everywhere (raw OCR pass-through)
void SetALPRCheckerEnabled(bool enable) { _enableALPRChecker = enable; }
bool IsALPRCheckerEnabled() const { return _enableALPRChecker; }
void SetALPRCheckerEnabled(bool enable) {
const bool prev = _enableALPRChecker.exchange(enable, std::memory_order_relaxed);
ANS_DBG("ALPR_Checker",
"SetALPRCheckerEnabled this=%p prev=%d new=%d (%s)",
(void*)this, prev ? 1 : 0, enable ? 1 : 0,
enable ? "ON" : "OFF");
}
bool IsALPRCheckerEnabled() const {
const bool value = _enableALPRChecker.load(std::memory_order_relaxed);
ANS_DBG("ALPR_Checker",
"IsALPRCheckerEnabled this=%p value=%d (%s)",
(void*)this, value ? 1 : 0, value ? "ON" : "OFF");
return value;
}
virtual void SetCountry(Country country) { _country = country; }
Country GetCountry() const { return _country; }
@@ -262,6 +283,8 @@ extern "C" ANSLPR_API int ANSALPR_GetFormats(ANSCENTER::ANSALPR** Handle, LS
// ALPRChecker: 1 = enabled (full-frame auto-detected), 0 = disabled (raw OCR)
extern "C" ANSLPR_API int ANSALPR_SetALPRCheckerEnabled(ANSCENTER::ANSALPR** Handle, int enable);
// Returns the current ALPRChecker flag: 1 = enabled, 0 = disabled, -1 = invalid handle.
extern "C" ANSLPR_API int ANSALPR_GetALPRCheckerEnabled(ANSCENTER::ANSALPR** Handle);
// Country: 0=VIETNAM, 1=CHINA, 2=AUSTRALIA, 3=USA, 4=INDONESIA, 5=JAPAN
extern "C" ANSLPR_API int ANSALPR_SetCountry(ANSCENTER::ANSALPR** Handle, int country);