Remove locks

This commit is contained in:
2026-04-24 17:10:29 +10:00
parent 7a11c9617b
commit 3a527d2dad
51 changed files with 38 additions and 1251 deletions
-27
View File
@@ -33,15 +33,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSANOMALIB::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSANOMALIB::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_device = "AUTO:GPU,CPU";
_openvinoPreprocess = true;
_efficientAd = false;
@@ -100,15 +91,6 @@ namespace ANSCENTER {
try {
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, "ANSANOMALIB::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSANOMALIB::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "model";
@@ -185,15 +167,6 @@ namespace ANSCENTER {
//this->_logger.LogDebug("ANSANOMALIB::Initialize. OpenVINO version", openVINOVersion, __FILE__, __LINE__);
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, "ANSANOMALIB::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSANOMALIB::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for ABNORMAL only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::SEGMENTATION;
-20
View File
@@ -38,15 +38,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSCUSTOMDETECTOR::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSCUSTOMDETECTOR::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string labelMap;
CreateCustomDetector();
//_customDetector->SetLoadEngineOnCreate(this->_loadEngineOnCreation);
@@ -257,15 +248,6 @@ namespace ANSCENTER
try {
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, "ANSCUSTOMDETECTOR::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSCUSTOMDETECTOR::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
if (_modelConfig.modelMNSThreshold < 0.2)
_modelConfig.modelMNSThreshold = 0.5;
@@ -375,8 +357,6 @@ namespace ANSCENTER
}
//std::vector<Object> ANSCUSTOMDETECTOR::RunInference(const cv::Mat& input, const std::string& camera_id) {
// std::lock_guard<std::recursive_mutex> lock(_mutex);
// std::vector<Object> result;
-11
View File
@@ -343,15 +343,6 @@ if sys.stderr is None or not hasattr(sys.stderr, "write"):
// Step 1: Base model init
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, "ANSCUSTOMPY::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSCUSTOMPY::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.inpHeight = 640;
@@ -541,7 +532,6 @@ if sys.stderr is None or not hasattr(sys.stderr, "write"):
}
}
std::vector<Object> ANSCUSTOMPY::RunInference(const cv::Mat& input) {
return RunInference(input, "CustomPyCam");
}
@@ -763,4 +753,3 @@ if sys.stderr is None or not hasattr(sys.stderr, "write"):
}
}
-5
View File
@@ -27,11 +27,6 @@
//#define DEBUGENGINE
//#define USE_TV_MODEL // Use model to detect if person is on TV screen or not
// NOTE: ANSCENTER::ModelFolderLockGuard has been moved to Utility.h so that
// non-ANSODEngine modules (ANSOCR, ANSLPR, ANSFR, ...) can use it without
// pulling in ANSODEngine headers. It remains available here transitively
// because this file #includes "Utility.h" above.
const int MAX_HISTORY_FACE = 5;
const int MAX_MISSING_FACE = 30;
const int MAX_TRACKS = 200;
@@ -69,15 +69,6 @@ namespace ANSCENTER
this->_logger.LogError("ANSFDBase::LoadModel. Output model folder is not exist", _modelFolder, __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 ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSFDBase::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSFDBase::LoadModel",
"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);
@@ -169,15 +160,6 @@ namespace ANSCENTER
this->_logger.LogError("ANSFDBase::Initialize. Output model folder does not exist", _modelFolder, __FILE__, __LINE__);
return false;
}
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSFDBase::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSFDBase::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfigFile = CreateFilePath(_modelFolder, "model_config.json");
// 4. Load the image processing model
@@ -442,7 +424,6 @@ namespace ANSCENTER
return resizedImage;
}
ANSFDBase::~ANSFDBase() {
try {
Cleanup();
@@ -64,15 +64,6 @@ namespace ANSCENTER
this->_logger.LogError("ANSFRBase::LoadModel. Output model folder is not exist", _modelFolder, __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 ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSFRBase::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSFRBase::LoadModel",
"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);
@@ -121,15 +112,6 @@ namespace ANSCENTER
this->_logger.LogError("ANSFRBase::Initialize. Output model folder is not exist", _modelFolder, __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 ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSFRBase::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSFRBase::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);
-24
View File
@@ -108,7 +108,6 @@ namespace ANSCENTER {
}
}
void ANSMOTIONDETECTOR::setMinObjectArea(const std::string& camera_id, double area)
{
std::lock_guard<std::recursive_mutex> lock(cameras_mutex);
@@ -183,7 +182,6 @@ namespace ANSCENTER {
return 0.0;
}
bool ANSMOTIONDETECTOR::isMovementDetected(const std::string& camera_id) const
{
std::lock_guard<std::recursive_mutex> lock(cameras_mutex);
@@ -303,7 +301,6 @@ namespace ANSCENTER {
return std::vector<std::vector<cv::Point>>();
}
ANSMOTIONDETECTOR::CameraStats ANSMOTIONDETECTOR::getStats(const std::string& camera_id) const
{
std::lock_guard<std::recursive_mutex> lock(cameras_mutex);
@@ -557,7 +554,6 @@ namespace ANSCENTER {
camera.psnr_threshold = base_threshold * camera.sensitivity_multiplier;
}
std::cout << "Base threshold: " << base_threshold
<< ", Sensitivity: " << camera.sensitivity_multiplier
<< ", Final threshold: " << camera.psnr_threshold << std::endl;
@@ -920,7 +916,6 @@ namespace ANSCENTER {
return MovementDetect(camera_id, camera.next_frame_index, next_image);
}
//std::vector<Object> ANSMOTIONDETECTOR::MovementDetect(const std::string& camera_id, const size_t frame_index, const cv::Mat& image)
//{
// std::lock_guard<std::recursive_mutex> lock(cameras_mutex);
@@ -1336,7 +1331,6 @@ namespace ANSCENTER {
// return outputObjects;
// }
// // Store original dimensions for scaling back
// const int original_width = image.cols;
// const int original_height = image.rows;
@@ -1953,15 +1947,6 @@ 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";
@@ -1977,15 +1962,6 @@ 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;
-27
View File
@@ -25,15 +25,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ODHUBAPI::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ODHUBAPI::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// 0. Check weigth file
std::string weightfile = CreateFilePath(_modelFolder, "train_last.weights");
if (FileExist(weightfile)) {
@@ -91,15 +82,6 @@ namespace ANSCENTER
try {
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, "ODHUBAPI::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ODHUBAPI::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -172,15 +154,6 @@ 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, "ODHUBAPI::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ODHUBAPI::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
-28
View File
@@ -721,7 +721,6 @@ namespace ANSCENTER
className = "ClassID_" + std::to_string(bestClassId);
}
Object detection;
if (m_imgWidth > 20 && m_imgHeight > 20) {
detection.box = cv::Rect(10, 10, m_imgWidth - 20, m_imgHeight - 20);
@@ -882,15 +881,6 @@ namespace ANSCENTER
_modelLoadValid = false;
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, "ANSONNXCL::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXCL::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::CLASSIFICATION;
@@ -952,15 +942,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXCL::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXCL::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::CLASSIFICATION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 224;
@@ -1017,15 +998,6 @@ namespace ANSCENTER
try {
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, "ANSONNXCL::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXCL::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
-27
View File
@@ -1377,15 +1377,6 @@ namespace ANSCENTER {
_modelLoadValid = false;
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, "ANSONNXOBB::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXOBB::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -1447,15 +1438,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXOBB::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXOBB::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::CLASSIFICATION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 640;
@@ -1512,15 +1494,6 @@ namespace ANSCENTER {
try {
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, "ANSONNXOBB::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXOBB::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
-30
View File
@@ -801,7 +801,6 @@ namespace ANSCENTER {
DEBUG_PRINT("[Instance " << instanceId_ << "] Keypoints: " << numKeypoints
<< " (derived=" << derivedKps << ", config=" << _modelConfig.numKPS << ")");
const size_t expectedFeatures = 4 + 1 + numKeypoints * featuresPerKeypoint; // box(4) + conf(1) + kpts(17*3)
DEBUG_PRINT("[Instance " << instanceId_ << "] Output shape: ["
@@ -1072,7 +1071,6 @@ namespace ANSCENTER {
}
}
std::vector<Object> ANSONNXPOSE::detect(const cv::Mat& image, const std::string& camera_id) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
@@ -1245,7 +1243,6 @@ namespace ANSCENTER {
}
}
// Public functions
ANSONNXPOSE::~ANSONNXPOSE() {
Destroy();
@@ -1267,15 +1264,6 @@ namespace ANSCENTER {
_modelLoadValid = false;
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, "ANSONNXPOSE::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXPOSE::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -1338,15 +1326,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXPOSE::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXPOSE::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::CLASSIFICATION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 640;
@@ -1404,15 +1383,6 @@ namespace ANSCENTER {
try {
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, "ANSONNXPOSE::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXPOSE::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
-27
View File
@@ -42,15 +42,6 @@ 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, "ANSONNXSAM3::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXSAM3::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = DetectionType::SEGMENTATION;
if (_modelConfig.modelConfThreshold < 0.1f)
@@ -98,15 +89,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXSAM3::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXSAM3::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = DetectionType::SEGMENTATION;
if (_modelConfig.modelConfThreshold < 0.1f)
@@ -156,15 +138,6 @@ namespace ANSCENTER
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, "ANSONNXSAM3::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXSAM3::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.detectionType = DetectionType::SEGMENTATION;
-30
View File
@@ -549,7 +549,6 @@ namespace ANSCENTER {
}
}
cv::Mat ANSONNXSEG::preprocess(const cv::Mat& image, float*& blobPtr, std::vector<int64_t>& inputTensorShape) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
m_imgWidth = image.cols;
@@ -988,7 +987,6 @@ namespace ANSCENTER {
}
}
std::vector<Object> ANSONNXSEG::segment(const cv::Mat& image, const std::string& camera_id) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
@@ -1136,7 +1134,6 @@ namespace ANSCENTER {
}
}
// Public functions
ANSONNXSEG::~ANSONNXSEG() {
Destroy();
@@ -1158,15 +1155,6 @@ namespace ANSCENTER {
_modelLoadValid = false;
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, "ANSONNXSEG::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXSEG::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::SEGMENTATION;
@@ -1229,15 +1217,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXSEG::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXSEG::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::SEGMENTATION;
_modelConfig.modelType = ModelType::ONNXSEG;
_modelConfig.inpHeight = 640;
@@ -1295,15 +1274,6 @@ namespace ANSCENTER {
try {
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, "ANSONNXSEG::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSONNXSEG::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
-29
View File
@@ -98,7 +98,6 @@ namespace ANSCENTER {
const bool isClassification = !output_node_dims.empty()
&& output_node_dims[0].size() == 2;
cv::Mat canvas;
if (isClassification) {
// Classification: direct resize (no letterbox padding) — matches ANSONNXCL
@@ -1326,7 +1325,6 @@ namespace ANSCENTER {
const bool alreadyNormalized = (rawSum > 0.9f && rawSum < 1.1f
&& raw[0] >= 0.f); // probabilities are non-negative
std::vector<float> probs(nc);
if (alreadyNormalized) {
// Output is already softmax — use as-is (skip double softmax)
@@ -1775,15 +1773,6 @@ namespace ANSCENTER {
labelMap = VectorToCommaSeparatedString(_classes);
if (this->_loadEngineOnCreation) {
// Serialize session creation against concurrent extract re-entries
// on the same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXYOLO::Initialize");
if (!_flg.acquired()) {
_logger.LogError("ANSONNXYOLO::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
if (!InitOrtEngine()) {
_logger.LogError("ANSONNXYOLO::Initialize",
"Failed to create ONNX Runtime engine: " + _modelFilePath,
@@ -1854,15 +1843,6 @@ namespace ANSCENTER {
}
if (this->_loadEngineOnCreation) {
// See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXYOLO::LoadModel");
if (!_flg.acquired()) {
_logger.LogError("ANSONNXYOLO::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
_modelLoadValid = false;
return false;
}
if (!InitOrtEngine()) { _modelLoadValid = false; return false; }
}
@@ -1938,15 +1918,6 @@ namespace ANSCENTER {
labelMap = VectorToCommaSeparatedString(_classes);
if (this->_loadEngineOnCreation) {
// See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSONNXYOLO::LoadModelFromFolder");
if (!_flg.acquired()) {
_logger.LogError("ANSONNXYOLO::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
_modelLoadValid = false;
return false;
}
if (!InitOrtEngine()) { _modelLoadValid = false; return false; }
}
-28
View File
@@ -36,15 +36,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "OPENVINOCL::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("OPENVINOCL::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// 0. Check if the configuration file exist
if (FileExist(_modelConfigFile)) {
ModelType modelType;
@@ -93,15 +84,6 @@ namespace ANSCENTER
try {
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, "OPENVINOCL::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("OPENVINOCL::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -200,15 +182,6 @@ namespace ANSCENTER
//this->_logger.LogDebug("OPENVINOCL::Initialize. OpenVINO version", openVINOVersion, __FILE__, __LINE__);
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, "OPENVINOCL::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("OPENVINOCL::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::CLASSIFICATION;
@@ -447,7 +420,6 @@ namespace ANSCENTER
}
}
//std::vector<Object> OPENVINOCL::RunInference(const cv::Mat& input, const std::string& camera_id) {
// std::lock_guard<std::recursive_mutex> lock(_mutex);
// std::vector<Object> outputs;
-27
View File
@@ -36,15 +36,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "OPENVINOOD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("OPENVINOOD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// 0. Check if the configuration file exist
if (FileExist(_modelConfigFile)) {
ModelType modelType;
@@ -94,15 +85,6 @@ namespace ANSCENTER
try {
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, "OPENVINOOD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("OPENVINOOD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -205,15 +187,6 @@ namespace ANSCENTER
try {
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, "OPENVINOOD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("OPENVINOOD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -7,15 +7,6 @@
namespace ANSCENTER {
bool ANSOVFBFD::Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) {
bool result = ANSFDBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, labelMap);
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOVFBFD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVFBFD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
labelMap = "Face";
// We do not need to check for the license
_licenseValid = true;
@@ -79,15 +70,6 @@ namespace ANSCENTER {
// We need to get the _modelFolder
bool result = ANSFDBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOVFBFD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVFBFD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// We need to get the modelfolder from here
std::string xmlfile = CreateFilePath(_modelFolder, "ansovfb.xml");
if (std::filesystem::exists(xmlfile)) {
-27
View File
@@ -11,15 +11,6 @@
namespace ANSCENTER {
bool ANSOVFD::Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) {
bool result = ANSFDBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, labelMap);
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOVFD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVFD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
labelMap = "Face";
_licenseValid = true;
std::vector<std::string> labels{ labelMap };
@@ -56,15 +47,6 @@ namespace ANSCENTER {
// We need to get the _modelFolder
bool result = ANSFDBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOVFD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVFD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string onnxModel = CreateFilePath(_modelFolder, "scrfd.onnx");
//this->_face_detector = std::make_unique<SCRFD>(onnxModel);
_isInitialized = true;
@@ -80,15 +62,6 @@ namespace ANSCENTER {
try {
bool result = ANSFDBase::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, "ANSOVFD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVFD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "scrfd";
-28
View File
@@ -34,15 +34,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOVSEG::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVSEG::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// 0. Check if the configuration file exist
if (FileExist(_modelConfigFile)) {
ModelType modelType;
@@ -92,15 +83,6 @@ namespace ANSCENTER {
try {
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, "ANSOVSEG::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVSEG::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -170,15 +152,6 @@ namespace ANSCENTER {
this->_logger.LogDebug("ANSOVSEG::Initialize. OpenVINO version", openVINOVersion, __FILE__, __LINE__);
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, "ANSOVSEG::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVSEG::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::SEGMENTATION;
@@ -669,7 +642,6 @@ namespace ANSCENTER {
}
// Only work for Yolov8 for now, extract polygons does not work as expected
//std::vector<Object> ANSOVSEG::RunInference(const cv::Mat& input, const std::string& camera_id) {
// std::lock_guard<std::recursive_mutex> lock(_mutex);
-31
View File
@@ -37,15 +37,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSPOSE::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSPOSE::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_device = GetOpenVINODevice(_core);
// 0. Check if the configuration file exist
if (FileExist(_modelConfigFile)) {
@@ -90,15 +81,6 @@ namespace ANSCENTER {
try {
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, "ANSPOSE::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSPOSE::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "ansposesetimation";
@@ -154,7 +136,6 @@ namespace ANSCENTER {
}
}
bool ANSPOSE::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);
@@ -163,15 +144,6 @@ namespace ANSCENTER {
this->_logger.LogDebug("ANSPOSE::Initialize. OpenVINO version", openVINOVersion, __FILE__, __LINE__);
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, "ANSPOSE::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSPOSE::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for ABNORMAL only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::KEYPOINT;
@@ -420,8 +392,6 @@ namespace ANSCENTER {
}
// std::vector<Object> ANSPOSE::RunInference(const cv::Mat& input, const std::string& camera_id) {
// std::lock_guard<std::recursive_mutex> lock(_mutex);
// std::vector<Object> output;
@@ -470,7 +440,6 @@ namespace ANSCENTER {
// _poseEstimationPipeline->waitForTotalCompletion();
// std::unique_ptr<ResultBase> result = _poseEstimationPipeline->getResult();
// /* static const std::pair<int, int> keypointsOP[] = {
// {1, 2},
// {1, 5},
-27
View File
@@ -63,15 +63,6 @@ namespace ANSCENTER {
_isFixedBatch = false;
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSRTYOLO::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSRTYOLO::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.modelType = ModelType::TENSORRT;
if (_modelConfig.inpHeight <= 0) _modelConfig.inpHeight = 640;
@@ -164,15 +155,6 @@ namespace ANSCENTER {
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, "ANSRTYOLO::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSRTYOLO::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.modelType = ModelType::TENSORRT;
@@ -278,15 +260,6 @@ 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, "ANSRTYOLO::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSRTYOLO::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.modelType = ModelType::TENSORRT;
-30
View File
@@ -39,15 +39,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSSAM::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSAM::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string xmlfile = CreateFilePath(_modelFolder, "anssam.xml");
std::string binaryfile = CreateFilePath(_modelFolder, "anssam.bin");
if (std::filesystem::exists(xmlfile)) {
@@ -81,15 +72,6 @@ namespace ANSCENTER {
try {
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, "ANSSAM::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSAM::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "anssam";
@@ -132,15 +114,6 @@ namespace ANSCENTER {
_modelConfig = modelConfig;
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, "ANSSAM::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSAM::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string xmlfile = CreateFilePath(_modelFolder, "anssam.xml");
std::string binaryfile = CreateFilePath(_modelFolder, "anssam.bin");
if (std::filesystem::exists(xmlfile)) {
@@ -338,7 +311,6 @@ namespace ANSCENTER {
return false;
}
return true;
}
void ANSSAM::ScaleBoxes(cv::Mat& box, const cv::Size& oriSize)
@@ -452,7 +424,6 @@ namespace ANSCENTER {
return binaryMask;
}
std::string ANSSAM::MaskToPolygons(const cv::Mat& image, cv::Rect& boundingBox, std::vector<cv::Point2f>& polygon) {
try {
// image is boxMask: CV_32FC1 with 0.0 / 1.0 → directly convert
@@ -554,7 +525,6 @@ namespace ANSCENTER {
return BuildTensor();
}
cv::Mat ANSSAM::BuildOutput0()
{
auto* ptr = m_request.get_output_tensor(0).data();
-28
View File
@@ -616,7 +616,6 @@ namespace ANSCENTER
return true;
}
// =========================================================================
// EnsureEnginesBuilt — pre-build uncached engines one at a time
// Avoids GPU OOM when building one engine while others are already loaded.
@@ -691,15 +690,6 @@ namespace ANSCENTER
try {
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, "ANSSAM3::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSAM3::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = DetectionType::SEGMENTATION;
if (_modelConfig.modelConfThreshold < 0.1f)
@@ -760,15 +750,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSSAM3::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSAM3::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = DetectionType::SEGMENTATION;
if (_modelConfig.modelConfThreshold < 0.1f)
@@ -827,15 +808,6 @@ namespace ANSCENTER
try {
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, "ANSSAM3::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSAM3::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.detectionType = DetectionType::SEGMENTATION;
-29
View File
@@ -62,15 +62,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "TENSORRTCL::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTCL::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::CLASSIFICATION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 224;
@@ -109,7 +100,6 @@ namespace ANSCENTER
m_options.minInputWidth = _modelConfig.minInputWidth;
m_options.optInputWidth = _modelConfig.optInputWidth;
m_options.engineFileDir = _modelFolder;
// Use FP16 or FP32 precision based on the input flag
m_options.precision = (_fp16 ? Precision::FP16 : Precision::FP32);
@@ -166,15 +156,6 @@ namespace ANSCENTER
try {
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, "TENSORRTCL::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTCL::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -281,15 +262,6 @@ namespace ANSCENTER
try {
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, "TENSORRTCL::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTCL::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::CLASSIFICATION;
@@ -615,7 +587,6 @@ namespace ANSCENTER
clsResult.className = "Unknown"; // Fallback if _classes is empty
}
clsResult.confidence = score;
if (meta.imgWidth > 20 && meta.imgHeight > 20) {
clsResult.box = cv::Rect(10, 10, meta.imgWidth - 20, meta.imgHeight - 20);
-28
View File
@@ -59,15 +59,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSTENSORRTPOSE::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSTENSORRTPOSE::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 640;
@@ -159,15 +150,6 @@ namespace ANSCENTER
{
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, "ANSTENSORRTPOSE::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSTENSORRTPOSE::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.modelType = ModelType::RTPOSE;
@@ -271,15 +253,6 @@ namespace ANSCENTER
_modelLoadValid = false;
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, "ANSTENSORRTPOSE::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSTENSORRTPOSE::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -996,7 +969,6 @@ namespace ANSCENTER
}
}
/*std::vector<Object> ANSTENSORRTPOSE::RunInference(const cv::Mat& inputImgBGR, const std::string& camera_id) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
if (!_modelLoadValid) {
-28
View File
@@ -59,15 +59,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "TENSORRTSEG::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTSEG::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::SEGMENTATION;
_modelConfig.modelType = ModelType::RTSEG;
_modelConfig.inpHeight = 640;
@@ -159,15 +150,6 @@ namespace ANSCENTER
{
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, "TENSORRTSEG::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTSEG::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::SEGMENTATION;
_modelConfig.modelType = ModelType::RTSEG;
@@ -271,15 +253,6 @@ namespace ANSCENTER
_modelLoadValid = false;
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, "TENSORRTSEG::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTSEG::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::SEGMENTATION;
@@ -1155,7 +1128,6 @@ namespace ANSCENTER
}
}
/*std::vector<Object> TENSORRTSEG::RunInference(const cv::Mat& inputImgBGR, const std::string& camera_id) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
if (!_modelLoadValid) {
-27
View File
@@ -63,15 +63,6 @@ namespace ANSCENTER
_isFixedBatch = false;
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "TENSORRTOD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTOD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 640;
@@ -167,15 +158,6 @@ namespace ANSCENTER
_isFixedBatch = false;
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, "TENSORRTOD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTOD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.modelType = ModelType::TENSORRT;
@@ -283,15 +265,6 @@ namespace ANSCENTER
_isFixedBatch = false;
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, "TENSORRTOD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("TENSORRTOD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
-29
View File
@@ -4,7 +4,6 @@
#ifdef USEONNXOV
#endif
namespace ANSCENTER {
bool YOLO12OD::OptimizeModel(bool fp16, std::string& optimizedModelFolder) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
@@ -28,15 +27,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "YOLO12OD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("YOLO12OD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.inpHeight = 640;
_modelConfig.inpWidth = 640;
@@ -96,15 +86,6 @@ namespace ANSCENTER {
try {
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, "YOLO12OD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("YOLO12OD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -178,15 +159,6 @@ namespace ANSCENTER {
try {
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, "YOLO12OD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("YOLO12OD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -501,7 +473,6 @@ namespace ANSCENTER {
}
}
cv::Mat YOLO12OD::preprocess(const cv::Mat& image, std::vector<float>& blob, std::vector<int64_t>& inputTensorShape) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
m_imgWidth = image.cols;
-28
View File
@@ -949,15 +949,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "YOLOOD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("YOLOOD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.inpHeight = 640;
_modelConfig.inpWidth = 640;
@@ -1051,15 +1042,6 @@ namespace ANSCENTER
try {
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, "YOLOOD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("YOLOOD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -1183,15 +1165,6 @@ namespace ANSCENTER
try {
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, "YOLOOD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("YOLOOD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -1877,6 +1850,5 @@ namespace ANSCENTER
this->_logger.LogFatal("YOLOOD::LoadDarknetNetwork()", e.what(), __FILE__, __LINE__);
}
}
}
-28
View File
@@ -37,15 +37,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOYOLOV10OVOD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOYOLOV10OVOD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.modelType = ModelType::OPENVINO;
_modelConfig.inpHeight = 640;
@@ -102,15 +93,6 @@ namespace ANSCENTER
try {
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, "ANSOYOLOV10OVOD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOYOLOV10OVOD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -184,15 +166,6 @@ namespace ANSCENTER
//this->_logger.LogDebug("ANSOYOLOV10OVOD::Initialize. OpenVINO version", openVINOVersion, __FILE__, __LINE__);
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, "ANSOYOLOV10OVOD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOYOLOV10OVOD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -821,7 +794,6 @@ namespace ANSCENTER
return allObjects;
}
std::vector<Object> ANSOYOLOV10OVOD::DetectObjectsBatch(const std::vector<cv::Mat>& inputImages,
const std::string& camera_id) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
-31
View File
@@ -60,15 +60,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSYOLOV10RTOD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSYOLOV10RTOD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 640;
@@ -168,15 +159,6 @@ namespace ANSCENTER
try {
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, "ANSYOLOV10RTOD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSYOLOV10RTOD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -257,7 +239,6 @@ namespace ANSCENTER
if (!_classes.empty())
labelMap = VectorToCommaSeparatedString(_classes);
// 2. Load the TensorRT engine file
if (this->_loadEngineOnCreation) {
auto succ = m_trtEngine->buildLoadNetwork(_modelFilePath, SUB_VALS, DIV_VALS, NORMALIZE, m_maxSlotsPerGpu);
@@ -286,15 +267,6 @@ namespace ANSCENTER
_modelLoadValid = false;
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, "ANSYOLOV10RTOD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSYOLOV10RTOD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
@@ -366,7 +338,6 @@ namespace ANSCENTER
if (!_classes.empty())
labelMap = VectorToCommaSeparatedString(_classes);
// 2. Load the TensorRT engine file
if (this->_loadEngineOnCreation && !engineAlreadyLoaded) {
auto succ = m_trtEngine->buildLoadNetwork(_modelFilePath, SUB_VALS, DIV_VALS, NORMALIZE, m_maxSlotsPerGpu);
@@ -771,7 +742,6 @@ namespace ANSCENTER
roi = cv::Rect(0, 0, _modelConfig.inpWidth, _modelConfig.inpHeight * meta.imgHeight / meta.imgWidth);
}
for (size_t i = 0; i < indices.size(); i++)
{
cv::Mat dest, mask;
@@ -889,7 +859,6 @@ namespace ANSCENTER
return objects;
}
std::vector<std::vector<Object>> ANSYOLOV10RTOD::DetectObjectsBatch(
const std::vector<cv::Mat>& inputImages, const std::string& camera_id)
{
-27
View File
@@ -59,15 +59,6 @@ namespace ANSCENTER
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSYOLOV12RTOD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSYOLOV12RTOD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
_modelConfig.modelType = ModelType::TENSORRT;
_modelConfig.inpHeight = 640;
@@ -161,15 +152,6 @@ namespace ANSCENTER
try {
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, "ANSYOLOV12RTOD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSYOLOV12RTOD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "train_last";
@@ -274,15 +256,6 @@ namespace ANSCENTER
_modelLoadValid = false;
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, "ANSYOLOV12RTOD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSYOLOV12RTOD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// Parsing for YOLO only here
_modelConfig = modelConfig;
_modelConfig.detectionType = ANSCENTER::DetectionType::DETECTION;
-27
View File
@@ -114,15 +114,6 @@ namespace ANSCENTER {
bool ANSMOVIENET::Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) {
bool result = ANSODBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, labelMap);
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSMOVIENET::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSMOVIENET::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
labelMap = "Face";
_licenseValid = true;
std::vector<std::string> labels{ labelMap };
@@ -161,15 +152,6 @@ namespace ANSCENTER {
try {
bool result = ANSODBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSMOVIENET::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSMOVIENET::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
int detectedW = 0, detectedH = 0;
std::string onnxModel = ResolveMovinetModel(_modelFolder, detectedW, detectedH);
@@ -192,15 +174,6 @@ namespace ANSCENTER {
try {
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, "ANSMOVIENET::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSMOVIENET::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
_modelConfig = modelConfig;
_modelConfig.modelType = ModelType::MOVIENET;
@@ -3,15 +3,6 @@
namespace ANSCENTER {
bool ANSRETINAFD::Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) {
bool result = ANSFDBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, labelMap);
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSRETINAFD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSRETINAFD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// We do not need to check for the license
_licenseValid = true;
if (!_licenseValid) return false;
@@ -70,15 +61,6 @@ namespace ANSCENTER {
// We need to get the _modelFolder
bool result = ANSFDBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSRETINAFD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSRETINAFD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// We need to get the modelfolder from here
std::string onnxfile = CreateFilePath(_modelFolder, "retinaface.onnx");
@@ -270,7 +252,6 @@ namespace ANSCENTER {
}
}
ANSRETINAFD::~ANSRETINAFD() {
try {
// if (_faceDectector) {
-30
View File
@@ -14,15 +14,6 @@ namespace ANSCENTER {
// Call base class Initialize
bool result = ANSFDBase::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, "ANSSCRFDFD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSCRFDFD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
labelMap = "Face";
_licenseValid = true;
try {
@@ -84,15 +75,6 @@ namespace ANSCENTER {
// We need to get the _modelFolder
bool result = ANSFDBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSSCRFDFD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSCRFDFD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
const bool engineAlreadyLoaded = _isInitialized && m_trtEngine != nullptr;
_modelConfig.modelType = ModelType::FACEDETECT;
_modelConfig.detectionType = DetectionType::FACEDETECTOR;
@@ -151,15 +133,6 @@ namespace ANSCENTER {
// We need to get the _modelFolder
bool result = ANSFDBase::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, "ANSSCRFDFD::LoadModelFromFolder");
if (!_flg.acquired()) {
this->_logger.LogError("ANSSCRFDFD::LoadModelFromFolder",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
std::string _modelName = modelName;
if (_modelName.empty()) {
_modelName = "scrfdface";
@@ -437,8 +410,6 @@ namespace ANSCENTER {
return output;
}
std::vector<Object> ANSSCRFDFD::InferenceDynamic(const cv::Mat& input, const std::string& camera_id) {
if (_modelLoading.load()) return {};
auto lock = TryLockWithTimeout("ANSSCRFDFD::InferenceDynamic");
@@ -602,7 +573,6 @@ namespace ANSCENTER {
return output;
}
std::vector<Object> ANSSCRFDFD::Detect(const cv::Mat& input)
{
// Phase 1: Validation + engine dims (brief lock)
@@ -5,15 +5,6 @@
namespace ANSCENTER {
bool ANSOVSCRFDFD::Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) {
bool result = ANSFDBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, labelMap);
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOVSCRFDFD::Initialize");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVSCRFDFD::Initialize",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
labelMap = "Face";
// We do not need to check for the license
_licenseValid = true;
@@ -46,7 +37,6 @@ namespace ANSCENTER {
<< model->input().get_any_name() << "' will be used." << slog::endl;
}
const ov::Layout& inputLayout = layout;
//ppp.input().tensor().set_element_type(ov::element::u8).set_layout("NHWC").set_color_format(ov::preprocess::ColorFormat::BGR);
@@ -70,7 +60,6 @@ namespace ANSCENTER {
int outputSize = model->outputs().size();
std::cout << "output Size:" << outputSize << std::endl;
const ov::Layout outputLayout{ "CHW" };
maxProposalsCount = model->outputs().front().get_shape()[ov::layout::height_idx(outputLayout)];
for (const auto& output : model->outputs()) {
@@ -110,15 +99,6 @@ namespace ANSCENTER {
// We need to get the _modelFolder
bool result = ANSFDBase::LoadModel(modelZipFilePath, modelZipPassword);
if (!result) return false;
// Serialize derived init against concurrent extract re-entries on the
// same folder. See ModelFolderLockGuard in ANSEngineCommon.h.
ModelFolderLockGuard _flg(_modelFolder, "ANSOVSCRFDFD::LoadModel");
if (!_flg.acquired()) {
this->_logger.LogError("ANSOVSCRFDFD::LoadModel",
"Timed out waiting for model-folder lock: " + _modelFolder,
__FILE__, __LINE__);
return false;
}
// We need to get the modelfolder from here
std::string xmlfile = CreateFilePath(_modelFolder, "scrfdface.xml");
@@ -257,7 +237,6 @@ namespace ANSCENTER {
// Perform inference
inference_request_.infer();
std::cout << "Model outputs:" << std::endl;
auto ovOutputs= compiled_model_.outputs();
for (int i = 0; i < ovOutputs.size();i++) {
@@ -288,7 +267,6 @@ namespace ANSCENTER {
std::cout << "Total valid detections: " << valid_detections.size() << std::endl;
/* float* score = inference_request_.get_output_tensor(2).data<float>();
//if (score != nullptr) {
// std::cout << "Score:" << score[0]<<std::endl;
@@ -296,7 +274,6 @@ namespace ANSCENTER {
float* bbox = inference_request_.get_output_tensor(5).data<float>();*/
// Get the output tensor
//// Step 0: Prepare input
//this->PreprocessImage(im);