- Remove ALPR_OD Tracker and voting system.

- Disable debugview
This commit is contained in:
2026-04-19 23:15:50 +10:00
parent 51fe507dfd
commit 3418090042
13 changed files with 1266 additions and 129 deletions

View File

@@ -26,6 +26,8 @@ std::atomic<bool> g_forceNoPool{false};
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
// DebugView: filter on "[ANSFR]" — gated by ANSCORE_DEBUGVIEW in ANSLicense.h.
// Handle registry with refcount — prevents use-after-free when
// ReleaseANSRFHandle is called while inference is still running.
// destructionStarted: set by the first Unregister caller; blocks new Acquires
@@ -48,14 +50,30 @@ static std::condition_variable& FRHandleRegistryCV() {
static void RegisterFRHandle(ANSCENTER::ANSFacialRecognition* h) {
std::lock_guard<std::mutex> lk(FRHandleRegistryMutex());
FRHandleRegistry()[h] = { 1, false };
ANS_DBG("ANSFR","Register: handle=%p (uint=%llu) registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, FRHandleRegistry().size());
}
static ANSCENTER::ANSFacialRecognition* AcquireFRHandle(ANSCENTER::ANSFacialRecognition* h) {
std::lock_guard<std::mutex> lk(FRHandleRegistryMutex());
auto it = FRHandleRegistry().find(h);
if (it == FRHandleRegistry().end()) return nullptr;
if (it->second.destructionStarted) return nullptr;
if (it == FRHandleRegistry().end()) {
ANS_DBG("ANSFR","Acquire FAIL: handle=%p (uint=%llu) NOT in registry. registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, FRHandleRegistry().size());
size_t i = 0;
for (auto& kv : FRHandleRegistry()) {
ANS_DBG("ANSFR"," 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("ANSFR","Acquire FAIL: handle=%p is being destroyed (destructionStarted=true)", (void*)h);
return nullptr;
}
it->second.refcount++;
ANS_DBG("ANSFR","Acquire OK: handle=%p refcount=%d", (void*)h, it->second.refcount);
return h;
}
@@ -73,10 +91,15 @@ static bool ReleaseFRHandleRef(ANSCENTER::ANSFacialRecognition* h) {
static bool UnregisterFRHandle(ANSCENTER::ANSFacialRecognition* h) {
std::unique_lock<std::mutex> lk(FRHandleRegistryMutex());
auto it = FRHandleRegistry().find(h);
if (it == FRHandleRegistry().end()) return false;
if (it == FRHandleRegistry().end()) {
ANS_DBG("ANSFR","Unregister: handle=%p NOT in registry (already gone)", (void*)h);
return false;
}
if (it->second.destructionStarted) {
ANS_DBG("ANSFR","Unregister: handle=%p already being destroyed by another thread, returning false", (void*)h);
return false; // Another thread already owns the delete.
}
ANS_DBG("ANSFR","Unregister: handle=%p starting (refcount before=%d)", (void*)h, it->second.refcount);
it->second.destructionStarted = true;
it->second.refcount--;
bool ok = FRHandleRegistryCV().wait_for(lk, std::chrono::seconds(30), [&]() {
@@ -84,6 +107,7 @@ static bool UnregisterFRHandle(ANSCENTER::ANSFacialRecognition* h) {
return it2 == FRHandleRegistry().end() || it2->second.refcount <= 0;
});
if (!ok) {
ANS_DBG("ANSFR","WARNING: Unregister timed out waiting for in-flight inference on handle=%p", (void*)h);
OutputDebugStringA("WARNING: UnregisterFRHandle timed out waiting for in-flight inference\n");
}
FRHandleRegistry().erase(h);
@@ -228,14 +252,22 @@ extern "C" ANSFR_API int CreateANSRFHandle(ANSCENTER::ANSFacialRecognition**
int enableHeadPose,
int minFaceSize,
float faceDetectorThreshold,
int enableFaceLiveness,
int enableFaceLiveness,
int enableAntiSpoofing)
{
ANS_DBG("ANSFR","CreateANSRFHandle called: HandlePtr=%p, *Handle(in)=%p, precision=%d, knownThr=%f, ageGender=%d, emotions=%d, headPose=%d, minFace=%d, faceThr=%f, liveness=%d, antiSpoof=%d, configFile=%s, dbFile=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), precisionType, knownPersonThreshold,
enableAgeGender, enableFaceEmotions, enableHeadPose, minFaceSize, faceDetectorThreshold,
enableFaceLiveness, enableAntiSpoofing,
configFilePath ? configFilePath : "(null)", databaseFilePath ? databaseFilePath : "(null)");
try {
// Ensure all shared DLLs (OpenCV, OpenVINO, TRT, ORT) are pre-loaded
ANSCENTER::ANSLibsLoader::Initialize();
if (!Handle || !licenseKey || !configFilePath || !databaseFilePath || !recogniserFilePath) return -1;
if (!Handle || !licenseKey || !configFilePath || !databaseFilePath || !recogniserFilePath) {
ANS_DBG("ANSFR","CreateANSRFHandle FAIL: required pointer is null");
return -1;
}
// Log the detected vendor path so field triage between NVIDIA / AMD /
// Intel / CPU machines is trivial from the debug log. Mirrors the
@@ -269,6 +301,8 @@ extern "C" ANSFR_API int CreateANSRFHandle(ANSCENTER::ANSFacialRecognition**
// std::unique_ptr ensures automatic cleanup if Initialize() throws
auto ptr = std::make_unique<ANSCENTER::ANSFacialRecognition>();
ANS_DBG("ANSFR","CreateANSRFHandle: allocated handle=%p (uint=%llu), calling Initialize...",
(void*)ptr.get(), (unsigned long long)(uintptr_t)ptr.get());
const bool _enableFaceLiveness = (enableFaceLiveness == 1);
const bool _enableAntiSpoofing = (enableAntiSpoofing == 1);
@@ -291,6 +325,7 @@ extern "C" ANSFR_API int CreateANSRFHandle(ANSCENTER::ANSFacialRecognition**
_enableAntiSpoofing);
if (result < 0) {
ANS_DBG("ANSFR","CreateANSRFHandle FAIL: Initialize returned %d, handle being freed", result);
*Handle = nullptr;
return result;
}
@@ -298,14 +333,18 @@ extern "C" ANSFR_API int CreateANSRFHandle(ANSCENTER::ANSFacialRecognition**
// Transfer ownership to caller on success
*Handle = ptr.release();
RegisterFRHandle(*Handle);
ANS_DBG("ANSFR","CreateANSRFHandle OK: handle=%p (uint=%llu) result=%d",
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle, result);
return result;
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","CreateANSRFHandle EXCEPTION (std::exception): %s", e.what());
return -1;
}
}
extern "C" ANSFR_API int LoadANSRFEngine(ANSCENTER::ANSFacialRecognition** Handle) {
ANS_DBG("ANSFR","LoadANSRFEngine: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
try {
if (!Handle || !*Handle) return -1;
bool result = (*Handle)->LoadEngine();
@@ -313,23 +352,33 @@ extern "C" ANSFR_API int LoadANSRFEngine(ANSCENTER::ANSFacialRecognition** Ha
else return 0;
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","LoadANSRFEngine EXCEPTION: %s", e.what());
return -1;
}
}
static int ReleaseANSRFHandle_Impl(ANSCENTER::ANSFacialRecognition** Handle) {
try {
if (!Handle || !*Handle) return 1;
if (!UnregisterFRHandle(*Handle)) {
if (!Handle || !*Handle) {
ANS_DBG("ANSFR","Release: HandlePtr or *Handle is null, no-op");
return 1;
}
ANSCENTER::ANSFacialRecognition* h = *Handle;
ANS_DBG("ANSFR","Release called: handle=%p (uint=%llu)", (void*)h, (unsigned long long)(uintptr_t)h);
if (!UnregisterFRHandle(h)) {
ANS_DBG("ANSFR","Release: Unregister returned false (already gone or being destroyed by another thread), handle=%p", (void*)h);
*Handle = nullptr;
return 1; // Not in registry — already freed
}
(*Handle)->Destroy();
delete *Handle;
h->Destroy();
delete h;
*Handle = nullptr;
ANS_DBG("ANSFR","Release OK: handle=%p deleted, registry now has %zu entries",
(void*)h, FRHandleRegistry().size());
return 1;
}
catch (...) {
ANS_DBG("ANSFR","Release EXCEPTION (unknown)");
if (Handle) *Handle = nullptr;
return 0;
}
@@ -340,10 +389,13 @@ extern "C" ANSFR_API int ReleaseANSRFHandle(ANSCENTER::ANSFacialRecogni
return ReleaseANSRFHandle_Impl(Handle);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
ANS_DBG("ANSFR","ReleaseANSRFHandle: SEH exception caught");
if (Handle) *Handle = nullptr;
return 0;
}
}
extern "C" ANSFR_API std::string RunANSRFInference(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength) {
ANS_DBG("ANSFR","RunANSRFInference: HandlePtr=%p, *Handle=%p, bufLen=%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0) return "";
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return "";
@@ -362,6 +414,7 @@ extern "C" ANSFR_API std::string RunANSRFInference(ANSCENTER::ANSFacialRecognit
extern "C" ANSFR_API std::string RunANSRFInferenceBinary(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_bytes, unsigned int width, unsigned int height) {
ANS_DBG("ANSFR","RunANSRFInferenceBinary: HandlePtr=%p, *Handle=%p, %ux%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), width, height);
if (!Handle || !*Handle || !jpeg_bytes || width == 0 || height == 0) return "";
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return "";
@@ -377,6 +430,7 @@ extern "C" ANSFR_API std::string RunANSRFInferenceBinary(ANSCENTER::ANSFacialRe
catch (...) { return ""; }
}
extern "C" ANSFR_API std::string RunANSRFRecognition(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength) {
ANS_DBG("ANSFR","RunANSRFRecognition: HandlePtr=%p, *Handle=%p, bufLen=%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0) return "";
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return "";
@@ -392,6 +446,7 @@ extern "C" ANSFR_API std::string RunANSRFRecognition(ANSCENTER::ANSFacialRecogn
catch (...) { return ""; }
}
extern "C" ANSFR_API std::string RunANSRFRecognitionBinary(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_bytes, unsigned int width, unsigned int height) {
ANS_DBG("ANSFR","RunANSRFRecognitionBinary: HandlePtr=%p, *Handle=%p, %ux%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), width, height);
if (!Handle || !*Handle || !jpeg_bytes || width == 0 || height == 0) return "";
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return "";
@@ -407,6 +462,7 @@ extern "C" ANSFR_API std::string RunANSRFRecognitionBinary(ANSCENTER::ANSFacial
catch (...) { return ""; }
}
extern "C" ANSFR_API std::string RunANSRFDetectorBinary(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_bytes, unsigned int width, unsigned int height) {
ANS_DBG("ANSFR","RunANSRFDetectorBinary: HandlePtr=%p, *Handle=%p, %ux%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), width, height);
if (!Handle || !*Handle || !jpeg_bytes || width == 0 || height == 0) return "";
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return "";
@@ -422,6 +478,7 @@ extern "C" ANSFR_API std::string RunANSRFDetectorBinary(ANSCENTER::ANSFacialRec
catch (...) { return ""; }
}
extern "C" ANSFR_API std::string RunANSRFDetector(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength) {
ANS_DBG("ANSFR","RunANSRFDetector: HandlePtr=%p, *Handle=%p, bufLen=%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0) return "";
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return "";
@@ -439,16 +496,20 @@ extern "C" ANSFR_API std::string RunANSRFDetector(ANSCENTER::ANSFacialRecogniti
//// For LabVIEW API
extern "C" ANSFR_API int RunInference_LV(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunInference_LV: HandlePtr=%p, *Handle=%p, bufLen=%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
try {
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !detectionResult) return -1;
std::string st = RunANSRFInference(Handle, jpeg_string, bufferLength);
return CopyToLStrHandle(detectionResult, st);
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","RunInference_LV EXCEPTION: %s", e.what());
return -1;
}
}
extern "C" ANSFR_API int RunInferenceWithCamId_LV(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunInferenceWithCamId_LV: HandlePtr=%p, *Handle=%p, bufLen=%u, cam=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return -3;
@@ -467,17 +528,21 @@ extern "C" ANSFR_API int RunInferenceWithCamId_LV(ANSCENTER::ANSFacialR
extern "C" ANSFR_API int RunDetector_LV(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult)
{
ANS_DBG("ANSFR","RunDetector_LV: HandlePtr=%p, *Handle=%p, bufLen=%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
try {
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !detectionResult) return -1;
std::string st = RunANSRFDetector(Handle, jpeg_string, bufferLength);
return CopyToLStrHandle(detectionResult, st);
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","RunDetector_LV EXCEPTION: %s", e.what());
return -1;
}
}
extern "C" ANSFR_API int RunDetectorWithCamId_LV(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunDetectorWithCamId_LV: HandlePtr=%p, *Handle=%p, bufLen=%u, cam=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return -3;
@@ -494,16 +559,20 @@ extern "C" ANSFR_API int RunDetectorWithCamId_LV(ANSCENTER::ANSFacialRe
}
extern "C" ANSFR_API int RunRecognition_LV(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunRecognition_LV: HandlePtr=%p, *Handle=%p, bufLen=%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
try {
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !detectionResult) return -1;
std::string st = RunANSRFRecognition(Handle, jpeg_string, bufferLength);
return CopyToLStrHandle(detectionResult, st);
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","RunRecognition_LV EXCEPTION: %s", e.what());
return -1;
}
}
extern "C" ANSFR_API int RunRecognitionWithCamId_LV(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunRecognitionWithCamId_LV: HandlePtr=%p, *Handle=%p, bufLen=%u, cam=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return -3;
@@ -519,6 +588,8 @@ extern "C" ANSFR_API int RunRecognitionWithCamId_LV(ANSCENTER::ANSFacia
catch (...) { return -1; }
}
extern "C" ANSFR_API int RunFaceDetection_LV(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunFaceDetection_LV: HandlePtr=%p, *Handle=%p, bufLen=%u, cam=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength, cameraId ? cameraId : "(null)");
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return -3;
@@ -535,6 +606,7 @@ extern "C" ANSFR_API int RunFaceDetection_LV(ANSCENTER::ANSFacialRecogn
}
extern "C" ANSFR_API std::string RunANSRFFaceDetector(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_bytes, unsigned int width, unsigned int height)
{
ANS_DBG("ANSFR","RunANSRFFaceDetector: HandlePtr=%p, *Handle=%p, %ux%u", (void*)Handle, (void*)(Handle ? *Handle : nullptr), width, height);
if (!Handle || !*Handle || !jpeg_bytes || width == 0 || height == 0) return "";
FRHandleGuard guard(AcquireFRHandle(*Handle));
if (!guard) return "";
@@ -552,6 +624,8 @@ extern "C" ANSFR_API std::string RunANSRFFaceDetector(ANSCENTER::ANSFacialRecog
// User management
extern "C" ANSFR_API int InsertUser(ANSCENTER::ANSFacialRecognition** Handle, const char* userCode, const char* userName) {
ANS_DBG("ANSFR","InsertUser: HandlePtr=%p, *Handle=%p, userCode=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userCode ? userCode : "(null)");
try {
if (!Handle || !*Handle || !userCode || !userName) return -1;
int result = (*Handle)->InsertUser(userCode, userName);
@@ -713,6 +787,8 @@ static std::string LStrHandleToUTF8(LStrHandle handle) {
}
extern "C" ANSFR_API int InsertUser_LV(ANSCENTER::ANSFacialRecognition** Handle, const char* userCode, LStrHandle userName) {
ANS_DBG("ANSFR","InsertUser_LV: HandlePtr=%p, *Handle=%p, userCode=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userCode ? userCode : "(null)");
try {
if (!Handle || !*Handle || !userCode || !userName) return -1;
std::string utf8Name = LStrHandleToUTF8(userName);
@@ -723,6 +799,8 @@ extern "C" ANSFR_API int InsertUser_LV(ANSCENTER::ANSFacialRecognition** Handle,
}
extern "C" ANSFR_API int UpdateUser_LV(ANSCENTER::ANSFacialRecognition** Handle, int userId, const char* userCode, LStrHandle userName) {
ANS_DBG("ANSFR","UpdateUser_LV: HandlePtr=%p, *Handle=%p, userId=%d, userCode=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId, userCode ? userCode : "(null)");
try {
if (!Handle || !*Handle || !userCode || !userName) return -1;
std::string utf8Name = LStrHandleToUTF8(userName);
@@ -733,6 +811,8 @@ extern "C" ANSFR_API int UpdateUser_LV(ANSCENTER::ANSFacialRecognition** Handle,
}
extern "C" ANSFR_API int UpdateUser(ANSCENTER::ANSFacialRecognition** Handle, int userId, const char* userCode, const char* userName) {
ANS_DBG("ANSFR","UpdateUser: HandlePtr=%p, *Handle=%p, userId=%d, userCode=%s",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId, userCode ? userCode : "(null)");
try {
if (!Handle || !*Handle || !userCode || !userName) return -1;
int result = (*Handle)->UpdateUser(userId, userCode, userName);
@@ -743,6 +823,8 @@ extern "C" ANSFR_API int UpdateUser(ANSCENTER::ANSFacialRecognition** H
}
}
extern "C" ANSFR_API int DeleteUser(ANSCENTER::ANSFacialRecognition** Handle, int userId) {
ANS_DBG("ANSFR","DeleteUser: HandlePtr=%p, *Handle=%p, userId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId);
try {
if (!Handle || !*Handle) return -1;
int result = (*Handle)->DeleteUser(userId);
@@ -753,6 +835,8 @@ extern "C" ANSFR_API int DeleteUser(ANSCENTER::ANSFacialRecognition** H
}
}
extern "C" ANSFR_API int DeleteUsers(ANSCENTER::ANSFacialRecognition** Handle, int* userIds, int count) {
ANS_DBG("ANSFR","DeleteUsers: HandlePtr=%p, *Handle=%p, count=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), count);
try {
if (!Handle || !*Handle || !userIds || count <= 0) return -1;
std::vector<int> ids(userIds, userIds + count);
@@ -763,6 +847,8 @@ extern "C" ANSFR_API int DeleteUsers(ANSCENTER::ANSFacialRecognition**
}
}
extern "C" ANSFR_API int InsertFace(ANSCENTER::ANSFacialRecognition** Handle, int userId, unsigned char* jpeg_string, unsigned int bufferLength) {
ANS_DBG("ANSFR","InsertFace: HandlePtr=%p, *Handle=%p, userId=%d, bufLen=%u",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId, bufferLength);
try {
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0) return -1;
cv::Mat frame = cv::imdecode(cv::Mat(1, bufferLength, CV_8UC1, jpeg_string), cv::IMREAD_COLOR);
@@ -778,6 +864,8 @@ extern "C" ANSFR_API int InsertFace(ANSCENTER::ANSFacialRecognition** H
}
extern "C" ANSFR_API int InsertFaces(ANSCENTER::ANSFacialRecognition** Handle, int userId, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle faceIdsStr) {
ANS_DBG("ANSFR","InsertFaces: HandlePtr=%p, *Handle=%p, userId=%d, bufLen=%u",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId, bufferLength);
try {
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0 || !faceIdsStr) return -1;
cv::Mat frame = cv::imdecode(cv::Mat(1, bufferLength, CV_8UC1, jpeg_string), cv::IMREAD_COLOR);
@@ -797,6 +885,8 @@ extern "C" ANSFR_API int InsertFaces(ANSCENTER::ANSFacialRecognition**
extern "C" ANSFR_API int CheckFaceEmbedding(ANSCENTER::ANSFacialRecognition** Handle, unsigned char* jpeg_string, unsigned int bufferLength) {
ANS_DBG("ANSFR","CheckFaceEmbedding: HandlePtr=%p, *Handle=%p, bufLen=%u",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), bufferLength);
try {
if (!Handle || !*Handle || !jpeg_string || bufferLength == 0) return -1;
cv::Mat frame = cv::imdecode(cv::Mat(1, bufferLength, CV_8UC1, jpeg_string), cv::IMREAD_COLOR);
@@ -812,6 +902,8 @@ extern "C" ANSFR_API int CheckFaceEmbedding(ANSCENTER::ANSFacialRecogni
}
extern "C" ANSFR_API int InsertFaceBinary(ANSCENTER::ANSFacialRecognition** Handle, int userId, unsigned char* jpeg_bytes, unsigned int width, unsigned int height) {
ANS_DBG("ANSFR","InsertFaceBinary: HandlePtr=%p, *Handle=%p, userId=%d, %ux%u",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId, width, height);
try {
if (!Handle || !*Handle || !jpeg_bytes || width == 0 || height == 0) return -1;
cv::Mat frame = cv::Mat(height, width, CV_8UC3, jpeg_bytes).clone(); // make a copy
@@ -826,6 +918,8 @@ extern "C" ANSFR_API int InsertFaceBinary(ANSCENTER::ANSFacialRecogniti
}
}
extern "C" ANSFR_API int DeleteFace(ANSCENTER::ANSFacialRecognition** Handle, int faceId) {
ANS_DBG("ANSFR","DeleteFace: HandlePtr=%p, *Handle=%p, faceId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), faceId);
try {
if (!Handle || !*Handle) return -1;
int result = (*Handle)->DeleteFace(faceId);
@@ -836,6 +930,7 @@ extern "C" ANSFR_API int DeleteFace(ANSCENTER::ANSFacialRecognition** H
}
}
extern "C" ANSFR_API int Reload(ANSCENTER::ANSFacialRecognition** Handle) {
ANS_DBG("ANSFR","Reload: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
try {
if (!Handle || !*Handle) return -1;
bool result = (*Handle)->Reload();
@@ -849,6 +944,8 @@ extern "C" ANSFR_API int Reload(ANSCENTER::ANSFacialRecognition** Handl
// New management API
extern "C" ANSFR_API int GetUser(ANSCENTER::ANSFacialRecognition** Handle, int userId, LStrHandle userRecord) {
ANS_DBG("ANSFR","GetUser: HandlePtr=%p, *Handle=%p, userId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId);
try {
if (!Handle || !*Handle || !userRecord) return -1;
std::string st;
@@ -860,6 +957,7 @@ extern "C" ANSFR_API int GetUser(ANSCENTER::ANSFacialRecognition** Handle, in
}
}
extern "C" ANSFR_API int GetUsers(ANSCENTER::ANSFacialRecognition** Handle, LStrHandle userRecords) {
ANS_DBG("ANSFR","GetUsers: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
try {
if (!Handle || !*Handle || !userRecords) return -1;
std::string st;
@@ -872,6 +970,8 @@ extern "C" ANSFR_API int GetUsers(ANSCENTER::ANSFacialRecognition** Handle, L
}
}
extern "C" ANSFR_API int GetFace(ANSCENTER::ANSFacialRecognition** Handle, int faceId, LStrHandle faceRecord) {
ANS_DBG("ANSFR","GetFace: HandlePtr=%p, *Handle=%p, faceId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), faceId);
try {
if (!Handle || !*Handle || !faceRecord) return -1;
std::string st;
@@ -883,6 +983,8 @@ extern "C" ANSFR_API int GetFace(ANSCENTER::ANSFacialRecognition** Handle, in
}
}
extern "C" ANSFR_API int GetFaces(ANSCENTER::ANSFacialRecognition** Handle, int userId, LStrHandle faceRecords) {
ANS_DBG("ANSFR","GetFaces: HandlePtr=%p, *Handle=%p, userId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId);
try {
if (!Handle || !*Handle || !faceRecords) return -1;
std::string st;
@@ -894,6 +996,8 @@ extern "C" ANSFR_API int GetFaces(ANSCENTER::ANSFacialRecognition** Handle, i
}
}
extern "C" ANSFR_API int DeleteFacesByUser(ANSCENTER::ANSFacialRecognition** Handle, int userId) {
ANS_DBG("ANSFR","DeleteFacesByUser: HandlePtr=%p, *Handle=%p, userId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId);
try {
if (!Handle || !*Handle) return -1;
int ret = (*Handle)->DeleteFacesByUser(userId);
@@ -907,6 +1011,8 @@ extern "C" ANSFR_API int DeleteFacesByUser(ANSCENTER::ANSFacialRecognition**
// For testing only
extern "C" ANSFR_API int GetUserString(ANSCENTER::ANSFacialRecognition** Handle, int userId, std::string& userRecord) {
ANS_DBG("ANSFR","GetUserString: HandlePtr=%p, *Handle=%p, userId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId);
try {
if (!Handle || !*Handle) return -1;
(*Handle)->GetUser(userId, userRecord);
@@ -917,6 +1023,7 @@ extern "C" ANSFR_API int GetUserString(ANSCENTER::ANSFacialRecognition** Hand
}
}
extern "C" ANSFR_API int GetUsersString(ANSCENTER::ANSFacialRecognition** Handle, std::string& userRecords, std::vector<int>& userIds) {
ANS_DBG("ANSFR","GetUsersString: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
try {
if (!Handle || !*Handle) return -1;
(*Handle)->GetUsers(userRecords, userIds);
@@ -927,6 +1034,8 @@ extern "C" ANSFR_API int GetUsersString(ANSCENTER::ANSFacialRecognition** Han
}
}
extern "C" ANSFR_API int GetFaceString(ANSCENTER::ANSFacialRecognition** Handle, int faceId, std::string& faceRecord) {
ANS_DBG("ANSFR","GetFaceString: HandlePtr=%p, *Handle=%p, faceId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), faceId);
try {
if (!Handle || !*Handle) return -1;
(*Handle)->GetFace(faceId, faceRecord);
@@ -937,6 +1046,8 @@ extern "C" ANSFR_API int GetFaceString(ANSCENTER::ANSFacialRecognition** Hand
}
}
extern "C" ANSFR_API int GetFacesString(ANSCENTER::ANSFacialRecognition** Handle, int userId, std::string& faceRecords) {
ANS_DBG("ANSFR","GetFacesString: HandlePtr=%p, *Handle=%p, userId=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), userId);
try {
if (!Handle || !*Handle) return -1;
(*Handle)->GetFaces(userId, faceRecords);
@@ -949,6 +1060,7 @@ extern "C" ANSFR_API int GetFacesString(ANSCENTER::ANSFacialRecognition** Han
extern "C" ANSFR_API double BlurCalculation(unsigned char* jpeg_string, unsigned int bufferLength) {
ANS_DBG("ANSFR","BlurCalculation: bufLen=%u", bufferLength);
try {
if (!jpeg_string || bufferLength == 0) return -1;
cv::Mat image = cv::imdecode(cv::Mat(1, bufferLength, CV_8UC1, jpeg_string), cv::IMREAD_COLOR);
@@ -970,6 +1082,8 @@ extern "C" ANSFR_API double BlurCalculation(unsigned char* jpeg_string, un
// Unicode conversion utilities for LabVIEW wrapper classes
extern "C" ANSFR_API int ANSFR_ConvertUTF8ToUTF16LE(const char* utf8Str, LStrHandle result, int includeBOM) {
ANS_DBG("ANSFR","ANSFR_ConvertUTF8ToUTF16LE: includeBOM=%d, len=%d",
includeBOM, utf8Str ? (int)strlen(utf8Str) : -1);
try {
if (!utf8Str || !result) return -1;
int len = (int)strlen(utf8Str);
@@ -1025,6 +1139,7 @@ extern "C" ANSFR_API int ANSFR_ConvertUTF8ToUTF16LE(const char* utf8Str, LStrHan
}
extern "C" ANSFR_API int ANSFR_ConvertUTF16LEToUTF8(const unsigned char* utf16leBytes, int byteLen, LStrHandle result) {
ANS_DBG("ANSFR","ANSFR_ConvertUTF16LEToUTF8: byteLen=%d", byteLen);
try {
if (!utf16leBytes || byteLen <= 0 || !result) return -1;
bool isUtf16le = (byteLen >= 2 && byteLen % 2 == 0);
@@ -1062,6 +1177,10 @@ extern "C" ANSFR_API int ANSFR_ConvertUTF16LEToUTF8(const unsigned char* utf16le
}
extern "C" ANSFR_API int UpdateParameters(ANSCENTER::ANSFacialRecognition** Handle, float knownPersonThreshold, int enableAgeGender, int enableFaceEmotions, int enableHeadPose, int minFaceSize, float faceDetectorThreshold, int enableFaceliveness, int antiSpoof, int removeFakeFaces) {
ANS_DBG("ANSFR","UpdateParameters: HandlePtr=%p, *Handle=%p, knownThr=%f, ageGender=%d, emotions=%d, headPose=%d, minFace=%d, faceThr=%f, liveness=%d, antiSpoof=%d, removeFake=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), knownPersonThreshold,
enableAgeGender, enableFaceEmotions, enableHeadPose, minFaceSize,
faceDetectorThreshold, enableFaceliveness, antiSpoof, removeFakeFaces);
try {
if (!Handle || !*Handle) return -1;
bool _enableAgeGender = false;
@@ -1088,6 +1207,7 @@ extern "C" ANSFR_API int UpdateParameters(ANSCENTER::ANSFacialRecogniti
extern "C" ANSFR_API int GetParamters(ANSCENTER::ANSFacialRecognition** Handle, LStrHandle faceParams) {
ANS_DBG("ANSFR","GetParamters: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
try {
if (!Handle || !*Handle || !faceParams) return -1;
std::string st;
@@ -1134,6 +1254,8 @@ extern "C" ANSFR_API int GetParamters(ANSCENTER::ANSFacialRecognition** Handl
}
}
extern "C" ANSFR_API int UpdateFaceQueue(ANSCENTER::ANSFacialRecognition** Handle, int queueSize, int numKnownFaceInQueue, int enableFaceQueue) {
ANS_DBG("ANSFR","UpdateFaceQueue: HandlePtr=%p, *Handle=%p, queueSize=%d, numKnown=%d, enable=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr), queueSize, numKnownFaceInQueue, enableFaceQueue);
try {
if (!Handle || !*Handle) return -1;
bool _enableFaceQueue = false;
@@ -1147,6 +1269,7 @@ extern "C" ANSFR_API int UpdateFaceQueue(ANSCENTER::ANSFacialRecognitio
}
}
extern "C" ANSFR_API int GetFaceQueue(ANSCENTER::ANSFacialRecognition** Handle, LStrHandle faceQueue) {
ANS_DBG("ANSFR","GetFaceQueue: HandlePtr=%p, *Handle=%p", (void*)Handle, (void*)(Handle ? *Handle : nullptr));
try {
if (!Handle || !*Handle || !faceQueue) return -1;
std::string st;
@@ -1178,6 +1301,9 @@ extern "C" ANSFR_API int RunInferenceComplete_LV(
LStrHandle detectionResult,
LStrHandle imageStr)
{
ANS_DBG("ANSFR","RunInferenceComplete_LV: HandlePtr=%p, *Handle=%p, cam=%s, getJpeg=%d, jpegSize=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize);
// Validate inputs
if (!cvImage || !(*cvImage) || (*cvImage)->empty()) return -2;
if (!Handle || !(*Handle)) return -2;
@@ -1273,6 +1399,9 @@ extern "C" ANSFR_API int RunFaceDetectionComplete_LV(
LStrHandle detectionResult,
LStrHandle imageStr)
{
ANS_DBG("ANSFR","RunFaceDetectionComplete_LV: HandlePtr=%p, *Handle=%p, cam=%s, getJpeg=%d, jpegSize=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize);
// Validate inputs
if (!cvImage || !(*cvImage) || (*cvImage)->empty()) return -2;
if (!Handle || !(*Handle)) return -2;
@@ -1368,6 +1497,9 @@ extern "C" ANSFR_API int RunFaceRecogniserComplete_LV(
LStrHandle detectionResult,
LStrHandle imageStr)
{
ANS_DBG("ANSFR","RunFaceRecogniserComplete_LV: HandlePtr=%p, *Handle=%p, cam=%s, getJpeg=%d, jpegSize=%d",
(void*)Handle, (void*)(Handle ? *Handle : nullptr),
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize);
// Validate inputs
if (!cvImage || !(*cvImage) || (*cvImage)->empty()) return -2;
if (!Handle || !(*Handle)) return -2;
@@ -1465,6 +1597,8 @@ extern "C" ANSFR_API int RunFaceRecogniserComplete_LV(
ANSCENTER::ANSFacialRecognition** Handle = &_v2Arr[0];
extern "C" ANSFR_API int RunInference_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunInference_LV_V2: handleVal=%llu handle=%p, bufLen=%u",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal), bufferLength);
FR_V2_HANDLE_SETUP(handleVal);
try {
if (!jpeg_string || bufferLength == 0 || !detectionResult) return -1;
@@ -1472,11 +1606,15 @@ extern "C" ANSFR_API int RunInference_LV_V2(uint64_t handleVal, unsigned char* j
return CopyToLStrHandle(detectionResult, st);
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","RunInference_LV_V2 EXCEPTION: %s", e.what());
return -1;
}
}
extern "C" ANSFR_API int RunInferenceWithCamId_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunInferenceWithCamId_LV_V2: handleVal=%llu handle=%p, bufLen=%u, cam=%s",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal),
bufferLength, cameraId ? cameraId : "(null)");
ANSCENTER::ANSFacialRecognition* _v2Direct = reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal);
if (_v2Direct == nullptr) return -1;
if (!jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
@@ -1496,6 +1634,8 @@ extern "C" ANSFR_API int RunInferenceWithCamId_LV_V2(uint64_t handleVal, unsigne
}
extern "C" ANSFR_API int RunDetector_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunDetector_LV_V2: handleVal=%llu handle=%p, bufLen=%u",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal), bufferLength);
FR_V2_HANDLE_SETUP(handleVal);
try {
if (!jpeg_string || bufferLength == 0 || !detectionResult) return -1;
@@ -1503,11 +1643,15 @@ extern "C" ANSFR_API int RunDetector_LV_V2(uint64_t handleVal, unsigned char* jp
return CopyToLStrHandle(detectionResult, st);
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","RunDetector_LV_V2 EXCEPTION: %s", e.what());
return -1;
}
}
extern "C" ANSFR_API int RunDetectorWithCamId_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunDetectorWithCamId_LV_V2: handleVal=%llu handle=%p, bufLen=%u, cam=%s",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal),
bufferLength, cameraId ? cameraId : "(null)");
ANSCENTER::ANSFacialRecognition* _v2Direct = reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal);
if (_v2Direct == nullptr) return -1;
if (!jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
@@ -1527,6 +1671,8 @@ extern "C" ANSFR_API int RunDetectorWithCamId_LV_V2(uint64_t handleVal, unsigned
}
extern "C" ANSFR_API int RunRecognition_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunRecognition_LV_V2: handleVal=%llu handle=%p, bufLen=%u",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal), bufferLength);
FR_V2_HANDLE_SETUP(handleVal);
try {
if (!jpeg_string || bufferLength == 0 || !detectionResult) return -1;
@@ -1534,11 +1680,15 @@ extern "C" ANSFR_API int RunRecognition_LV_V2(uint64_t handleVal, unsigned char*
return CopyToLStrHandle(detectionResult, st);
}
catch (const std::exception& e) {
ANS_DBG("ANSFR","RunRecognition_LV_V2 EXCEPTION: %s", e.what());
return -1;
}
}
extern "C" ANSFR_API int RunRecognitionWithCamId_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunRecognitionWithCamId_LV_V2: handleVal=%llu handle=%p, bufLen=%u, cam=%s",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal),
bufferLength, cameraId ? cameraId : "(null)");
ANSCENTER::ANSFacialRecognition* _v2Direct = reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal);
if (_v2Direct == nullptr) return -1;
if (!jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
@@ -1558,6 +1708,9 @@ extern "C" ANSFR_API int RunRecognitionWithCamId_LV_V2(uint64_t handleVal, unsig
}
extern "C" ANSFR_API int RunFaceDetection_LV_V2(uint64_t handleVal, unsigned char* jpeg_string, unsigned int bufferLength, const char* cameraId, LStrHandle detectionResult) {
ANS_DBG("ANSFR","RunFaceDetection_LV_V2: handleVal=%llu handle=%p, bufLen=%u, cam=%s",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal),
bufferLength, cameraId ? cameraId : "(null)");
ANSCENTER::ANSFacialRecognition* _v2Direct = reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal);
if (_v2Direct == nullptr) return -1;
if (!jpeg_string || bufferLength == 0 || !cameraId || !detectionResult) return -1;
@@ -1585,6 +1738,9 @@ extern "C" ANSFR_API int RunInferenceComplete_LV_V2(
LStrHandle detectionResult,
LStrHandle imageStr)
{
ANS_DBG("ANSFR","RunInferenceComplete_LV_V2: handleVal=%llu handle=%p, cam=%s, getJpeg=%d, jpegSize=%d",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal),
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize);
ANSCENTER::ANSFacialRecognition* _v2Direct = reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal);
if (_v2Direct == nullptr) return -1;
if (!cvImage || !(*cvImage) || (*cvImage)->empty()) return -2;
@@ -1674,6 +1830,9 @@ extern "C" ANSFR_API int RunFaceDetectionComplete_LV_V2(
LStrHandle detectionResult,
LStrHandle imageStr)
{
ANS_DBG("ANSFR","RunFaceDetectionComplete_LV_V2: handleVal=%llu handle=%p, cam=%s, getJpeg=%d, jpegSize=%d",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal),
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize);
ANSCENTER::ANSFacialRecognition* _v2Direct = reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal);
if (_v2Direct == nullptr) return -1;
if (!cvImage || !(*cvImage) || (*cvImage)->empty()) return -2;
@@ -1763,6 +1922,9 @@ extern "C" ANSFR_API int RunFaceRecogniserComplete_LV_V2(
LStrHandle detectionResult,
LStrHandle imageStr)
{
ANS_DBG("ANSFR","RunFaceRecogniserComplete_LV_V2: handleVal=%llu handle=%p, cam=%s, getJpeg=%d, jpegSize=%d",
(unsigned long long)handleVal, (void*)reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal),
cameraId ? cameraId : "(null)", getJpegString, jpegImageSize);
ANSCENTER::ANSFacialRecognition* _v2Direct = reinterpret_cast<ANSCENTER::ANSFacialRecognition*>(handleVal);
if (_v2Direct == nullptr) return -1;
if (!cvImage || !(*cvImage) || (*cvImage)->empty()) return -2;