Add CPU/GPU gate and support new ANSALPR using OCR

This commit is contained in:
2026-04-12 17:16:16 +10:00
parent 27083a6530
commit 0a8aaed215
30 changed files with 1870 additions and 2166 deletions

View File

@@ -17,6 +17,30 @@ namespace ANSCENTER
class ANSLPR_API ANSALPR_OD :public ANSALPR {
private:
ANSCENTER::EngineType engineType;
// --------------------------------------------------------------
// Vendor predicates — use these to gate hardware-specific paths
// (NV12 GPU crop, CUDA helpers, DirectML quirks, OpenVINO tricks).
//
// Certain helpers like _nv12Helper.tryNV12CropToBGR() call into
// CUDA runtime (cv::cuda::Stream/GpuMat/cudaStream_t) unconditionally,
// which is unsafe on AMD/Intel hardware — cv::cuda::Stream's ctor
// touches the CUDA driver even when the helper would early-return.
// Always wrap those calls in isNvidiaEngine() before invoking.
// --------------------------------------------------------------
[[nodiscard]] bool isNvidiaEngine() const noexcept {
return engineType == ANSCENTER::EngineType::NVIDIA_GPU;
}
[[nodiscard]] bool isAmdEngine() const noexcept {
return engineType == ANSCENTER::EngineType::AMD_GPU;
}
[[nodiscard]] bool isIntelEngine() const noexcept {
return engineType == ANSCENTER::EngineType::OPENVINO_GPU;
}
[[nodiscard]] bool isCpuEngine() const noexcept {
return engineType == ANSCENTER::EngineType::CPU;
}
std::unique_ptr<ANSCENTER::ANSODBase>_lpDetector = nullptr; // License plate detector
std::unique_ptr<ANSCENTER::ANSODBase>_ocrDetector = nullptr; // OCR detector
std::unique_ptr<ANSCENTER::ANSODBase>_lpColourDetector = nullptr; // License plate colour classifier