Improve ALPR_OCR peformance
This commit is contained in:
@@ -50,7 +50,8 @@ bool ANSONNXOCR::Initialize(const std::string& licenseKey, OCRModelConfig modelC
|
||||
_modelConfig.detectionModelFile,
|
||||
clsModelPath,
|
||||
_modelConfig.recognizerModelFile,
|
||||
_modelConfig.recogizerCharDictionaryPath);
|
||||
_modelConfig.recogizerCharDictionaryPath,
|
||||
_modelConfig.useTensorRT);
|
||||
|
||||
return _isInitialized;
|
||||
}
|
||||
@@ -391,4 +392,16 @@ std::pair<std::string, float> ANSONNXOCR::RecognizeText(const cv::Mat& croppedIm
|
||||
return {result.text, result.score};
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, float>> ANSONNXOCR::RecognizeTextBatch(
|
||||
const std::vector<cv::Mat>& croppedImages) {
|
||||
std::vector<std::pair<std::string, float>> out(croppedImages.size(), {"", 0.0f});
|
||||
if (!_isInitialized || !_engine || croppedImages.empty()) return out;
|
||||
|
||||
auto lines = _engine->recognizeMany(croppedImages);
|
||||
for (size_t i = 0; i < lines.size() && i < out.size(); ++i) {
|
||||
out[i] = { lines[i].text, lines[i].score };
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace ANSCENTER
|
||||
|
||||
Reference in New Issue
Block a user