Fix mutex lock issues (OCR and FR)

This commit is contained in:
2026-04-13 20:38:40 +10:00
parent 844d7396b2
commit 8e60126c4c
16 changed files with 227 additions and 18 deletions

View File

@@ -212,7 +212,9 @@ namespace ANSCENTER {
return RunInference(input, "OCRCPUCAM");
}
std::vector<ANSCENTER::OCRObject> ANSCPUOCR::RunInference(const cv::Mat& input, const std::string& cameraId) {
std::lock_guard<std::mutex> lock(_mutex);
if (_modelLoading.load()) return {};
auto lock = TryLockWithTimeout("ANSCPUOCR::RunInference");
if (!lock.owns_lock()) return {};
// Early validation
if (!_licenseValid) {
@@ -311,7 +313,9 @@ namespace ANSCENTER {
}
std::vector<ANSCENTER::OCRObject> ANSCPUOCR::RunInference(const cv::Mat& input, const std::vector<cv::Rect>& Bbox) {
std::lock_guard<std::mutex> lock(_mutex);
if (_modelLoading.load()) return {};
auto lock = TryLockWithTimeout("ANSCPUOCR::RunInference(Bbox)");
if (!lock.owns_lock()) return {};
// Early validation
if (!_licenseValid) {
@@ -434,7 +438,9 @@ namespace ANSCENTER {
const std::vector<cv::Rect>& Bbox,
const std::string& cameraId)
{
std::lock_guard<std::mutex> lock(_mutex);
if (_modelLoading.load()) return {};
auto lock = TryLockWithTimeout("ANSCPUOCR::RunInference(Bbox,CamId)");
if (!lock.owns_lock()) return {};
// Early validation
if (!_licenseValid) {