Fix mutex lock issues
This commit is contained in:
@@ -938,6 +938,7 @@ namespace ANSCENTER
|
||||
}
|
||||
bool YOLOOD::LoadModel(const std::string& modelZipFilePath, const std::string& modelZipPassword) {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
ModelLoadingGuard mlg(_modelLoading);
|
||||
try {
|
||||
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
|
||||
if (!result) return false;
|
||||
@@ -1030,6 +1031,7 @@ namespace ANSCENTER
|
||||
}
|
||||
bool YOLOOD::LoadModelFromFolder(std::string licenseKey, ModelConfig modelConfig, std::string modelName, std::string className, const std::string& modelFolder, std::string& labelMap) {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
ModelLoadingGuard mlg(_modelLoading);
|
||||
try {
|
||||
bool result = ANSODBase::LoadModelFromFolder(licenseKey, modelConfig, modelName, className, modelFolder, labelMap);
|
||||
if (!result) return false;
|
||||
@@ -1152,6 +1154,7 @@ namespace ANSCENTER
|
||||
}
|
||||
bool YOLOOD::Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
ModelLoadingGuard mlg(_modelLoading);
|
||||
try {
|
||||
bool result = ANSODBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, labelMap);
|
||||
if (!result) return false;
|
||||
@@ -1266,18 +1269,7 @@ namespace ANSCENTER
|
||||
return RunInference(input, "CustomCam");
|
||||
}
|
||||
std::vector<Object> YOLOOD::RunInference(const cv::Mat& input, const std::string& camera_id) {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
|
||||
// Early validation - before try block
|
||||
if (!_licenseValid) {
|
||||
this->_logger.LogError("YOLOOD::RunInference", "Invalid License", __FILE__, __LINE__);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!_isInitialized) {
|
||||
this->_logger.LogError("YOLOOD::RunInference", "Model is not initialized", __FILE__, __LINE__);
|
||||
return {};
|
||||
}
|
||||
if (!PreInferenceCheck("YOLOOD::RunInference")) return {};
|
||||
|
||||
if (input.empty() || input.cols < 10 || input.rows < 10) {
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user