Fix model extract race issue to all classes
This commit is contained in:
@@ -1953,6 +1953,15 @@ namespace ANSCENTER {
|
||||
|
||||
bool result = ANSODBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, labelMap);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
|
||||
ModelFolderLockGuard _flg(_modelFolder, "ANSMOTIONDETECTOR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSMOTIONDETECTOR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
_isInitialized = true;
|
||||
//_modelConfig.detectionScoreThreshold = 0.5;
|
||||
labelMap = "Movement";
|
||||
@@ -1968,6 +1977,15 @@ namespace ANSCENTER {
|
||||
bool ANSMOTIONDETECTOR::LoadModelFromFolder(std::string licenseKey, ModelConfig modelConfig, std::string modelName, std::string className, const std::string& modelFolder, std::string& labelMap) {
|
||||
bool result = ANSODBase::LoadModelFromFolder(licenseKey, modelConfig, modelName, className, modelFolder, labelMap);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
|
||||
ModelFolderLockGuard _flg(_modelFolder, "ANSMOTIONDETECTOR::LoadModel");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSMOTIONDETECTOR::LoadModel",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
_isInitialized = true;
|
||||
labelMap = "Movement";
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user