Improve ALPR_OCR peformance

This commit is contained in:
2026-04-14 20:30:21 +10:00
parent 3349b45ade
commit f9a0af8949
18 changed files with 991 additions and 77 deletions

View File

@@ -25,10 +25,13 @@ public:
// Initialize the OCR pipeline
// clsModelPath can be empty to skip classification
// preferTensorRT: try TensorRT EP first for the three sub-models
// (cuDNN-friendly cuDNN max-workspace mode either way)
bool Initialize(const std::string& detModelPath,
const std::string& clsModelPath,
const std::string& recModelPath,
const std::string& dictPath);
const std::string& dictPath,
bool preferTensorRT = false);
// Run full OCR pipeline on an image
// Returns results matching PaddleOCR::OCRPredictResult format
@@ -37,6 +40,14 @@ public:
// Run recognizer only on a pre-cropped text image (no detection step)
TextLine recognizeOnly(const cv::Mat& croppedImage);
// Run recognizer only on a batch of pre-cropped text images in a
// single batched ORT inference. Skips the detector entirely — the
// caller is expected to supply crops that are already roughly
// axis-aligned single-line text (e.g. ALPR plate ROIs, optionally
// pre-split into rows). Crops are grouped by bucket width, so a
// single call to this function typically issues 12 ORT Runs total.
std::vector<TextLine> recognizeMany(const std::vector<cv::Mat>& croppedImages);
// Configuration setters (matching OCRModelConfig parameters)
void SetDetMaxSideLen(int val) { _maxSideLen = val; }
void SetDetDbThresh(float val) { _detDbThresh = val; }