11#include " OCR.h"
22
3- namespace rnexecutorch {} // namespace rnexecutorch
3+ #include < rnexecutorch/models/ocr/Constants.h>
4+
5+ namespace rnexecutorch {
6+ OCR::OCR (std::string detectorSource, std::string recognizerSourceLarge,
7+ std::string recognizerSourceMedium, std::string recognizerSourceSmall,
8+ std::string symbols, std::shared_ptr<react::CallInvoker> callInvoker)
9+ : detector(detectorSource, callInvoker),
10+ recognitionHandler (symbols, recognizerSourceLarge, recognizerSourceMedium,
11+ recognizerSourceSmall, callInvoker) {}
12+
13+ std::vector<OCRDetection> OCR::forward (std::string input) {
14+ std::vector<DetectorBBox> detectorResult = detector.forward (input);
15+ cv::Mat grayscaleImg = imageprocessing::readImage (input);
16+ cv::cvtColor (grayscaleImg, grayscaleImg, cv::COLOR_BGR2GRAY);
17+ std::vector<OCRDetection> result = recognitionHandler.recognize (
18+ detectorResult, grayscaleImg, recognizerImageSize, recognizerImageSize);
19+ return result;
20+ }
21+
22+ void OCR::unloadModule () {
23+ detector.unload ();
24+ recognitionHandler.unload ();
25+ }
26+
27+ std::size_t OCR::getMemoryLowerBound () {
28+ return detector.getMemoryLowerBound () +
29+ recognitionHandler.getMemoryLowerBound ();
30+ }
31+ } // namespace rnexecutorch
0 commit comments