Remove locks
This commit is contained in:
@@ -103,7 +103,10 @@
|
||||
"Bash(echo \"Exit: $?\")",
|
||||
"Bash(python -)",
|
||||
"Bash(git show *)",
|
||||
"Bash(dumpbin //dependents \"C:\\\\\\\\ProgramData\\\\\\\\ANSCENTER\\\\\\\\Shared\\\\\\\\ANSLicensingSystem.dll\")"
|
||||
"Bash(dumpbin //dependents \"C:\\\\\\\\ProgramData\\\\\\\\ANSCENTER\\\\\\\\Shared\\\\\\\\ANSLicensingSystem.dll\")",
|
||||
"Bash(grep -v \"//\")",
|
||||
"Bash(grep -v \"^ *//\")",
|
||||
"Bash(python strip_folder_lock.py)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
#include "Utility.h"
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
// Bounded wait when acquiring GetZipPathLock inside extractor/writer entry
|
||||
// points. A genuine extract is seconds, but adversarial I/O (slow NAS,
|
||||
// antivirus holding files, libzip hang on malformed archive, a crashed
|
||||
// thread that never unwound the lock) can make it block indefinitely.
|
||||
// 15 minutes is generous enough for large models on slow storage yet short
|
||||
// enough that a service-wide hang turns into a localized load-failure
|
||||
// visible in DebugView.
|
||||
static constexpr auto kZipPathLockTimeout = std::chrono::minutes(15);
|
||||
|
||||
// Per-path mutex to serialize concurrent zip operations on the same target.
|
||||
// Without this, two LabVIEW threads can race: one extracting a zip while
|
||||
// another truncates/writes the same file, corrupting data and crashing LabVIEW.
|
||||
// Also used to serialize extract ↔ ONNX session creation on the same extracted
|
||||
// model folder — without that, thread A can finish extraction and begin opening
|
||||
// train_last.onnx while thread B re-enters extraction and truncates the file,
|
||||
// producing "system error number 13" (EACCES) on the first reader.
|
||||
// Recursive so the same thread can re-acquire the lock through layered load
|
||||
// calls — ANSALPR_OD::LoadEngine -> ANSONNXYOLO::LoadModelFromFolder both
|
||||
// acquire the SAME folder lock on the SAME thread. A non-recursive
|
||||
// timed_mutex deadlocks that nesting for 120 s then fails. Recursive keeps
|
||||
// cross-thread serialization intact while allowing legitimate re-entry from
|
||||
// the lock-holding thread.
|
||||
// Scope is limited to the extractor / zip writer — once ExtractProtectedZipFile
|
||||
// returns, the sidecar check makes subsequent calls fast no-ops, and readers
|
||||
// (ORT / TRT session create) access stable files concurrently with no lock.
|
||||
static std::mutex g_zipPathMapMutex;
|
||||
static std::map<std::string, std::shared_ptr<std::recursive_timed_mutex>> g_zipPathLocks;
|
||||
|
||||
@@ -27,13 +30,6 @@ static std::shared_ptr<std::recursive_timed_mutex> GetZipPathLock(const std::str
|
||||
return ptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<std::recursive_timed_mutex> GetModelFolderLock(const std::string& folderPath) {
|
||||
auto ptr = GetZipPathLock(folderPath);
|
||||
ANS_DBG("ModelLock", "GetModelFolderLock: folder=%s mutex=%p",
|
||||
folderPath.c_str(), (void*)ptr.get());
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get_data(const boost::property_tree::ptree& pt, const std::string& key)
|
||||
{
|
||||
@@ -470,7 +466,17 @@ bool AddFolderContentsToZip(zip* archive, const char* folderPath, const char* zi
|
||||
|
||||
bool ZipFolderWithPassword(const char* folderPath, const char* zipFilePath, const char* password) {
|
||||
auto pathLock = GetZipPathLock(std::string(zipFilePath));
|
||||
std::lock_guard<std::recursive_timed_mutex> zipGuard(*pathLock);
|
||||
ANS_DBG("Extract", "ZipFolderWithPassword: waiting on zip lock (%llds): %s",
|
||||
(long long)std::chrono::duration_cast<std::chrono::seconds>(kZipPathLockTimeout).count(),
|
||||
zipFilePath ? zipFilePath : "(null)");
|
||||
std::unique_lock<std::recursive_timed_mutex> zipGuard(*pathLock, std::defer_lock);
|
||||
if (!zipGuard.try_lock_for(kZipPathLockTimeout)) {
|
||||
ANS_DBG("Extract", "ZipFolderWithPassword: TIMEOUT acquiring zip lock for %s",
|
||||
zipFilePath ? zipFilePath : "(null)");
|
||||
return false;
|
||||
}
|
||||
ANS_DBG("Extract", "ZipFolderWithPassword: zip lock acquired: %s",
|
||||
zipFilePath ? zipFilePath : "(null)");
|
||||
|
||||
zip* zipArchive;
|
||||
zip_flags_t flags = ZIP_CREATE | ZIP_TRUNCATE;
|
||||
@@ -856,7 +862,16 @@ std::string GetDateTimeString(const std::string& format) {
|
||||
bool ExtractProtectedZipFile(const std::string& zipFileName, const std::string& password, const std::string& modelName, const std::string outputFolder)
|
||||
{
|
||||
auto pathLock = GetZipPathLock(outputFolder);
|
||||
std::lock_guard<std::recursive_timed_mutex> zipGuard(*pathLock);
|
||||
ANS_DBG("Extract", "ExtractProtectedZipFile: waiting on zip lock (%llds): %s",
|
||||
(long long)std::chrono::duration_cast<std::chrono::seconds>(kZipPathLockTimeout).count(),
|
||||
outputFolder.c_str());
|
||||
std::unique_lock<std::recursive_timed_mutex> zipGuard(*pathLock, std::defer_lock);
|
||||
if (!zipGuard.try_lock_for(kZipPathLockTimeout)) {
|
||||
ANS_DBG("Extract", "ExtractProtectedZipFile: TIMEOUT acquiring zip lock for %s (zip=%s)",
|
||||
outputFolder.c_str(), zipFileName.c_str());
|
||||
return false;
|
||||
}
|
||||
ANS_DBG("Extract", "ExtractProtectedZipFile: zip lock acquired: %s", outputFolder.c_str());
|
||||
|
||||
int error;
|
||||
if (!FileExist(zipFileName))return false;
|
||||
|
||||
@@ -92,118 +92,5 @@ namespace fs = std::filesystem;
|
||||
//bool ExtractPasswordProtectedZipForTrainingEgnine(const std::string& zipFileName, const std::string& password, const std::string& modelName, std::string& outputFolder, bool edgeDeviceModel = true);
|
||||
ANSLICENSE_API bool ExtractProtectedZipFile(const std::string& zipFileName,const std::string& password,const std::string& modelName,const std::string outputFolder);
|
||||
|
||||
// Per-path mutex for a model folder. Used to serialize extract ↔ session
|
||||
// creation on the same extracted folder so concurrent CreateANSODHandle calls
|
||||
// cannot truncate/rewrite a model file while another thread is loading it.
|
||||
// Keyed by folder path (not zip path) so both extractor and consumer agree.
|
||||
// Returns std::recursive_timed_mutex so callers can bound their wait and
|
||||
// recursion — layered load paths (e.g. ANSALPR_OD::LoadEngine ->
|
||||
// ANSONNXYOLO::LoadModelFromFolder) legitimately re-enter on the same
|
||||
// thread; a non-recursive timed_mutex self-deadlocks that nesting. Cross-
|
||||
// thread serialization is unchanged.
|
||||
ANSLICENSE_API std::shared_ptr<std::recursive_timed_mutex> GetModelFolderLock(const std::string& folderPath);
|
||||
|
||||
// ============================================================================
|
||||
// ModelFolderLockGuard
|
||||
//
|
||||
// RAII guard that serializes "open files in an extracted model folder" against
|
||||
// re-entries into ExtractProtectedZipFile on the SAME folder. Without this,
|
||||
// two threads creating handles for the same model zip can race so that thread
|
||||
// A opens a model file (via ORT / TRT / OpenVINO) while thread B truncates it
|
||||
// via std::ofstream inside the extractor — Windows surfaces this as "system
|
||||
// error number 13" (EACCES) on the reader.
|
||||
//
|
||||
// Backed by GetModelFolderLock() above which returns a process-wide
|
||||
// std::recursive_timed_mutex keyed on the folder path. The extractor takes
|
||||
// the same lock, so extract ↔ open is mutually exclusive across threads,
|
||||
// while same-thread re-entry (layered loaders) is permitted without
|
||||
// deadlocking.
|
||||
//
|
||||
// Acquisition is bounded by `timeout` (default 120 s) so a deadlocked peer
|
||||
// cannot hang the caller thread forever. On timeout, .acquired() is false and
|
||||
// the caller must fail the load.
|
||||
//
|
||||
// Lives in Utility.h (rather than a per-module header) so every ANSCORE
|
||||
// module — ANSODEngine, ANSOCR, ANSLPR, ANSFR, etc. — can use it without
|
||||
// pulling in ANSODEngine headers.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// bool MyEngine::LoadModelFromFolder(...) {
|
||||
// bool result = MyBase::LoadModelFromFolder(...);
|
||||
// if (!result) return false;
|
||||
// // ── serialize derived-class init against concurrent extracts ──
|
||||
// ANSCENTER::ModelFolderLockGuard _flg(_modelFolder,
|
||||
// "MyEngine::LoadModelFromFolder");
|
||||
// if (!_flg.acquired()) {
|
||||
// _logger.LogError("MyEngine::LoadModelFromFolder",
|
||||
// "Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
// __FILE__, __LINE__);
|
||||
// return false;
|
||||
// }
|
||||
// // ... existing body: Init(...) / buildLoadNetwork(...) / etc. ...
|
||||
// }
|
||||
//
|
||||
// Notes:
|
||||
// • Placement — insert AFTER the base's XXX() returns (extractor already
|
||||
// released its own lock by then) and BEFORE any file open in _modelFolder.
|
||||
// Wrapping the base call would deadlock — it takes the same lock itself.
|
||||
// • RAII — destructor auto-releases on every return path within the scope.
|
||||
// • Timing — entry/acquire/timeout are traced via ANS_DBG("EngineLoad"),
|
||||
// filter on [EngineLoad] in DebugView to diagnose stalls.
|
||||
// ============================================================================
|
||||
namespace ANSCENTER {
|
||||
class ModelFolderLockGuard {
|
||||
public:
|
||||
explicit ModelFolderLockGuard(const std::string& folderPath,
|
||||
const char* caller,
|
||||
std::chrono::seconds timeout = std::chrono::seconds(120))
|
||||
: _caller(caller ? caller : "(?)"), _folder(folderPath)
|
||||
{
|
||||
if (folderPath.empty()) {
|
||||
// Nothing to serialize — no extracted folder yet. Treat as
|
||||
// acquired so caller's existing init runs unchanged (e.g.
|
||||
// custom-path engines that never go through the zip extractor).
|
||||
_ok = true;
|
||||
ANS_DBG("EngineLoad", "%s: empty folder path, skipping lock",
|
||||
_caller);
|
||||
return;
|
||||
}
|
||||
auto lock = GetModelFolderLock(folderPath);
|
||||
_guard = std::unique_lock<std::recursive_timed_mutex>(*lock, std::defer_lock);
|
||||
ANS_DBG("EngineLoad",
|
||||
"%s: waiting on folder lock (%llds): %s",
|
||||
_caller, (long long)timeout.count(), folderPath.c_str());
|
||||
const auto t0 = std::chrono::steady_clock::now();
|
||||
if (_guard.try_lock_for(timeout)) {
|
||||
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - t0).count();
|
||||
_ok = true;
|
||||
ANS_DBG("EngineLoad", "%s: folder lock acquired in %lldms",
|
||||
_caller, (long long)ms);
|
||||
} else {
|
||||
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now() - t0).count();
|
||||
_ok = false;
|
||||
ANS_DBG("EngineLoad",
|
||||
"%s: TIMEOUT on folder lock after %lldms: %s",
|
||||
_caller, (long long)ms, folderPath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Non-copyable, non-movable: lock lifetime is tied to this scope.
|
||||
ModelFolderLockGuard(const ModelFolderLockGuard&) = delete;
|
||||
ModelFolderLockGuard& operator=(const ModelFolderLockGuard&) = delete;
|
||||
|
||||
bool acquired() const noexcept { return _ok; }
|
||||
explicit operator bool() const noexcept { return _ok; }
|
||||
|
||||
private:
|
||||
const char* _caller;
|
||||
std::string _folder;
|
||||
std::unique_lock<std::recursive_timed_mutex> _guard;
|
||||
bool _ok = false;
|
||||
};
|
||||
} // namespace ANSCENTER
|
||||
|
||||
#endif
|
||||
@@ -55,15 +55,6 @@ namespace ANSCENTER {
|
||||
ANS_DBG("FaceRecognizer", "ANSFRBase::Initialize FAILED");
|
||||
return false;
|
||||
}
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSFR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSFR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
#ifdef CPU_MODE
|
||||
engineType = EngineType::CPU;
|
||||
ANS_DBG("FaceRecognizer", "CPU_MODE forced: engineType=CPU");
|
||||
@@ -208,15 +199,6 @@ namespace ANSCENTER {
|
||||
try {
|
||||
bool result = ANSFRBase::LoadModel(modelZipFilePath, modelZipPassword);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSFaceRecognizer::LoadModel");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSFaceRecognizer::LoadModel",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (engineType == EngineType::NVIDIA_GPU) {
|
||||
std::string onnxfile = CreateFilePath(_modelFolder, "ansfacerecognizer.onnx");
|
||||
@@ -1280,8 +1262,6 @@ namespace ANSCENTER {
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Old method
|
||||
//std::tuple<std::vector<std::string>, std::vector<float>> ANSFaceRecognizer::SearchForFaces(std::vector<std::vector<float>> detectedEmbeddings) {
|
||||
// std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
@@ -1556,8 +1536,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
|
||||
// Before refactor (working version)
|
||||
/*std::vector<float> ANSFaceRecognizer::Feature(const cv::Mat& image,
|
||||
ANSCENTER::Object bBox) {
|
||||
@@ -2114,8 +2092,6 @@ namespace ANSCENTER {
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// std::vector<std::vector<float>> ANSFaceRecognizer::Forward(const cv::Mat& input, std::vector<ANSCENTER::Object> outputBbox)
|
||||
// {
|
||||
// std::vector<std::vector<float>> detectedEmbeddings;
|
||||
|
||||
@@ -9,15 +9,6 @@ namespace ANSCENTER {
|
||||
std::string& labelMap) {
|
||||
bool result = ANSFRBase::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 Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ArcFace::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ArcFace::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
_modelConfig = modelConfig;
|
||||
@@ -80,15 +71,6 @@ namespace ANSCENTER {
|
||||
try {
|
||||
bool result = ANSFRBase::LoadModel(modelZipFilePath, modelZipPassword);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ArcFace::LoadModel");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ArcFace::LoadModel",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string onnxfile50 = CreateFilePath(_modelFolder, "ansfacerecognizer50.onnx");
|
||||
if (std::filesystem::exists(onnxfile50)) {
|
||||
|
||||
@@ -20,15 +20,6 @@ namespace ANSCENTER {
|
||||
{
|
||||
bool result = ANSFRBase::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 Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSFaceNet::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSFaceNet::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
_modelConfig = modelConfig;
|
||||
_modelConfig.modelType = ModelType::FACERECOGNIZE;
|
||||
@@ -74,15 +65,6 @@ namespace ANSCENTER {
|
||||
// We need to get the _modelFolder
|
||||
bool result = ANSFRBase::LoadModel(modelZipFilePath, modelZipPassword);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSFaceNet::LoadModel");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSFaceNet::LoadModel",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
// We need to get the modelfolder from here
|
||||
std::string faceidModel = CreateFilePath(_modelFolder, "ansfacenet.xml");
|
||||
if (std::filesystem::exists(faceidModel)) {
|
||||
|
||||
@@ -518,15 +518,6 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSFDBase::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 init against concurrent extract re-entries on the same
|
||||
// folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSALPR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
|
||||
@@ -304,15 +304,6 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSALPR_CPU::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 init against concurrent extract re-entries on the same
|
||||
// folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_CPU::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSALPR_CPU::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3. Load LD model
|
||||
alprChecker.Init(MAX_ALPR_FRAME);
|
||||
@@ -326,15 +317,6 @@ namespace ANSCENTER {
|
||||
bool ANSALPR_CPU::LoadEngine() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
try {
|
||||
// Serialize init against concurrent extract re-entries on the same
|
||||
// folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_CPU::LoadEngine");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSALPR_CPU::LoadEngine",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
// 1. Load license plate detection model (using CPU OpenVINO)
|
||||
if (_lprDetector) _lprDetector.reset();
|
||||
std::string lprModel = CreateFilePath(_modelFolder, "lprModel.xml");
|
||||
@@ -460,7 +442,6 @@ namespace ANSCENTER {
|
||||
float iouThreshold = 0.4;
|
||||
std::vector<Object> lprOutput = ANSUtilityHelper::ApplyNMS(lprOutputRaw, iouThreshold);
|
||||
|
||||
|
||||
if (!lprOutput.empty()) {
|
||||
if (!ppocr) {
|
||||
this->_logger.LogFatal("ANSALPR_CPU::Inference", "PPOCR instance is null", __FILE__, __LINE__);
|
||||
@@ -923,7 +904,6 @@ namespace ANSCENTER {
|
||||
// std::string numberCode = cleanOCRText.substr(7, 2);// 00 to 99
|
||||
// std::string newSuburbCode = convertStringToDigits(suburbCode);
|
||||
|
||||
|
||||
// // Convert the newSuburbCode to an integer
|
||||
// int numericValue = std::stoi(newSuburbCode);
|
||||
// // Check if it is within the range 11 to 99
|
||||
@@ -986,7 +966,6 @@ namespace ANSCENTER {
|
||||
// std::string numberCode = cleanOCRText.substr(7, 3);// 00 to 99
|
||||
// std::string newSuburbCode = convertStringToDigits(suburbCode);
|
||||
|
||||
|
||||
// // Convert the newSuburbCode to an integer
|
||||
// int numericValue = std::stoi(newSuburbCode);
|
||||
// // Check if it is within the range 11 to 99
|
||||
@@ -1280,7 +1259,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Align plate
|
||||
cv::Mat ANSALPR_CPU::alignPlateForOCR(const cv::Mat& fullImage, const cv::Rect& bbox) {
|
||||
try {
|
||||
|
||||
@@ -177,15 +177,6 @@ namespace ANSCENTER
|
||||
this->_logger.LogError("ANSALPR_OCR::Initialize", "Output model folder does not exist: " + _modelFolder, __FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
// Serialize init against concurrent extract re-entries on the same
|
||||
// folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSALPR_OCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check country from country.txt
|
||||
std::string countryFile = CreateFilePath(_modelFolder, "country.txt");
|
||||
@@ -225,15 +216,6 @@ namespace ANSCENTER
|
||||
bool ANSALPR_OCR::LoadEngine() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
try {
|
||||
// Serialize init against concurrent extract re-entries on the same
|
||||
// folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OCR::LoadEngine");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSALPR_OCR::LoadEngine",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
WriteEventLog("ANSALPR_OCR::LoadEngine: Step 1 - Starting engine load");
|
||||
this->_logger.LogInfo("ANSALPR_OCR::LoadEngine", "Step 1: Starting engine load", __FILE__, __LINE__);
|
||||
|
||||
|
||||
@@ -431,15 +431,6 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSALPR_OD::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 init against concurrent extract re-entries on the same
|
||||
// folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OD::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSALPR_OD::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check country
|
||||
std::string countryFile = CreateFilePath(_modelFolder, "country.txt");
|
||||
@@ -518,15 +509,6 @@ namespace ANSCENTER {
|
||||
bool ANSALPR_OD::LoadEngine() {
|
||||
std::lock_guard<std::recursive_mutex> lock(_mutex);
|
||||
try {
|
||||
// Serialize init against concurrent extract re-entries on the same
|
||||
// folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSALPR_OD::LoadEngine");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSALPR_OD::LoadEngine",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
WriteEventLog("ANSALPR_OD::LoadEngine: Step 1 - Starting engine load");
|
||||
this->_logger.LogInfo("ANSALPR_OD::LoadEngine", "Step 1: Starting engine load", __FILE__, __LINE__);
|
||||
|
||||
@@ -547,7 +529,6 @@ namespace ANSCENTER {
|
||||
_lpColourModelConfig.modelConfThreshold = 0.5;
|
||||
_lpColourModelConfig.modelMNSThreshold = 0.5;
|
||||
|
||||
|
||||
_lpdmodelConfig.inpHeight = 640;
|
||||
_lpdmodelConfig.inpWidth = 640;
|
||||
|
||||
@@ -578,7 +559,6 @@ namespace ANSCENTER {
|
||||
_lpColourModelConfig.optInputHeight = 224;
|
||||
_lpColourModelConfig.optInputWidth = 224;
|
||||
|
||||
|
||||
std::string lprModel = CreateFilePath(_modelFolder, "lpd.onnx");
|
||||
std::string lprClassesFile = CreateFilePath(_modelFolder, "lpd.names");
|
||||
|
||||
@@ -1364,7 +1344,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if this is actually a single row
|
||||
// If max gap is too small relative to character height, it's a single row
|
||||
std::vector<std::vector<Object>> rows;
|
||||
@@ -3086,7 +3065,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (maxGap < avgHeight * ROW_SPLIT_MIN_GAP_FACTOR) {
|
||||
// Single row - sort by projection along reading direction
|
||||
std::vector<std::pair<float, size_t>> allProj;
|
||||
@@ -3119,7 +3097,6 @@ namespace ANSCENTER {
|
||||
if (avgY0 > avgY1)
|
||||
std::swap(rowIndices[0], rowIndices[1]);
|
||||
|
||||
|
||||
// Sort each row by projection along reading direction
|
||||
std::string ocrText;
|
||||
ocrText.reserve(n);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <omp.h>
|
||||
#include <include/paddleocr_utility.h>
|
||||
|
||||
|
||||
namespace ANSCENTER {
|
||||
|
||||
bool ANSCPUOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelConfig,
|
||||
@@ -13,15 +12,6 @@ namespace ANSCENTER {
|
||||
{
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSCPUOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSCPUOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Override the paddleocrv3 for openvino only
|
||||
switch (_modelConfig.ocrLanguage) {
|
||||
@@ -442,7 +432,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSCPUOCR::RunInference(const cv::Mat& input,
|
||||
const std::vector<cv::Rect>& Bbox,
|
||||
const std::string& cameraId)
|
||||
|
||||
@@ -9,15 +9,6 @@ namespace ANSCENTER {
|
||||
{
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
auto option = fastdeploy::RuntimeOption();
|
||||
// Add default values to modelConfig if required.
|
||||
_modelConfig.precisionType = "fp32";
|
||||
@@ -117,8 +108,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSOCR::RunInference(const cv::Mat& input) {
|
||||
std::vector<ANSCENTER::OCRObject> OCRObjects;
|
||||
if (input.empty()) return OCRObjects;
|
||||
@@ -184,7 +173,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSOCR::RunInference(const cv::Mat& input, const std::vector<cv::Rect>& Bbox) {
|
||||
// No coarse _mutex — ppOCR->Predict() / engine has its own internal lock
|
||||
std::vector<ANSCENTER::OCRObject> OCRObjects;
|
||||
@@ -278,7 +266,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<ANSCENTER::OCRObject> ANSOCR::RunInference(const cv::Mat& input, const std::vector<cv::Rect>& Bbox, const std::string& cameraId) {
|
||||
// No coarse _mutex — ppOCR->Predict() / engine has its own internal lock
|
||||
std::vector<ANSCENTER::OCRObject> OCRObjects;
|
||||
@@ -348,7 +335,6 @@ namespace ANSCENTER {
|
||||
ocrObject.box.width = rook_points[1].x - rook_points[0].x;
|
||||
ocrObject.box.height = rook_points[2].y - rook_points[1].y;
|
||||
|
||||
|
||||
ocrObject.classId = res_ocr.cls_labels[n];
|
||||
ocrObject.confidence = res_ocr.rec_scores[n];
|
||||
ocrObject.className = res_ocr.text[n];
|
||||
|
||||
@@ -71,7 +71,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
_licenseValid = true;
|
||||
|
||||
|
||||
// 0. Check if the modelZipFilePath exist?
|
||||
if (!FileExist(modelZipFilePath)) {
|
||||
this->_logger.LogFatal("ANSOCRBase::Initialize", "Model zip file is not exist", __FILE__, __LINE__);
|
||||
@@ -96,15 +95,6 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize. Output model folder is not exist", modelName, __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 Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCRBase::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -133,7 +123,6 @@ namespace ANSCENTER {
|
||||
}
|
||||
_licenseValid = true;
|
||||
|
||||
|
||||
// 0. Check if the modelZipFilePath exist?
|
||||
if (!FileExist(modelZipFilePath)) {
|
||||
this->_logger.LogFatal("ANSOCRBase::Initialize", "Model zip file is not exist", __FILE__, __LINE__);
|
||||
@@ -158,15 +147,6 @@ namespace ANSCENTER {
|
||||
this->_logger.LogError("ANSOCRBase::Initialize. Output model folder is not exist", modelName, __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 Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSOCRBase::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSOCRBase::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);
|
||||
@@ -365,7 +345,6 @@ namespace ANSCENTER {
|
||||
return polygon;
|
||||
}
|
||||
|
||||
|
||||
// ── ALPR Configuration Methods ──────────────────────────────────────
|
||||
|
||||
void ANSOCRBase::SetOCRMode(OCRMode mode) { _ocrMode = mode; }
|
||||
@@ -938,5 +917,3 @@ namespace ANSCENTER {
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,15 +9,6 @@ bool ANSONNXOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelC
|
||||
try {
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSONNXOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSONNXOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate detection model
|
||||
if (!FileExist(_modelConfig.detectionModelFile)) {
|
||||
|
||||
@@ -9,15 +9,6 @@ bool ANSRTOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelCon
|
||||
try {
|
||||
bool result = ANSOCRBase::Initialize(licenseKey, modelConfig, modelZipFilePath, modelZipPassword, engineMode);
|
||||
if (!result) return false;
|
||||
// Serialize derived init against concurrent extract re-entries on the
|
||||
// same folder. See ModelFolderLockGuard in Utility.h.
|
||||
ANSCENTER::ModelFolderLockGuard _flg(_modelFolder, "ANSRTOCR::Initialize");
|
||||
if (!_flg.acquired()) {
|
||||
this->_logger.LogError("ANSRTOCR::Initialize",
|
||||
"Timed out waiting for model-folder lock: " + _modelFolder,
|
||||
__FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate detection model
|
||||
if (!FileExist(_modelConfig.detectionModelFile)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"):
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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__);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user