Fix mutex lock issues
This commit is contained in:
@@ -687,6 +687,7 @@ namespace ANSCENTER
|
||||
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;
|
||||
@@ -746,6 +747,7 @@ namespace ANSCENTER
|
||||
bool ANSSAM3::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;
|
||||
@@ -803,6 +805,7 @@ namespace ANSCENTER
|
||||
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;
|
||||
@@ -1010,15 +1013,7 @@ namespace ANSCENTER
|
||||
|
||||
std::vector<Object> ANSSAM3::RunInference(const cv::Mat& input, const std::string& camera_id)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
if (!_modelLoadValid || !_isInitialized) return {};
|
||||
if (!m_promptSet) {
|
||||
_logger.LogError("ANSSAM3::RunInference", "No prompt set", __FILE__, __LINE__);
|
||||
return {};
|
||||
}
|
||||
if (input.empty() || input.cols < 10 || input.rows < 10) return {};
|
||||
}
|
||||
if (!PreInferenceCheck("ANSSAM3::RunInference")) return {};
|
||||
try {
|
||||
return Detect(input, camera_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user