An engine's model has always been a path to a password-protected zip: ANSODBase inflates it into a folder, and every engine then picks out train_last.onnx, classes.names and model_config.json. A .ansmodel package replaces all four with one sealed file, and this is the part that turns it back into what the engines already understand. ANSODBase::LoadModel and ::Initialize now recognise a .ansmodel path and take a second route: the package is opened with the process keyring, the model is decrypted into memory, and the classes, task and input geometry come out of the manifest instead of loose files. Nothing is extracted, so the unprotected model never touches the disk — which is the reason the format exists, and it is one function's job to keep. The engines follow it down. BasicOrtHandler gains a constructor that takes the bytes rather than a path; it keeps a view of them, not a copy, because the weights are in RAM either way once a session exists and a copy would only double what every loaded model costs. The owner of the plaintext is ANSODBase, which holds it for as long as the engine object lives — that is what lets the DirectML recovery path rebuild a session after a driver fault — and wipes it on teardown. Wired through ANSONNXYOLO (and so the classification facade), ANSONNXOBB, ANSONNXPOSE, ANSONNXSEG and YOLO12OD. YOLOOD is left alone: it loads darknet weights and OpenCV DNN graphs, neither of which the writer produces. A zip still loads exactly as before, on every engine. Keys come from SetProcessModelKeys, as in ANSMINDCORE, with the same development fallback from the environment. With none set, a package is refused with a sentence saying so and every zip still works, so a build made before the key ceremony runs everything except packages. The engine layer needs CUDA to compile, so the contract it depends on is checked where it can be: ANSModelPackage-UnitTest now opens the fixture ANSMINDCORE wrote through the same glue ANSODBase uses, and covers the refusal a keyless build gives. 32 checks, no failures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
159 lines
5.0 KiB
CMake
159 lines
5.0 KiB
CMake
# ANSODEngine — Object Detection Engine DLL (CUDA + ONNX + TensorRT + OpenVINO)
|
|
# Source list matches original ANSODEngine.vcxproj exactly
|
|
|
|
set(ANSOD_SOURCES
|
|
ANSODEngine.cpp
|
|
ANSODHUB.cpp
|
|
ANSEngineCommon.cpp
|
|
ANSMotionDetector.cpp
|
|
ANSANOMALIB.cpp
|
|
ANSCLIPTokenizer.cpp
|
|
ANSCUSTOMDetector.cpp
|
|
ANSCUSTOMPY.cpp
|
|
ANSFD.cpp
|
|
ANSFaceDetectorEngine.cpp
|
|
ANSFaceRecognizerEngine.cpp
|
|
ANSGpuFrameRegistry.cpp
|
|
GpuNV12SlotPool.cpp
|
|
ANSONNXCL.cpp
|
|
ANSONNXOBB.cpp
|
|
ANSONNXPOSE.cpp
|
|
ANSONNXRTMPOSE.cpp
|
|
ANSONNXSAM3.cpp
|
|
ANSONNXSEG.cpp
|
|
ANSONNXYOLO.cpp
|
|
ANSOPENVINOCL.cpp
|
|
ANSOPENVINOOD.cpp
|
|
ANSOVFaceDetector.cpp
|
|
ANSOVSEG.cpp
|
|
ANSPOSE.cpp
|
|
ANSRTYOLO.cpp
|
|
ANSRTRTMPOSE.cpp
|
|
ANSSAM.cpp
|
|
ANSSAM3.cpp
|
|
ANSTENSORRTCL.cpp
|
|
ANSTENSORRTPOSE.cpp
|
|
ANSTENSORRTSEG.cpp
|
|
ANSTENSORTRTOD.cpp
|
|
ANSYOLO12OD.cpp
|
|
ANSYOLOOD.cpp
|
|
ANSYOLOV10OVOD.cpp
|
|
ANSYOLOV10RTOD.cpp
|
|
ANSYOLOV12RTOD.cpp
|
|
Movienet.cpp
|
|
NV12PreprocessHelper.cpp
|
|
SCRFDFaceDetector.cpp
|
|
engine.cpp
|
|
dllmain.cpp
|
|
pch.cpp
|
|
)
|
|
|
|
file(GLOB ANSOD_HEADERS "*.h")
|
|
file(GLOB ANSOD_CUDA_HEADERS "CUDA/*.h" "CUDA/*.cuh")
|
|
file(GLOB ANSOD_CUDA_SOURCES "CUDA/*.cu" "*.cu")
|
|
|
|
# Engine wrapper sources from original vcxproj
|
|
set(ENGINE_SOURCES
|
|
${CMAKE_SOURCE_DIR}/engines/ONNXEngine/ONNXEngine.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/ONNXEngine/ONNXSAM3.cpp
|
|
)
|
|
|
|
# OpenVINO engine sources from original vcxproj
|
|
set(OPENVINO_ENGINE_SOURCES
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/faceapp/cnn.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/detection_model.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/detection_model_faceboxes.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/detection_model_ssd.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/hpe_model_openpose.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/image_model.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/jpeg_restoration_model.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/model_base.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/openpose_decoder.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/models/super_resolution_model.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/pipelines/async_pipeline.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/pipelines/requests_pool.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/utils/args_helper.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/utils/common.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/utils/config_factory.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/utils/image_utils.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/utils/performance_metrics.cpp
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/src/utils/visualizer.cpp
|
|
)
|
|
|
|
add_library(ANSODEngine SHARED
|
|
${ANSOD_SOURCES}
|
|
${ANSOD_HEADERS}
|
|
${ANSOD_CUDA_HEADERS}
|
|
${ANSOD_CUDA_SOURCES}
|
|
${ENGINE_SOURCES}
|
|
${OPENVINO_ENGINE_SOURCES}
|
|
)
|
|
|
|
target_include_directories(ANSODEngine PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/CUDA
|
|
)
|
|
|
|
target_include_directories(ANSODEngine PRIVATE
|
|
${CMAKE_SOURCE_DIR}/engines/ONNXEngine
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/include
|
|
${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/include/faceapp
|
|
${CMAKE_SOURCE_DIR}/engines/TensorRTAPI/include
|
|
${CMAKE_SOURCE_DIR}/engines/TensorRTEngine
|
|
${CMAKE_SOURCE_DIR}/core/ANSLicensingSystem
|
|
${ANSLIBS_DIR}/nlohmann
|
|
${ANSLIBS_DIR}/spdlog/include
|
|
${ANSLIBS_DIR}
|
|
${ANSLIBS_DIR}/ANS-HWiNFO/include
|
|
${ANSLIBS_DIR}/ODHUBYOLODarknet/include
|
|
${ANSLIBS_DIR}/TurboJpeg
|
|
${ANSLIBS_DIR}/fastdeploy_gpu/include
|
|
${SHARED_INCLUDE_DIR}
|
|
)
|
|
|
|
target_link_libraries(ANSODEngine
|
|
PUBLIC ANSLibsLoader
|
|
# Reading .ansmodel packages. Header-only apart from the vendored
|
|
# curves, and free of CUDA/OpenCV, so it costs this target nothing.
|
|
PRIVATE ANSModelPackage
|
|
PUBLIC ANSLicensingSystem # PUBLIC: FileExist/SPDLogger symbols must be re-exported
|
|
PUBLIC opencv
|
|
PRIVATE ANSMOT
|
|
PRIVATE onnxruntime
|
|
PRIVATE tensorrt
|
|
PRIVATE openvino
|
|
PRIVATE python311
|
|
PRIVATE turbojpeg
|
|
PRIVATE boost
|
|
PRIVATE CUDA::cudart_static
|
|
PRIVATE CUDA::cublas
|
|
PRIVATE CUDA::cublasLt
|
|
)
|
|
|
|
# Additional link dependencies from original vcxproj
|
|
target_link_directories(ANSODEngine PRIVATE
|
|
${ANSLIBS_DIR}/ODHUBYOLODarknet/lib
|
|
)
|
|
target_link_libraries(ANSODEngine PRIVATE
|
|
odhublib.lib odhublib_cpu.lib
|
|
nvinfer_10.lib nvonnxparser_10.lib
|
|
labview
|
|
spdlog_dep
|
|
)
|
|
# Note: ANSLicensingSystem already linked as PUBLIC above — no need to repeat
|
|
|
|
target_compile_definitions(ANSODEngine PRIVATE UNICODE _UNICODE NOMINMAX
|
|
ANSODENGINE_EXPORTS
|
|
ENGINE_EXPORTS
|
|
ORT_API_MANUAL_INIT
|
|
_USRDLL
|
|
)
|
|
|
|
if(WIN32)
|
|
target_link_libraries(ANSODEngine PRIVATE ${WIN_COMMON_LIBS})
|
|
else()
|
|
target_link_libraries(ANSODEngine PRIVATE ${UNIX_COMMON_LIBS})
|
|
endif()
|
|
|
|
target_precompile_headers(ANSODEngine PRIVATE pch.h)
|