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

@@ -1,6 +1,7 @@
#include "ANSWEBCAM.h"
#include "ANSMatRegistry.h"
#include "ANSGpuFrameRegistry.h"
#include "ANSCVVendorGate.h" // anscv_vendor_gate::IsNvidiaGpuAvailable()
#include <cstdint>
#include <memory>
extern "C" {
@@ -914,6 +915,15 @@ namespace ANSCENTER {
return result;
}
void ANSWEBCAMPlayer::uploadPlanarBGRToGPU(const cv::Mat& inputMat, unsigned char** data) {
// Refuse on non-NVIDIA — cudaMalloc/cudaMemcpy are NVIDIA-only.
// The public entry point encodeMatToJpegWithNvJPEG() also guards,
// but defense-in-depth in case a future caller wires this up directly.
if (!anscv_vendor_gate::IsNvidiaGpuAvailable()) {
this->_logger.LogWarn("ANSWEBCAMPlayer::uploadPlanarBGRToGPU",
"skipped — non-NVIDIA hardware, nvJPEG path unavailable", __FILE__, __LINE__);
if (data) *data = nullptr;
return;
}
std::lock_guard<std::recursive_mutex> lock(_mutex);
try {
int width = inputMat.cols;
@@ -933,6 +943,13 @@ namespace ANSCENTER {
}
std::string ANSWEBCAMPlayer::encodeMatToJpegWithNvJPEG(const cv::Mat& inputMat, int quality)
{
// nvJPEG encoder is NVIDIA-only (part of CUDA toolkit). Refuse on
// AMD/Intel/CPU and let the caller fall back to the turbojpeg path.
if (!anscv_vendor_gate::IsNvidiaGpuAvailable()) {
this->_logger.LogWarn("ANSWEBCAMPlayer::encodeMatToJpegWithNvJPEG",
"nvJPEG requires NVIDIA GPU; falling back to last cached JPEG", __FILE__, __LINE__);
return _lastJpegImage;
}
std::lock_guard<std::recursive_mutex> lock(_mutex);
try {
// Image dimensions