Remove locks

This commit is contained in:
2026-04-24 17:10:29 +10:00
parent 7a11c9617b
commit 3a527d2dad
51 changed files with 38 additions and 1251 deletions

View File

@@ -518,15 +518,6 @@ namespace ANSCENTER {
this->_logger.LogError("ANSFDBase::Initialize. Output model folder is not exist", _modelFolder, __FILE__, __LINE__);
return false; // That means the model file is not exist or the password is not correct
}
// Serialize init against concurrent extract re-entries on the same
// folder. See ModelFolderLockGuard in Utility.h.
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSALPR::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
return true;
}
catch (std::exception& e) {

View File

@@ -304,15 +304,6 @@ namespace ANSCENTER {
this->_logger.LogError("ANSALPR_CPU::Initialize. Output model folder is not exist", _modelFolder, __FILE__, __LINE__);
return false; // That means the model file is not exist or the password is not correct
}
// Serialize init against concurrent extract re-entries on the same
// folder. See ModelFolderLockGuard in Utility.h.
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_CPU::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSALPR_CPU::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// 3. Load LD model
alprChecker.Init(MAX_ALPR_FRAME);
@@ -326,15 +317,6 @@ namespace ANSCENTER {
bool ANSALPR_CPU::LoadEngine() {
std::lock_guard<std::recursive_mutex> lock(_mutex);
try {
// Serialize init against concurrent extract re-entries on the same
// folder. See ModelFolderLockGuard in Utility.h.
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_CPU::LoadEngine");
if (!_flg.acquired()) {
this->_logger.LogError("ANSALPR_CPU::LoadEngine",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// 1. Load license plate detection model (using CPU OpenVINO)
if (_lprDetector) _lprDetector.reset();
std::string lprModel = CreateFilePath(_modelFolder, "lprModel.xml");
@@ -460,7 +442,6 @@ namespace ANSCENTER {
float iouThreshold = 0.4;
std::vector<Object> lprOutput = ANSUtilityHelper::ApplyNMS(lprOutputRaw, iouThreshold);
if (!lprOutput.empty()) {
if (!ppocr) {
this->_logger.LogFatal("ANSALPR_CPU::Inference", "PPOCR instance is null", __FILE__, __LINE__);
@@ -923,7 +904,6 @@ namespace ANSCENTER {
// std::string numberCode = cleanOCRText.substr(7, 2);// 00 to 99
// std::string newSuburbCode = convertStringToDigits(suburbCode);
// // Convert the newSuburbCode to an integer
// int numericValue = std::stoi(newSuburbCode);
// // Check if it is within the range 11 to 99
@@ -986,7 +966,6 @@ namespace ANSCENTER {
// std::string numberCode = cleanOCRText.substr(7, 3);// 00 to 99
// std::string newSuburbCode = convertStringToDigits(suburbCode);
// // Convert the newSuburbCode to an integer
// int numericValue = std::stoi(newSuburbCode);
// // Check if it is within the range 11 to 99
@@ -1280,7 +1259,6 @@ namespace ANSCENTER {
}
}
// Align plate
cv::Mat ANSALPR_CPU::alignPlateForOCR(const cv::Mat& fullImage, const cv::Rect& bbox) {
try {

View File

@@ -177,15 +177,6 @@ namespace ANSCENTER
this->_logger.LogError("ANSALPR_OCR::Initialize", "Output model folder does not exist: " + _modelFolder, __FILE__, __LINE__);
return false;
}
// Serialize init against concurrent extract re-entries on the same
// folder. See ModelFolderLockGuard in Utility.h.
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OCR::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSALPR_OCR::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Check country from country.txt
std::string countryFile = CreateFilePath(_modelFolder, "country.txt");
@@ -225,15 +216,6 @@ namespace ANSCENTER
bool ANSALPR_OCR::LoadEngine() {
std::lock_guard<std::recursive_mutex> lock(_mutex);
try {
// Serialize init against concurrent extract re-entries on the same
// folder. See ModelFolderLockGuard in Utility.h.
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OCR::LoadEngine");
if (!_flg.acquired()) {
this->_logger.LogError("ANSALPR_OCR::LoadEngine",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
WriteEventLog("ANSALPR_OCR::LoadEngine: Step 1 - Starting engine load");
this->_logger.LogInfo("ANSALPR_OCR::LoadEngine", "Step 1: Starting engine load", __FILE__, __LINE__);

View File

@@ -431,15 +431,6 @@ namespace ANSCENTER {
this->_logger.LogError("ANSALPR_OD::Initialize. Output model folder is not exist", _modelFolder, __FILE__, __LINE__);
return false; // That means the model file is not exist or the password is not correct
}
// Serialize init against concurrent extract re-entries on the same
// folder. See ModelFolderLockGuard in Utility.h.
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSALPR_OD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Check country
std::string countryFile = CreateFilePath(_modelFolder, "country.txt");
@@ -518,15 +509,6 @@ namespace ANSCENTER {
bool ANSALPR_OD::LoadEngine() {
std::lock_guard<std::recursive_mutex> lock(_mutex);
try {
// Serialize init against concurrent extract re-entries on the same
// folder. See ModelFolderLockGuard in Utility.h.
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OD::LoadEngine");
if (!_flg.acquired()) {
this->_logger.LogError("ANSALPR_OD::LoadEngine",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
WriteEventLog("ANSALPR_OD::LoadEngine: Step 1 - Starting engine load");
this->_logger.LogInfo("ANSALPR_OD::LoadEngine", "Step 1: Starting engine load", __FILE__, __LINE__);
@@ -547,7 +529,6 @@ namespace ANSCENTER {
_lpColourModelConfig.modelConfThreshold = 0.5;
_lpColourModelConfig.modelMNSThreshold = 0.5;
_lpdmodelConfig.inpHeight = 640;
_lpdmodelConfig.inpWidth = 640;
@@ -578,7 +559,6 @@ namespace ANSCENTER {
_lpColourModelConfig.optInputHeight = 224;
_lpColourModelConfig.optInputWidth = 224;
std::string lprModel = CreateFilePath(_modelFolder, "lpd.onnx");
std::string lprClassesFile = CreateFilePath(_modelFolder, "lpd.names");
@@ -1364,7 +1344,6 @@ namespace ANSCENTER {
}
}
// Check if this is actually a single row
// If max gap is too small relative to character height, it's a single row
std::vector<std::vector<Object>> rows;
@@ -3086,7 +3065,6 @@ namespace ANSCENTER {
}
}
if (maxGap < avgHeight * ROW_SPLIT_MIN_GAP_FACTOR) {
// Single row - sort by projection along reading direction
std::vector<std::pair<float, size_t>> allProj;
@@ -3119,7 +3097,6 @@ namespace ANSCENTER {
if (avgY0 > avgY1)
std::swap(rowIndices[0], rowIndices[1]);
// Sort each row by projection along reading direction
std::string ocrText;
ocrText.reserve(n);