Add unitest

This commit is contained in:
2026-04-06 07:11:04 +10:00
parent f57ed78763
commit e009257dfd
13 changed files with 225 additions and 77 deletions

View File

@@ -461,9 +461,9 @@ bool ANSCustomFS::Initialize(const std::string& modelDirectory, float detectionS
_motiondetector = ANSLIBPtr(ANSCENTER::ANSLIB::Create(), &ANSCENTER::ANSLIB::Destroy);
_detectorModelType = 4; // TENSORRT
_detectorModelType = 31; // TENSORRT
_detectorDetectionType = 1; // DETECTION
_filterModelType = 4; // TENSORRT
_filterModelType = 31; // TENSORRT
_filterDetectionType = 1; // DETECTION
_motionModelType = 19; // Motion detection (generic CPU)
_motionDetectionType = 1; // DETECTION
@@ -472,17 +472,17 @@ bool ANSCustomFS::Initialize(const std::string& modelDirectory, float detectionS
engineType = _detector->GetEngineType();
if (engineType == 1) {
// NVIDIA GPU: Use TensorRT
_detectorModelType = 4; // TENSORRT
_detectorModelType = 31; // TENSORRT
_detectorDetectionType = 1; // DETECTION
_filterModelType = 4; // TENSORRT
_filterModelType = 31; // TENSORRT
_filterDetectionType = 1; // DETECTION
std::cout << "NVIDIA GPU detected. Using TensorRT" << std::endl;
}
else {
// CPU/Other: Use OpenVINO
_detectorModelType = 17; // OPENVINO
_detectorModelType = 30; // OPENVINO
_detectorDetectionType = 1; // DETECTION
_filterModelType = 17; //Yolo v12
_filterModelType = 30; //Yolo v12
_filterDetectionType = 1; // DETECTION
std::cout << "CPU detected. Using OpenVINO and ONNX" << std::endl;
@@ -556,7 +556,7 @@ bool ANSCustomFS::Initialize(const std::string& modelDirectory, float detectionS
return false;
}
// Load motion detector model (background subtraction / frame differencing)
// Load motion detector model (optional — not used in Stage A tracker-based pipeline)
float motionScoreThreshold = MOTION_SENSITIVITY;
float motionConfThreshold = 0.5f;
float motionNMSThreshold = 0.5f;
@@ -570,8 +570,8 @@ bool ANSCustomFS::Initialize(const std::string& modelDirectory, float detectionS
"", // Empty model directory - motion detector is algorithmic
motionDetectorLabels);
if (motionResult != 1) {
std::cerr << "ANSCustomFS::Initialize: Failed to load motion detector model." << std::endl;
return false;
std::cerr << "ANSCustomFS::Initialize: Warning - Motion detector not loaded (not required for Stage A)." << std::endl;
// Non-fatal: motion detector is not used in the tracker-based Stage A pipeline
}
return true;

View File

@@ -5,7 +5,7 @@
#define RETAINFRAMES 80
#define FILTERFRAMES 10
//#define FNS_DEBUG
#define FNS_DEBUG
class CUSTOM_API ANSCustomFS : public IANSCustomClass
{
typedef std::pair<cv::Scalar, cv::Scalar> Range;
@@ -33,7 +33,7 @@ class CUSTOM_API ANSCustomFS : public IANSCustomClass
private:
using ANSLIBPtr = std::unique_ptr<ANSCENTER::ANSLIB, decltype(&ANSCENTER::ANSLIB::Destroy)>;
int engineType{ 0 };
int engineType{ 0 };
ANSLIBPtr _motiondetector{ nullptr, &ANSCENTER::ANSLIB::Destroy };
ANSLIBPtr _detector{ nullptr, &ANSCENTER::ANSLIB::Destroy };
ANSLIBPtr _filter{ nullptr, &ANSCENTER::ANSLIB::Destroy };

View File

@@ -30,7 +30,7 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
# ---------- include directories ----------
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
C:/Projects/ANLS/ANSLIB/ANSLIB
C:/ProgramData/ANSCENTER/Shared # ANSLIB.h + ANSLIB.lib from same location
C:/ANSLibs/opencv/include
)
@@ -51,10 +51,12 @@ if(MSVC)
/W3 # Warning level 3
/sdl # SDL checks
/permissive- # Conformance mode
$<$<CONFIG:Release>:/O2 /Oi /GL> # Optimize + intrinsics + whole-program opt
/Zi # Generate full debug info (PDB) in all configs
$<$<CONFIG:Release>:/O2 /Oi> # Optimize + intrinsics (no /GL — incompatible with debugging)
)
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:/OPT:REF /OPT:ICF /LTCG> # Optimize refs, COMDAT folding, link-time codegen
/DEBUG # Emit PDB for debugger in all configs
$<$<CONFIG:Release>:/OPT:REF /OPT:ICF> # Optimize refs, COMDAT folding (no /LTCG — incompatible with debugging)
)
endif()