Fix mutex lock issues
This commit is contained in:
@@ -33,6 +33,7 @@ namespace ANSCENTER
|
||||
|
||||
bool ANSOYOLOV10OVOD::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;
|
||||
@@ -88,6 +89,7 @@ namespace ANSCENTER
|
||||
}
|
||||
bool ANSOYOLOV10OVOD::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;
|
||||
@@ -157,6 +159,7 @@ namespace ANSCENTER
|
||||
|
||||
bool ANSOYOLOV10OVOD::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 {
|
||||
std::string openVINOVersion = ov::get_openvino_version().buildNumber;
|
||||
std::cout << "OpenVINO version: " << openVINOVersion << std::endl;
|
||||
@@ -222,18 +225,7 @@ namespace ANSCENTER
|
||||
return RunInference(input, "OpenVINO10Cam");
|
||||
}
|
||||
std::vector<Object> ANSOYOLOV10OVOD::RunInference(const cv::Mat& input, const std::string& camera_id) {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
|
||||
// Validate license and initialization status
|
||||
if (!_licenseValid) {
|
||||
_logger.LogError("ANSOYOLOV10OVOD::RunInference", "Invalid License", __FILE__, __LINE__);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!_isInitialized) {
|
||||
_logger.LogError("ANSOYOLOV10OVOD::RunInference", "Model is not initialized", __FILE__, __LINE__);
|
||||
return {};
|
||||
}
|
||||
if (!PreInferenceCheck("ANSOYOLOV10OVOD::RunInference")) return {};
|
||||
|
||||
// Validate input
|
||||
if (input.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user