Fix ALPR Batch and memory leak

This commit is contained in:
2026-04-15 23:00:19 +10:00
parent b05c49ad93
commit 808df4656d
8 changed files with 1846 additions and 54 deletions

View File

@@ -86,6 +86,19 @@ namespace ANSCENTER
static bool resizeImage(cv::Mat& inputImage, int resizeWidth, int orginalImageSize=0);
static bool cropImage(cv::Mat& inputImage, const cv::Rect& resizeROI, int originalImageSize=0);
static bool ImagesToMP4(const std::string& imageFolder, const std::string& outputVideoPath, int maxWidth, int fps);
// Direct FFmpeg (libav*) encoder path. Prefers HEVC/H.265 (libx265),
// falls back to H.264 (libx264), then MPEG-4 Part 2 (mpeg4).
// Produces significantly smaller files than ImagesToMP4 for the same
// visual quality. Same parameter meaning as ImagesToMP4.
static bool ImagesToMP4FF(const std::string& imageFolder, const std::string& outputVideoPath, int maxWidth, int fps);
// Hardware-accelerated FFmpeg path. Tries, in order:
// hevc_nvenc, hevc_qsv, hevc_amf (NVIDIA/Intel/AMD HEVC)
// h264_nvenc, h264_qsv, h264_amf (NVIDIA/Intel/AMD H.264)
// libx265, libx264, mpeg4 (software fallbacks)
// First encoder that opens successfully is used. HEVC is preferred
// everywhere because it compresses ~40% smaller than H.264 at the
// same visual quality, and hardware HEVC is free on any modern GPU.
static bool ImagesToMP4HW(const std::string& imageFolder, const std::string& outputVideoPath, int maxWidth, int fps);
private:
void CheckLicense();
@@ -166,6 +179,17 @@ extern "C" __declspec(dllexport) int ANSCV_ImagePatternMatchs_S(cv::Mat** image
extern "C" __declspec(dllexport) int ANSCV_ImagesToMP4_S(const char* imageFolder, const char* outputVideoPath, int maxWidth, int fps);
// Direct-FFmpeg variant. Same signature as ANSCV_ImagesToMP4_S but uses libav*
// encoders directly with libx265/libx264 tuning for smaller output files.
extern "C" __declspec(dllexport) int ANSCV_ImagesToMP4FF_S(const char* imageFolder, const char* outputVideoPath, int maxWidth, int fps);
// Hardware-accelerated variant. Tries NVIDIA (NVENC), Intel (QSV), and AMD
// (AMF) HEVC/H.264 encoders in order, then falls back to software encoders.
// Same signature as ANSCV_ImagesToMP4_S.
extern "C" __declspec(dllexport) int ANSCV_ImagesToMP4HW_S(const char* imageFolder, const char* outputVideoPath, int maxWidth, int fps);
// Prints the license string of the FFmpeg libraries linked into ANSCV.dll
// (LGPL vs GPL). Useful for verifying whether the bundled FFmpeg build is
// commercially safe to distribute. Prints to stdout.
extern "C" __declspec(dllexport) void ANSCV_PrintFFmpegLicense_S();
// IMAQ -> cv::Mat conversion (NI Vision Image*, auto-detects indirection level)
extern "C" __declspec(dllexport) int ANSCV_IMAQ2Image(void* imaqHandle, cv::Mat** imageOut);