Remove locks
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include <omp.h>
|
||||
#include <include/paddleocr_utility.h>
|
||||
|
||||
|
||||
namespace ANSCENTER {
|
||||
|
||||
bool ANSCPUOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelConfig,
|
||||
@@ -13,15 +12,6 @@ namespace ANSCENTER {
|
||||
{
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSCPUOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSCPUOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Override the paddleocrv3 for openvino only
|
||||
switch (_modelConfig.ocrLanguage) {
|
||||
@@ -442,7 +432,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSCPUOCR::RunInference(const cv::Mat& input,
|
||||
const std::vector<cv::Rect>& Bbox,
|
||||
const std::string& cameraId)
|
||||
|
||||
@@ -9,15 +9,6 @@ namespace ANSCENTER {
|
||||
{
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
auto option = fastdeploy::RuntimeOption();
|
||||
// Add default values to modelConfig if required.
|
||||
_modelConfig.precisionType = "fp32";
|
||||
@@ -117,8 +108,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSOCR::RunInference(const cv::Mat& input) {
|
||||
std::vector<ANSCENTER::OCRObject> OCRObjects;
|
||||
if (input.empty()) return OCRObjects;
|
||||
@@ -184,7 +173,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSOCR::RunInference(const cv::Mat& input, const std::vector<cv::Rect>& Bbox) {
|
||||
// No coarse _mutex — ppOCR->Predict() / engine has its own internal lock
|
||||
std::vector<ANSCENTER::OCRObject> OCRObjects;
|
||||
@@ -278,7 +266,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSOCR::RunInference(const cv::Mat& input, const std::vector<cv::Rect>& Bbox, const std::string& cameraId) {
|
||||
// No coarse _mutex — ppOCR->Predict() / engine has its own internal lock
|
||||
std::vector<ANSCENTER::OCRObject> OCRObjects;
|
||||
@@ -348,7 +335,6 @@ namespace ANSCENTER {
|
||||
ocrObject.box.width = rook_points[1].x - rook_points[0].x;
|
||||
ocrObject.box.height = rook_points[2].y - rook_points[1].y;
|
||||
|
||||
|
||||
ocrObject.classId = res_ocr.cls_labels[n];
|
||||
ocrObject.confidence = res_ocr.rec_scores[n];
|
||||
ocrObject.className = res_ocr.text[n];
|
||||
|
||||
@@ -71,7 +71,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
_licenseValid = true;
|
||||
|
||||
|
||||
// 0. Check if the modelZipFilePath exist?
|
||||
if (!FileExist(modelZipFilePath)) {
|
||||
this->_logger.LogFatal("ANSOCRBase::Initialize", "Model zip file is not exist", __FILE__, __LINE__);
|
||||
@@ -96,15 +95,6 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize. Output model folder is not exist", modelName, __FILE__, __LINE__);
|
||||
return false; // That means the model file is not exist or the password is not correct
|
||||
}
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCRBase::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -133,7 +123,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
_licenseValid = true;
|
||||
|
||||
|
||||
// 0. Check if the modelZipFilePath exist?
|
||||
if (!FileExist(modelZipFilePath)) {
|
||||
this->_logger.LogFatal("ANSOCRBase::Initialize", "Model zip file is not exist", __FILE__, __LINE__);
|
||||
@@ -158,15 +147,6 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize. Output model folder is not exist", modelName, __FILE__, __LINE__);
|
||||
return false; // That means the model file is not exist or the password is not correct
|
||||
}
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCRBase::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
// 3. Check if the model has the configuration file
|
||||
std::string modelConfigName = "model_config.json";
|
||||
_modelConfigFile = CreateFilePath(_modelFolder, modelConfigName);
|
||||
@@ -365,7 +345,6 @@ namespace ANSCENTER {
|
||||
return polygon;
|
||||
}
|
||||
|
||||
|
||||
// ── ALPR Configuration Methods ──────────────────────────────────────
|
||||
|
||||
void ANSOCRBase::SetOCRMode(OCRMode mode) { _ocrMode = mode; }
|
||||
@@ -938,5 +917,3 @@ namespace ANSCENTER {
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,15 +9,6 @@ bool ANSONNXOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelC
|
||||
try {
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSONNXOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSONNXOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate detection model
|
||||
if (!FileExist(_modelConfig.detectionModelFile)) {
|
||||
|
||||
@@ -9,15 +9,6 @@ bool ANSRTOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelCon
|
||||
try {
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSRTOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSRTOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate detection model
|
||||
if (!FileExist(_modelConfig.detectionModelFile)) {
|
||||
|
||||
Reference in New Issue
Block a user