- Remove ALPR_OD Tracker and voting system.
- Disable debugview
This commit is contained in:
@@ -62,6 +62,8 @@ extern "C" ANSODENGINE_API GpuFrameData** ANSODEngine_GetTlsGpuFrame() {
|
||||
#include <unordered_set>
|
||||
#include <mutex>
|
||||
|
||||
// DebugView: filter on "[ANSOD]" — gated by ANSCORE_DEBUGVIEW in ANSLicense.h.
|
||||
|
||||
// Handle registry with refcount — prevents use-after-free when
|
||||
// ReleaseANSODHandle is called while inference is still running.
|
||||
// refcount: starts at 1 on Register. AcquireODHandle increments,
|
||||
@@ -213,6 +215,8 @@ static std::condition_variable& ODHandleRegistryCV() {
|
||||
static void RegisterODHandle(ANSCENTER::ANSODBase* h) {
|
||||
std::lock_guard<std::mutex> lk(ODHandleRegistryMutex());
|
||||
ODHandleRegistry()[h] = { 1, false };
|
||||
ANS_DBG("ANSOD","Register: handle=%p (uint=%llu) registrySize=%zu",
|
||||
(void*)h, (unsigned long long)(uintptr_t)h, ODHandleRegistry().size());
|
||||
}
|
||||
|
||||
// Acquire a handle for use (increment refcount). Returns the handle
|
||||
@@ -220,9 +224,23 @@ static void RegisterODHandle(ANSCENTER::ANSODBase* h) {
|
||||
static ANSCENTER::ANSODBase* AcquireODHandle(ANSCENTER::ANSODBase* h) {
|
||||
std::lock_guard<std::mutex> lk(ODHandleRegistryMutex());
|
||||
auto it = ODHandleRegistry().find(h);
|
||||
if (it == ODHandleRegistry().end()) return nullptr;
|
||||
if (it->second.destructionStarted) return nullptr;
|
||||
if (it == ODHandleRegistry().end()) {
|
||||
ANS_DBG("ANSOD","Acquire FAIL: handle=%p (uint=%llu) NOT in registry. registrySize=%zu",
|
||||
(void*)h, (unsigned long long)(uintptr_t)h, ODHandleRegistry().size());
|
||||
size_t i = 0;
|
||||
for (auto& kv : ODHandleRegistry()) {
|
||||
ANS_DBG("ANSOD"," registry[%zu] = %p (uint=%llu) refcount=%d destructionStarted=%d",
|
||||
i++, (void*)kv.first, (unsigned long long)(uintptr_t)kv.first,
|
||||
kv.second.refcount, kv.second.destructionStarted ? 1 : 0);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
if (it->second.destructionStarted) {
|
||||
ANS_DBG("ANSOD","Acquire FAIL: handle=%p is being destroyed (destructionStarted=true)", (void*)h);
|
||||
return nullptr;
|
||||
}
|
||||
it->second.refcount++;
|
||||
ANS_DBG("ANSOD","Acquire OK: handle=%p refcount=%d", (void*)h, it->second.refcount);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -244,10 +262,15 @@ static bool ReleaseODHandleRef(ANSCENTER::ANSODBase* h) {
|
||||
static bool UnregisterODHandle(ANSCENTER::ANSODBase* h) {
|
||||
std::unique_lock<std::mutex> lk(ODHandleRegistryMutex());
|
||||
auto it = ODHandleRegistry().find(h);
|
||||
if (it == ODHandleRegistry().end()) return false;
|
||||
if (it == ODHandleRegistry().end()) {
|
||||
ANS_DBG("ANSOD","Unregister: handle=%p NOT in registry (already gone)", (void*)h);
|
||||
return false;
|
||||
}
|
||||
if (it->second.destructionStarted) {
|
||||
ANS_DBG("ANSOD","Unregister: handle=%p already being destroyed by another thread, returning false", (void*)h);
|
||||
return false; // Another thread already owns the delete.
|
||||
}
|
||||
ANS_DBG("ANSOD","Unregister: handle=%p starting (refcount before=%d)", (void*)h, it->second.refcount);
|
||||
it->second.destructionStarted = true;
|
||||
it->second.refcount--; // Remove creation ref
|
||||
// Wait for in-flight inferences to finish (30s timeout as safety net)
|
||||
@@ -256,6 +279,7 @@ static bool UnregisterODHandle(ANSCENTER::ANSODBase* h) {
|
||||
return it2 == ODHandleRegistry().end() || it2->second.refcount <= 0;
|
||||
});
|
||||
if (!ok) {
|
||||
ANS_DBG("ANSOD","WARNING: Unregister timed out waiting for in-flight operations on handle=%p", (void*)h);
|
||||
OutputDebugStringA("WARNING: UnregisterODHandle timed out waiting for in-flight inference\n");
|
||||
}
|
||||
ODHandleRegistry().erase(h);
|
||||
@@ -361,7 +385,11 @@ extern "C" ANSODENGINE_API std::string CreateANSODHandle(ANSCENTER::ANSODBase**
|
||||
int detectionType,
|
||||
int loadEngineOnCreation)
|
||||
{
|
||||
if (Handle == nullptr) return "";
|
||||
ANS_DBG("ANSOD","CreateANSODHandle: HandlePtr=%p, *Handle(in)=%p, modelType=%d, detectionType=%d, autoDetectEngine=%d, loadOnCreate=%d, modelPath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
|
||||
modelType, detectionType, autoDetectEngine, loadEngineOnCreation,
|
||||
modelFilePath ? modelFilePath : "(null)");
|
||||
if (Handle == nullptr) { ANS_DBG("ANSOD","CreateANSODHandle FAIL: Handle is null"); return ""; }
|
||||
|
||||
// NOTE: We intentionally do NOT destroy any existing *Handle here.
|
||||
// LabVIEW reuses DLL parameter buffer addresses, so *Handle may point
|
||||
@@ -667,9 +695,12 @@ extern "C" ANSODENGINE_API std::string CreateANSODHandle(ANSCENTER::ANSODBase**
|
||||
break;
|
||||
}
|
||||
if (*Handle == nullptr) {
|
||||
ANS_DBG("ANSOD","CreateANSODHandle FAIL: allocation produced null handle (modelType=%d)", modelType);
|
||||
return labelMap;
|
||||
}
|
||||
else {
|
||||
ANS_DBG("ANSOD","CreateANSODHandle: allocated handle=%p (uint=%llu) modelType=%d, calling Initialize...",
|
||||
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle, (int)modelConfig.modelType);
|
||||
// CUDA round-robin + VRAM check — only relevant for NVIDIA GPUs.
|
||||
// On AMD/DirectML and OpenVINO these calls hit stub CUDA APIs that
|
||||
// return bogus 0-byte VRAM and pollute the log with false warnings.
|
||||
@@ -683,6 +714,8 @@ extern "C" ANSODENGINE_API std::string CreateANSODHandle(ANSCENTER::ANSODBase**
|
||||
RegisterODHandle(*Handle);
|
||||
(*Handle)->SetLoadEngineOnCreation(_loadEngineOnCreation); //Set force to load the engine immediately
|
||||
bool loadResult = (*Handle)->Initialize(licenseKey, modelConfig, modelFilePath, modelFileZipPassword, labelMap);
|
||||
ANS_DBG("ANSOD","CreateANSODHandle OK: handle=%p initResult=%d labelMapLen=%zu",
|
||||
(void*)*Handle, loadResult ? 1 : 0, labelMap.size());
|
||||
return labelMap;
|
||||
}
|
||||
}
|
||||
@@ -699,7 +732,11 @@ extern "C" ANSODENGINE_API int CreateANSODHandleEx(ANSCENTER::ANSODBase** Handl
|
||||
std::string& labelMap,
|
||||
int loadEngineOnCreation)
|
||||
{
|
||||
if (Handle == nullptr) return -1; // invalid modelType return
|
||||
ANS_DBG("ANSOD","CreateANSODHandleEx: HandlePtr=%p, *Handle(in)=%p, modelType=%d, detectionType=%d, autoDetectEngine=%d, loadOnCreate=%d, modelPath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
|
||||
modelType, detectionType, autoDetectEngine, loadEngineOnCreation,
|
||||
modelFilePath ? modelFilePath : "(null)");
|
||||
if (Handle == nullptr) { ANS_DBG("ANSOD","CreateANSODHandleEx FAIL: Handle is null"); return -1; } // invalid modelType return
|
||||
|
||||
bool _loadEngineOnCreation = false;
|
||||
if (loadEngineOnCreation == 1) {
|
||||
@@ -1003,10 +1040,13 @@ extern "C" ANSODENGINE_API int CreateANSODHandleEx(ANSCENTER::ANSODBase** Handl
|
||||
returnModelType = static_cast<int>(modelConfig.modelType);
|
||||
|
||||
if (*Handle == nullptr) {
|
||||
ANS_DBG("ANSOD","CreateANSODHandleEx FAIL: allocation produced null handle (modelType=%d)", modelType);
|
||||
labelMap ="";
|
||||
return returnModelType;
|
||||
}
|
||||
else {
|
||||
ANS_DBG("ANSOD","CreateANSODHandleEx: allocated handle=%p (uint=%llu) modelType=%d, calling Initialize...",
|
||||
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle, (int)modelConfig.modelType);
|
||||
// CUDA round-robin + VRAM check — only relevant for NVIDIA GPUs.
|
||||
// On AMD/DirectML and OpenVINO these calls hit stub CUDA APIs that
|
||||
// return bogus 0-byte VRAM and pollute the log with false warnings.
|
||||
@@ -1020,12 +1060,18 @@ extern "C" ANSODENGINE_API int CreateANSODHandleEx(ANSCENTER::ANSODBase** Handl
|
||||
RegisterODHandle(*Handle);
|
||||
(*Handle)->SetLoadEngineOnCreation(_loadEngineOnCreation); //Set force to load the engine immediately
|
||||
bool loadResult = (*Handle)->Initialize(licenseKey, modelConfig, modelFilePath, modelFileZipPassword, labelMap);
|
||||
ANS_DBG("ANSOD","CreateANSODHandleEx OK: handle=%p initResult=%d returnModelType=%d labelMapLen=%zu",
|
||||
(void*)*Handle, loadResult ? 1 : 0, returnModelType, labelMap.size());
|
||||
return returnModelType;
|
||||
}
|
||||
|
||||
}
|
||||
//// For LabVIEW API
|
||||
extern "C" ANSODENGINE_API int CreateANSODHandle_LV(ANSCENTER::ANSODBase** Handle, const char* licenseKey, const char* modelFilePath, const char* modelFileZipPassword, float modelThreshold, float modelConfThreshold, float modelNMSThreshold, int autoDetectEngine, int modelType, int detectorType, int loadEngineOnCreation, LStrHandle labelMap) {
|
||||
ANS_DBG("ANSOD","CreateANSODHandle_LV: HandlePtr=%p, *Handle(in)=%p, modelType=%d, detectorType=%d, autoDetectEngine=%d, loadOnCreate=%d, modelPath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
|
||||
modelType, detectorType, autoDetectEngine, loadEngineOnCreation,
|
||||
modelFilePath ? modelFilePath : "(null)");
|
||||
try {
|
||||
|
||||
std::string lbMap;
|
||||
@@ -1071,9 +1117,13 @@ extern "C" __declspec(dllexport) int LoadModelFromFolder(ANSCENTER::ANSODBase**
|
||||
const char* modelFolder,
|
||||
std::string& labelMap)
|
||||
{
|
||||
ANS_DBG("ANSOD","LoadModelFromFolder: HandlePtr=%p, *Handle(in)=%p, modelType=%d, detectionType=%d, autoDetectEngine=%d, modelFolder=%s, modelName=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
|
||||
modelType, detectionType, autoDetectEngine,
|
||||
modelFolder ? modelFolder : "(null)", modelName ? modelName : "(null)");
|
||||
try
|
||||
{
|
||||
if (Handle == nullptr) return 0;
|
||||
if (Handle == nullptr) { ANS_DBG("ANSOD","LoadModelFromFolder FAIL: Handle is null"); return 0; }
|
||||
labelMap.clear();
|
||||
ANSCENTER::ModelConfig modelConfig;
|
||||
bool _loadEngineOnCreation = false;
|
||||
@@ -1366,9 +1416,12 @@ extern "C" __declspec(dllexport) int LoadModelFromFolder(ANSCENTER::ANSODBase**
|
||||
break;
|
||||
}
|
||||
if (*Handle == nullptr) {
|
||||
ANS_DBG("ANSOD","LoadModelFromFolder FAIL: allocation produced null handle (modelType=%d)", modelType);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
ANS_DBG("ANSOD","LoadModelFromFolder: allocated handle=%p (uint=%llu) modelType=%d, calling LoadModelFromFolder...",
|
||||
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle, (int)modelConfig.modelType);
|
||||
// CUDA round-robin + VRAM check — NVIDIA only (see CreateANSODHandle).
|
||||
if (engineType == ANSCENTER::EngineType::NVIDIA_GPU) {
|
||||
const int assignedGPU = AssignNextGPU();
|
||||
@@ -1380,16 +1433,25 @@ extern "C" __declspec(dllexport) int LoadModelFromFolder(ANSCENTER::ANSODBase**
|
||||
RegisterODHandle(*Handle);
|
||||
(*Handle)->SetLoadEngineOnCreation(_loadEngineOnCreation); //Set force to load the engine immediately
|
||||
bool result = (*Handle)->LoadModelFromFolder(licenseKey, modelConfig, modelName, className, modelFolder, labelMap);
|
||||
ANS_DBG("ANSOD","LoadModelFromFolder OK: handle=%p loadResult=%d labelMapLen=%zu",
|
||||
(void*)*Handle, result ? 1 : 0, labelMap.size());
|
||||
if (result) return 1;
|
||||
else return 0;
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
ANS_DBG("ANSOD","LoadModelFromFolder EXCEPTION (std::exception): %s", e.what());
|
||||
return 0;
|
||||
}
|
||||
catch (...) {
|
||||
ANS_DBG("ANSOD","LoadModelFromFolder EXCEPTION (unknown)");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ANSODENGINE_API int OptimizeModelStr(const char* modelFilePath, const char* modelFileZipPassword, int modelType, int modelDetectionType, int fp16, std::string& modelFolder) {
|
||||
ANS_DBG("ANSOD","OptimizeModelStr: modelType=%d, modelDetectionType=%d, fp16=%d, modelPath=%s",
|
||||
modelType, modelDetectionType, fp16, modelFilePath ? modelFilePath : "(null)");
|
||||
try {
|
||||
bool optimizedResult = false;
|
||||
// NOTE: odMutex was removed here. OptimizeModelStr creates its own
|
||||
@@ -1578,22 +1640,35 @@ ANSODENGINE_API int OptimizeModelStr(const char* modelFilePath, const char* mode
|
||||
}
|
||||
static int ReleaseANSODHandle_Impl(ANSCENTER::ANSODBase** Handle) {
|
||||
try {
|
||||
if (Handle == nullptr) return 0;
|
||||
if (*Handle == nullptr) return 0;
|
||||
if (Handle == nullptr) {
|
||||
ANS_DBG("ANSOD","ReleaseANSODHandle: HandlePtr is null, no-op");
|
||||
return 0;
|
||||
}
|
||||
if (*Handle == nullptr) {
|
||||
ANS_DBG("ANSOD","ReleaseANSODHandle: *Handle is null, no-op");
|
||||
return 0;
|
||||
}
|
||||
ANSCENTER::ANSODBase* h = *Handle;
|
||||
ANS_DBG("ANSOD","ReleaseANSODHandle called: handle=%p (uint=%llu)",
|
||||
(void*)h, (unsigned long long)(uintptr_t)h);
|
||||
|
||||
// Only release if this handle was registered by us
|
||||
if (!UnregisterODHandle(*Handle)) {
|
||||
if (!UnregisterODHandle(h)) {
|
||||
// Not in registry — already freed or not ours
|
||||
ANS_DBG("ANSOD","ReleaseANSODHandle: Unregister returned false (already gone or being destroyed by another thread), handle=%p", (void*)h);
|
||||
*Handle = nullptr;
|
||||
return 0;
|
||||
}
|
||||
(*Handle)->Destroy();
|
||||
delete *Handle;
|
||||
h->Destroy();
|
||||
delete h;
|
||||
*Handle = nullptr;
|
||||
ANS_DBG("ANSOD","ReleaseANSODHandle OK: handle=%p deleted, registry now has %zu entries",
|
||||
(void*)h, ODHandleRegistry().size());
|
||||
return 0;
|
||||
}
|
||||
catch (...) {
|
||||
*Handle = nullptr;
|
||||
ANS_DBG("ANSOD","ReleaseANSODHandle EXCEPTION (unknown)");
|
||||
if (Handle) *Handle = nullptr;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1603,10 +1678,14 @@ extern "C" ANSODENGINE_API int ReleaseANSODHandle(ANSCENTER::ANSODBase** Handle)
|
||||
return ReleaseANSODHandle_Impl(Handle);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
ANS_DBG("ANSOD","ReleaseANSODHandle: SEH exception caught");
|
||||
if (Handle) *Handle = nullptr;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
ANSODENGINE_API std::string RunInference(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength) {
|
||||
ANS_DBG("ANSOD","RunInference: HandlePtr=%p, *Handle=%p, bufferLength=%u",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
if (jpeg_string == nullptr || bufferLength == 0) return "";
|
||||
@@ -1629,6 +1708,9 @@ ANSODENGINE_API std::string RunInference(ANSCENTER::ANSODBase** Handle, unsigned
|
||||
|
||||
}
|
||||
ANSODENGINE_API std::string RunTiledInference(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, int tiledWidth, int titledHeight, double overlap, const char* cameraId) {
|
||||
ANS_DBG("ANSOD","RunTiledInference: HandlePtr=%p, *Handle=%p, bufferLength=%u, tile=%dx%d, overlap=%.3f, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, tiledWidth, titledHeight, overlap,
|
||||
cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
if (jpeg_string == nullptr || bufferLength == 0) return "";
|
||||
@@ -1650,6 +1732,8 @@ ANSODENGINE_API std::string RunTiledInference(ANSCENTER::ANSODBase** Handle, uns
|
||||
|
||||
}
|
||||
ANSODENGINE_API std::string RunInferenceFromJpegString(ANSCENTER::ANSODBase** Handle, const char* jpeg_string, unsigned long jpeg_size, const char* cameraId) {
|
||||
ANS_DBG("ANSOD","RunInferenceFromJpegString: HandlePtr=%p, *Handle=%p, jpeg_size=%lu, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), jpeg_size, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
std::vector<ANSCENTER::Object> outputs = (*Handle)->RunInferenceFromJpegString(jpeg_string, jpeg_size, cameraId);
|
||||
@@ -1663,6 +1747,9 @@ ANSODENGINE_API std::string RunInferenceFromJpegString(ANSCENTER::ANSODBase** Ha
|
||||
}
|
||||
}
|
||||
ANSODENGINE_API std::string RunTiledInferenceFromJpegString(ANSCENTER::ANSODBase** Handle, const char* jpeg_string, unsigned long jpeg_size, int tiledWidth, int titledHeight, double overlap, const char* cameraId) {
|
||||
ANS_DBG("ANSOD","RunTiledInferenceFromJpegString: HandlePtr=%p, *Handle=%p, jpeg_size=%lu, tile=%dx%d, overlap=%.3f, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), jpeg_size, tiledWidth, titledHeight, overlap,
|
||||
cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
std::vector<ANSCENTER::Object> outputs = (*Handle)->RunTiledInferenceFromJpegString(jpeg_string, jpeg_size, tiledWidth, titledHeight, overlap, cameraId);
|
||||
@@ -1678,6 +1765,8 @@ ANSODENGINE_API std::string RunTiledInferenceFromJpegString(ANSCENTER::ANSODBase
|
||||
}
|
||||
ANSODENGINE_API std::string RunInferenceFromCV(ANSCENTER::ANSODBase** Handle, cv::Mat image)
|
||||
{
|
||||
ANS_DBG("ANSOD","RunInferenceFromCV: HandlePtr=%p, *Handle=%p, image=%dx%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), image.cols, image.rows);
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
std::string detectionResult;
|
||||
@@ -1691,6 +1780,9 @@ ANSODENGINE_API std::string RunInferenceFromCV(ANSCENTER::ANSODBase** Handle, cv
|
||||
}
|
||||
}
|
||||
extern "C" ANSODENGINE_API void RunDetectMovement(ANSCENTER::ANSODBase** Handle, cv::Mat image, const char* cameraId, std::vector<ANSCENTER::Object>& results) {
|
||||
ANS_DBG("ANSOD","RunDetectMovement: HandlePtr=%p, *Handle=%p, image=%dx%d, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), image.cols, image.rows,
|
||||
cameraId ? cameraId : "(null)");
|
||||
try{
|
||||
if (Handle == nullptr || *Handle == nullptr) { results.clear(); return; }
|
||||
results = (*Handle)->DetectMovement(image, cameraId);
|
||||
@@ -1700,6 +1792,9 @@ extern "C" ANSODENGINE_API void RunDetectMovement(ANSCENTER::ANSODBase** Handl
|
||||
}
|
||||
}
|
||||
extern "C" ANSODENGINE_API void RunTiledInferenceFromCV(ANSCENTER::ANSODBase** Handle, cv::Mat image, int tiledWidth, int titledHeight, double overlap, std::vector<ANSCENTER::Object>& results, const char* cameraId) {
|
||||
ANS_DBG("ANSOD","RunTiledInferenceFromCV: HandlePtr=%p, *Handle=%p, image=%dx%d, tile=%dx%d, overlap=%.3f, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), image.cols, image.rows,
|
||||
tiledWidth, titledHeight, overlap, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) { results.clear(); return; }
|
||||
results = (*Handle)->RunInferences(image, tiledWidth, titledHeight, overlap, cameraId);
|
||||
@@ -1709,6 +1804,8 @@ extern "C" ANSODENGINE_API void RunTiledInferenceFromCV(ANSCENTER::ANSODBase** H
|
||||
}
|
||||
}
|
||||
ANSODENGINE_API std::string RunInferenceInCroppedBBoxImages(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, const char* strBboxes) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedBBoxImages: HandlePtr=%p, *Handle=%p, bufferLength=%u, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
if (jpeg_string == nullptr || bufferLength == 0) return "";
|
||||
@@ -1731,6 +1828,8 @@ ANSODENGINE_API std::string RunInferenceInCroppedBBoxImages(ANSCENTER::ANSODBase
|
||||
|
||||
}
|
||||
ANSODENGINE_API std::string RunInferenceInCroppedPolygonImages(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, const char* strPolygon) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedPolygonImages: HandlePtr=%p, *Handle=%p, bufferLength=%u, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
if (jpeg_string == nullptr || bufferLength == 0) return "";
|
||||
@@ -1752,6 +1851,8 @@ ANSODENGINE_API std::string RunInferenceInCroppedPolygonImages(ANSCENTER::ANSODB
|
||||
}
|
||||
}
|
||||
ANSODENGINE_API std::string RunInferenceBinary(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_bytes, unsigned int width, unsigned int height) {
|
||||
ANS_DBG("ANSOD","RunInferenceBinary: HandlePtr=%p, *Handle=%p, width=%u, height=%u",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), width, height);
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
if (jpeg_bytes == nullptr || width == 0 || height == 0) return "";
|
||||
@@ -1774,6 +1875,8 @@ ANSODENGINE_API std::string RunInferenceBinary(ANSCENTER::ANSODBase** Handle, un
|
||||
|
||||
}
|
||||
ANSODENGINE_API std::string RunInferenceImagePath(ANSCENTER::ANSODBase** Handle, const char* imageFilePath) {
|
||||
ANS_DBG("ANSOD","RunInferenceImagePath: HandlePtr=%p, *Handle=%p, imageFilePath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), imageFilePath ? imageFilePath : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) return "";
|
||||
std::string stImageFileName(imageFilePath);
|
||||
@@ -1797,6 +1900,8 @@ ANSODENGINE_API std::string RunInferenceImagePath(ANSCENTER::ANSODBase** Handle,
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInference_LV(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInference_LV: HandlePtr=%p, *Handle=%p, bufferLength=%u",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
|
||||
try {
|
||||
std::string st = RunInference(Handle, jpeg_string, bufferLength);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1816,6 +1921,9 @@ extern "C" ANSODENGINE_API int RunInference_LV(ANSCENTER::ANSODBase** Handle,
|
||||
}
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunTiledInference_LV(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, int tiledWidth, int titledHeight, double overlap, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunTiledInference_LV: HandlePtr=%p, *Handle=%p, bufferLength=%u, tile=%dx%d, overlap=%.3f, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, tiledWidth, titledHeight, overlap,
|
||||
cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
std::string st = RunTiledInference(Handle, jpeg_string, bufferLength, tiledWidth, titledHeight, overlap, cameraId);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1835,6 +1943,8 @@ extern "C" ANSODENGINE_API int RunTiledInference_LV(ANSCENTER::ANSODBase** Han
|
||||
}
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunInferenceFromJpegString_LV(ANSCENTER::ANSODBase** Handle, const char* jpeg_string, unsigned long jpeg_size, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceFromJpegString_LV: HandlePtr=%p, *Handle=%p, jpeg_size=%lu, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), jpeg_size, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
std::string st = RunInferenceFromJpegString(Handle, jpeg_string, jpeg_size, cameraId);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1855,6 +1965,9 @@ extern "C" ANSODENGINE_API int RunInferenceFromJpegString_LV(ANSCENTER::ANSODB
|
||||
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunTiledInferenceFromJpegString_LV(ANSCENTER::ANSODBase** Handle, const char* jpeg_string, unsigned long jpeg_size, int tiledWidth, int titledHeight, double overlap, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunTiledInferenceFromJpegString_LV: HandlePtr=%p, *Handle=%p, jpeg_size=%lu, tile=%dx%d, overlap=%.3f, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), jpeg_size, tiledWidth, titledHeight, overlap,
|
||||
cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
std::string st = RunTiledInferenceFromJpegString(Handle, jpeg_string, jpeg_size, tiledWidth, titledHeight, overlap, cameraId);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1875,6 +1988,8 @@ extern "C" ANSODENGINE_API int RunTiledInferenceFromJpegString_LV(ANSCENTER::A
|
||||
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxImages_LV(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, int32 bufferLength, const char* cameraId, const char* strBboxes, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedBBoxImages_LV: HandlePtr=%p, *Handle=%p, bufferLength=%d, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), (int)bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
std::string st = RunInferenceInCroppedBBoxImages(Handle, jpeg_string, bufferLength, cameraId, strBboxes);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1894,6 +2009,8 @@ extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxImages_LV(ANSCENTER
|
||||
}
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxPolygonImages_LV(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, int32 bufferLength, const char* cameraId, const char* strPolygon, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedBBoxPolygonImages_LV: HandlePtr=%p, *Handle=%p, bufferLength=%d, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), (int)bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
std::string st = RunInferenceInCroppedPolygonImages(Handle, jpeg_string, bufferLength, cameraId, strPolygon);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1913,6 +2030,8 @@ extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxPolygonImages_LV(AN
|
||||
}
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunInferenceBinary_LV(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_bytes, unsigned int width, unsigned int height, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceBinary_LV: HandlePtr=%p, *Handle=%p, width=%u, height=%u",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), width, height);
|
||||
try {
|
||||
std::string st = RunInferenceBinary(Handle, jpeg_bytes, width, height);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1933,6 +2052,8 @@ extern "C" ANSODENGINE_API int RunInferenceBinary_LV(ANSCENTER::ANSODBase** Ha
|
||||
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunInferenceImagePath_LV(ANSCENTER::ANSODBase** Handle, const char* imageFilePath, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceImagePath_LV: HandlePtr=%p, *Handle=%p, imageFilePath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), imageFilePath ? imageFilePath : "(null)");
|
||||
try {
|
||||
std::string st = RunInferenceImagePath(Handle, imageFilePath);
|
||||
if (st.empty()) return 0;
|
||||
@@ -1954,6 +2075,8 @@ extern "C" ANSODENGINE_API int RunInferenceImagePath_LV(ANSCENTER::ANSODBase**
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int OptimizeModel(const char* modelFilePath, const char* modelFileZipPassword,int modelType, int modelDetectionType, int fp16, LStrHandle optimizedModelFolder) {
|
||||
ANS_DBG("ANSOD","OptimizeModel: modelType=%d, modelDetectionType=%d, fp16=%d, modelPath=%s",
|
||||
modelType, modelDetectionType, fp16, modelFilePath ? modelFilePath : "(null)");
|
||||
try {
|
||||
std::string st;
|
||||
int ret = OptimizeModelStr(modelFilePath, modelFileZipPassword, modelType, modelDetectionType, fp16, st);
|
||||
@@ -1979,6 +2102,10 @@ extern "C" ANSODENGINE_API int OptimizeModel(const char* modelFilePath, const ch
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) const char* CreateANSODHandle_CS(ANSCENTER::ANSODBase** Handle, const char* licenseKey, const char* modelFilePath, const char* modelFileZipPassword, float modelThreshold, float modelConfThreshold, float modelNMSThreshold, int autoDetectEngine, int modelType, int detectionType, int loadEngineOnCreation) {
|
||||
ANS_DBG("ANSOD","CreateANSODHandle_CS: HandlePtr=%p, *Handle(in)=%p, modelType=%d, detectionType=%d, autoDetectEngine=%d, loadOnCreate=%d, modelPath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
|
||||
modelType, detectionType, autoDetectEngine, loadEngineOnCreation,
|
||||
modelFilePath ? modelFilePath : "(null)");
|
||||
try {
|
||||
static std::string result;
|
||||
result = CreateANSODHandle(Handle, licenseKey, modelFilePath, modelFileZipPassword, modelThreshold, modelConfThreshold, modelNMSThreshold, autoDetectEngine, modelType, detectionType, loadEngineOnCreation);
|
||||
@@ -1990,6 +2117,8 @@ extern "C" __declspec(dllexport) const char* CreateANSODHandle_CS(ANSCENTER::ANS
|
||||
|
||||
}
|
||||
extern "C" __declspec(dllexport) const char* RunInferenceImagePath_CS(ANSCENTER::ANSODBase** Handle, const char* imageFilePath) {
|
||||
ANS_DBG("ANSOD","RunInferenceImagePath_CS: HandlePtr=%p, *Handle=%p, imageFilePath=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), imageFilePath ? imageFilePath : "(null)");
|
||||
try {
|
||||
static std::string result;
|
||||
result = RunInferenceImagePath(Handle, imageFilePath);
|
||||
@@ -2001,6 +2130,8 @@ extern "C" __declspec(dllexport) const char* RunInferenceImagePath_CS(ANSCENTER:
|
||||
|
||||
}
|
||||
extern "C" __declspec(dllexport) const char* RunInference_CS(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength) {
|
||||
ANS_DBG("ANSOD","RunInference_CS: HandlePtr=%p, *Handle=%p, bufferLength=%u",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
|
||||
try {
|
||||
static std::string result;
|
||||
result = RunInference(Handle, jpeg_string, bufferLength);
|
||||
@@ -2012,6 +2143,8 @@ extern "C" __declspec(dllexport) const char* RunInference_CS(ANSCENTER::ANSODBas
|
||||
|
||||
}
|
||||
extern "C" __declspec(dllexport) const char* RunInferenceInCroppedBBoxImages_CS(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, const char* strBboxes) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedBBoxImages_CS: HandlePtr=%p, *Handle=%p, bufferLength=%u, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
static std::string result;
|
||||
result = RunInferenceInCroppedBBoxImages(Handle, jpeg_string, bufferLength, cameraId, strBboxes);
|
||||
@@ -2023,6 +2156,8 @@ extern "C" __declspec(dllexport) const char* RunInferenceInCroppedBBoxImages_CS(
|
||||
|
||||
}
|
||||
extern "C" __declspec(dllexport) const char* RunInferenceInCroppedPolygonImages_CS(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, const char* strPolygon) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedPolygonImages_CS: HandlePtr=%p, *Handle=%p, bufferLength=%u, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
static std::string result;
|
||||
result = RunInferenceInCroppedPolygonImages(Handle, jpeg_string, bufferLength, cameraId, strPolygon);
|
||||
@@ -2033,6 +2168,8 @@ extern "C" __declspec(dllexport) const char* RunInferenceInCroppedPolygonImages_
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) const char* RunInferenceBinary_CS(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_bytes, unsigned int width, unsigned int height) {
|
||||
ANS_DBG("ANSOD","RunInferenceBinary_CS: HandlePtr=%p, *Handle=%p, width=%u, height=%u",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), width, height);
|
||||
try {
|
||||
static std::string result;
|
||||
result = RunInferenceBinary(Handle, jpeg_bytes, width, height);
|
||||
@@ -2045,6 +2182,8 @@ extern "C" __declspec(dllexport) const char* RunInferenceBinary_CS(ANSCENTER::AN
|
||||
}
|
||||
extern "C" __declspec(dllexport) const char* OptimizeModelStr_CS(const char* modelFilePath, const char* modelFileZipPassword, int modelType, int modelDetectionType, int fp16)
|
||||
{
|
||||
ANS_DBG("ANSOD","OptimizeModelStr_CS: modelType=%d, modelDetectionType=%d, fp16=%d, modelPath=%s",
|
||||
modelType, modelDetectionType, fp16, modelFilePath ? modelFilePath : "(null)");
|
||||
try {
|
||||
static std::string result;
|
||||
result.clear();
|
||||
@@ -2059,6 +2198,8 @@ extern "C" __declspec(dllexport) const char* OptimizeModelStr_CS(const char* mod
|
||||
|
||||
// with camera id
|
||||
extern "C" ANSODENGINE_API int RunDetectMovement_LV(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunDetectMovement_LV: HandlePtr=%p, *Handle=%p, bufferLength=%u, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
cv::Mat frame = cv::imdecode(cv::Mat(1, bufferLength, CV_8UC1, jpeg_string), cv::IMREAD_COLOR);
|
||||
if (frame.empty()) {
|
||||
@@ -2085,6 +2226,8 @@ extern "C" ANSODENGINE_API int RunDetectMovement_LV(ANSCENTER::ANSODBase** Han
|
||||
|
||||
}
|
||||
extern "C" ANSODENGINE_API int RunInferenceFromJpegStringWithCameraId_LV(ANSCENTER::ANSODBase** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceFromJpegStringWithCameraId_LV: HandlePtr=%p, *Handle=%p, bufferLength=%u, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
cv::Mat frame = cv::imdecode(cv::Mat(1, bufferLength, CV_8UC1, jpeg_string), cv::IMREAD_COLOR);
|
||||
if (frame.empty()) {
|
||||
@@ -2293,6 +2436,10 @@ extern "C" ANSODENGINE_API int RunInferenceComplete_LV(
|
||||
LStrHandle detectionResult,
|
||||
LStrHandle imageStr)
|
||||
{
|
||||
ANS_DBG("ANSOD","RunInferenceComplete_LV: HandlePtr=%p, *Handle=%p, cam=%s, getJpeg=%d, jpegImageSize=%d, roi=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
|
||||
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize,
|
||||
activeROIMode ? activeROIMode : "(null)");
|
||||
return RunInferenceComplete_LV_SEH(Handle, cvImage, cameraId, getJpegString, jpegImageSize, activeROIMode, detectionResult, imageStr);
|
||||
}
|
||||
|
||||
@@ -2311,6 +2458,10 @@ extern "C" ANSODENGINE_API int RunInferenceComplete_LV_V2(
|
||||
{
|
||||
// Cast the by-value integer back to the engine pointer — no double dereference
|
||||
ANSCENTER::ANSODBase* directHandle = reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal);
|
||||
ANS_DBG("ANSOD","RunInferenceComplete_LV_V2: handleVal=%llu handle=%p, cam=%s, getJpeg=%d, jpegImageSize=%d, roi=%s",
|
||||
(unsigned long long)handleVal, (void*)directHandle,
|
||||
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize,
|
||||
activeROIMode ? activeROIMode : "(null)");
|
||||
if (directHandle == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
@@ -2341,6 +2492,8 @@ extern "C" ANSODENGINE_API int RunInferenceComplete_LV_V2(
|
||||
ANSCENTER::ANSODBase** Handle = &_v2Arr[0];
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInference_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInference_LV_V2: handleVal=%llu handle=%p, bufferLength=%u",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal), bufferLength);
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunInference(Handle, jpeg_string, bufferLength);
|
||||
@@ -2358,6 +2511,9 @@ extern "C" ANSODENGINE_API int RunInference_LV_V2(uint64_t handleVal, unsigned c
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunTiledInference_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, int tiledWidth, int titledHeight, double overlap, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunTiledInference_LV_V2: handleVal=%llu handle=%p, bufferLength=%u, tile=%dx%d, overlap=%.3f, cam=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
bufferLength, tiledWidth, titledHeight, overlap, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunTiledInference(Handle, jpeg_string, bufferLength, tiledWidth, titledHeight, overlap, cameraId);
|
||||
@@ -2375,6 +2531,9 @@ extern "C" ANSODENGINE_API int RunTiledInference_LV_V2(uint64_t handleVal, unsig
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunTiledInferenceFromJpegString_LV_V2(uint64_t handleVal, const char* jpeg_string, unsigned long jpeg_size, int tiledWidth, int titledHeight, double overlap, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunTiledInferenceFromJpegString_LV_V2: handleVal=%llu handle=%p, jpeg_size=%lu, tile=%dx%d, overlap=%.3f, cam=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
jpeg_size, tiledWidth, titledHeight, overlap, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunTiledInferenceFromJpegString(Handle, jpeg_string, jpeg_size, tiledWidth, titledHeight, overlap, cameraId);
|
||||
@@ -2392,6 +2551,9 @@ extern "C" ANSODENGINE_API int RunTiledInferenceFromJpegString_LV_V2(uint64_t ha
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInferenceFromJpegString_LV_V2(uint64_t handleVal, const char* jpeg_string, unsigned long jpeg_size, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceFromJpegString_LV_V2: handleVal=%llu handle=%p, jpeg_size=%lu, cam=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
jpeg_size, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunInferenceFromJpegString(Handle, jpeg_string, jpeg_size, cameraId);
|
||||
@@ -2409,6 +2571,8 @@ extern "C" ANSODENGINE_API int RunInferenceFromJpegString_LV_V2(uint64_t handleV
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInferenceBinary_LV_V2(uint64_t handleVal, unsigned char* jpeg_bytes, unsigned int width, unsigned int height, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceBinary_LV_V2: handleVal=%llu handle=%p, width=%u, height=%u",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal), width, height);
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunInferenceBinary(Handle, jpeg_bytes, width, height);
|
||||
@@ -2426,6 +2590,9 @@ extern "C" ANSODENGINE_API int RunInferenceBinary_LV_V2(uint64_t handleVal, unsi
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInferenceImagePath_LV_V2(uint64_t handleVal, const char* imageFilePath, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceImagePath_LV_V2: handleVal=%llu handle=%p, imageFilePath=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
imageFilePath ? imageFilePath : "(null)");
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunInferenceImagePath(Handle, imageFilePath);
|
||||
@@ -2443,6 +2610,9 @@ extern "C" ANSODENGINE_API int RunInferenceImagePath_LV_V2(uint64_t handleVal, c
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxImages_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, int32 bufferLength, const char* cameraId, const char* strBboxes, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedBBoxImages_LV_V2: handleVal=%llu handle=%p, bufferLength=%d, cam=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
(int)bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunInferenceInCroppedBBoxImages(Handle, jpeg_string, bufferLength, cameraId, strBboxes);
|
||||
@@ -2460,6 +2630,9 @@ extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxImages_LV_V2(uint64_t ha
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxPolygonImages_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, int32 bufferLength, const char* cameraId, const char* strPolygon, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceInCroppedBBoxPolygonImages_LV_V2: handleVal=%llu handle=%p, bufferLength=%d, cam=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
(int)bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
V2_HANDLE_SETUP(handleVal);
|
||||
std::string st = RunInferenceInCroppedPolygonImages(Handle, jpeg_string, bufferLength, cameraId, strPolygon);
|
||||
@@ -2477,6 +2650,9 @@ extern "C" ANSODENGINE_API int RunInferenceInCroppedBBoxPolygonImages_LV_V2(uint
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunDetectMovement_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunDetectMovement_LV_V2: handleVal=%llu handle=%p, bufferLength=%u, cam=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
ANSCENTER::ANSODBase* directHandle = reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal);
|
||||
if (directHandle == nullptr) return 0;
|
||||
@@ -2499,6 +2675,9 @@ extern "C" ANSODENGINE_API int RunDetectMovement_LV_V2(uint64_t handleVal, unsig
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInferenceFromJpegStringWithCameraId_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceFromJpegStringWithCameraId_LV_V2: handleVal=%llu handle=%p, bufferLength=%u, cam=%s",
|
||||
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal),
|
||||
bufferLength, cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
ANSCENTER::ANSODBase* directHandle = reinterpret_cast<ANSCENTER::ANSODBase*>(handleVal);
|
||||
if (directHandle == nullptr) return 0;
|
||||
@@ -2521,6 +2700,9 @@ extern "C" ANSODENGINE_API int RunInferenceFromJpegStringWithCameraId_LV_V2(uint
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInferenceComplete_CPP(ANSCENTER::ANSODBase** Handle, cv::Mat** cvImage, const char* cameraId, const char* activeROIMode, std::vector<ANSCENTER::Object> &detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInferenceComplete_CPP: HandlePtr=%p, *Handle=%p, cam=%s, roi=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
|
||||
cameraId ? cameraId : "(null)", activeROIMode ? activeROIMode : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null in RunInferenceComplete_CPP!" << std::endl;
|
||||
return -1;
|
||||
@@ -2575,6 +2757,8 @@ extern "C" ANSODENGINE_API int RunInferenceComplete_CPP(ANSCENTER::ANSODBase**
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int RunInference_CPP(ANSCENTER::ANSODBase** Handle, cv::Mat** cvImage, const char* cameraId, std::vector<ANSCENTER::Object>& detectionResult) {
|
||||
ANS_DBG("ANSOD","RunInference_CPP: HandlePtr=%p, *Handle=%p, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), cameraId ? cameraId : "(null)");
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null in RunInference_CPP!" << std::endl;
|
||||
return -1;
|
||||
@@ -2624,6 +2808,7 @@ extern "C" ANSODENGINE_API int RunInference_CPP(ANSCENTER::ANSODBase** Handle,
|
||||
|
||||
// Utility function to convert a string to a vector of cv::Point
|
||||
extern "C" __declspec(dllexport) int GetEngineType() {
|
||||
ANS_DBG("ANSOD","GetEngineType: called");
|
||||
ANSCENTER::EngineType engineType = ANSCENTER::ANSLicenseHelper::CheckHardwareInformation();
|
||||
switch (engineType) {
|
||||
case ANSCENTER::EngineType::CPU:
|
||||
@@ -2641,6 +2826,8 @@ extern "C" __declspec(dllexport) int GetEngineType() {
|
||||
|
||||
|
||||
extern "C" __declspec(dllexport) int GetActiveRect(ANSCENTER::ANSODBase** Handle, cv::Mat cvImage, cv::Rect& activeWindow) {
|
||||
ANS_DBG("ANSOD","GetActiveRect: HandlePtr=%p, *Handle=%p, image=%dx%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), cvImage.cols, cvImage.rows);
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2667,6 +2854,9 @@ extern "C" __declspec(dllexport) int GetActiveRect(ANSCENTER::ANSODBase** Handle
|
||||
|
||||
}
|
||||
extern "C" __declspec(dllexport) int DetectMovement(ANSCENTER::ANSODBase** Handle, cv::Mat image, const char* cameraId, std::vector<ANSCENTER::Object>& results) {
|
||||
ANS_DBG("ANSOD","DetectMovement: HandlePtr=%p, *Handle=%p, image=%dx%d, cam=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), image.cols, image.rows,
|
||||
cameraId ? cameraId : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2693,6 +2883,8 @@ extern "C" __declspec(dllexport) int DetectMovement(ANSCENTER::ANSODBase** Handl
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) int Optimize(ANSCENTER::ANSODBase** Handle, bool fp16) {
|
||||
ANS_DBG("ANSOD","Optimize: HandlePtr=%p, *Handle=%p, fp16=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), fp16 ? 1 : 0);
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2714,6 +2906,8 @@ extern "C" __declspec(dllexport) int Optimize(ANSCENTER::ANSODBase** Handle, boo
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) int SetODParameters(ANSCENTER::ANSODBase** Handle, const char* parameters) {
|
||||
ANS_DBG("ANSOD","SetODParameters: HandlePtr=%p, *Handle=%p, parameters=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), parameters ? parameters : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2741,6 +2935,8 @@ extern "C" __declspec(dllexport) int SetODParameters(ANSCENTER::ANSODBase** Hand
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) int GetODParameters(ANSCENTER::ANSODBase** Handle, ANSCENTER::Params& param) {
|
||||
ANS_DBG("ANSOD","GetODParameters: HandlePtr=%p, *Handle=%p",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2755,6 +2951,8 @@ extern "C" __declspec(dllexport) int GetODParameters(ANSCENTER::ANSODBase** Hand
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int GetConfiguredParameters(ANSCENTER::ANSODBase** Handle, LStrHandle stParam) {
|
||||
ANS_DBG("ANSOD","GetConfiguredParameters: HandlePtr=%p, *Handle=%p",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
__try {
|
||||
return [&]() -> int {
|
||||
try {
|
||||
@@ -2801,6 +2999,8 @@ extern "C" __declspec(dllexport) int GetConfiguredParameters(ANSCENTER::ANSODBas
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int GetConfiguredParameters_CPP(ANSCENTER::ANSODBase** Handle, std::string& stParam) {
|
||||
ANS_DBG("ANSOD","GetConfiguredParameters_CPP: HandlePtr=%p, *Handle=%p",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr));
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2823,14 +3023,18 @@ extern "C" __declspec(dllexport) int GetConfiguredParameters_CPP(ANSCENTER::ANSO
|
||||
}
|
||||
|
||||
extern "C" ANSODENGINE_API int ShutdownPythonEngine() {
|
||||
ANS_DBG("ANSOD","ShutdownPythonEngine: called");
|
||||
ANSCENTER::ANSCUSTOMPY::SafeShutdownAll(false);
|
||||
return 1;
|
||||
}
|
||||
extern "C" ANSODENGINE_API int ShutdownPythonEngine_CPP() {
|
||||
ANS_DBG("ANSOD","ShutdownPythonEngine_CPP: called");
|
||||
ANSCENTER::ANSCUSTOMPY::SafeShutdownAll(true);
|
||||
return 1;
|
||||
}
|
||||
extern "C" __declspec(dllexport) int UpdateDetectionMinScore(ANSCENTER::ANSODBase** Handle, float detectionScore) {
|
||||
ANS_DBG("ANSOD","UpdateDetectionMinScore: HandlePtr=%p, *Handle=%p, detectionScore=%.4f",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), detectionScore);
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2851,6 +3055,8 @@ extern "C" __declspec(dllexport) int UpdateDetectionMinScore(ANSCENTER::ANSODBas
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int SetPrompt(ANSCENTER::ANSODBase** Handle, const char* textPrompt) {
|
||||
ANS_DBG("ANSOD","SetPrompt: HandlePtr=%p, *Handle=%p, textPrompt=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), textPrompt ? textPrompt : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2875,6 +3081,8 @@ extern "C" __declspec(dllexport) int SetPrompt(ANSCENTER::ANSODBase** Handle, co
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int SetTracker(ANSCENTER::ANSODBase** Handle, int trackerType, int enableTracker) {
|
||||
ANS_DBG("ANSOD","SetTracker: HandlePtr=%p, *Handle=%p, trackerType=%d, enableTracker=%d",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), trackerType, enableTracker);
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2911,6 +3119,8 @@ extern "C" __declspec(dllexport) int SetTracker(ANSCENTER::ANSODBase** Handle, i
|
||||
}
|
||||
}
|
||||
extern "C" __declspec(dllexport) int SetTrackerParameters(ANSCENTER::ANSODBase** Handle, const char* trackerParams) {
|
||||
ANS_DBG("ANSOD","SetTrackerParameters: HandlePtr=%p, *Handle=%p, trackerParams=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), trackerParams ? trackerParams : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
std::cerr << "Error: Handle is null!" << std::endl;
|
||||
@@ -2938,6 +3148,8 @@ extern "C" __declspec(dllexport) int SetTrackerParameters(ANSCENTER::ANSODBase**
|
||||
// All keys are optional — omit to keep current defaults.
|
||||
// Example: {"ema_alpha":0.4, "class_consistency_frames":8, "hysteresis_enter":0.5, "hysteresis_keep":0.3}
|
||||
extern "C" __declspec(dllexport) int SetStabilizationParameters(ANSCENTER::ANSODBase** Handle, const char* stabParams) {
|
||||
ANS_DBG("ANSOD","SetStabilizationParameters: HandlePtr=%p, *Handle=%p, stabParams=%s",
|
||||
(void*)Handle, (void*)(Handle ? *Handle : nullptr), stabParams ? stabParams : "(null)");
|
||||
try {
|
||||
if (Handle == nullptr || *Handle == nullptr) {
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user