| 223 | } |
| 224 | |
| 225 | OCRer::Result OCRer::predict_only_rec(const cv::Mat& image_roi) const |
| 226 | { |
| 227 | if (!recer_) { |
| 228 | LogError << "recer_ is null"; |
| 229 | return { }; |
| 230 | } |
| 231 | |
| 232 | std::string reco_text; |
| 233 | float reco_score = 0; |
| 234 | bool ret = false; |
| 235 | { |
| 236 | std::unique_lock lock(s_predict_mutex_); |
| 237 | ret = recer_->Predict(image_roi, &reco_text, &reco_score); |
| 238 | } |
| 239 | if (!ret) { |
| 240 | LogWarn << "recer_ return false" << VAR(recer_) << VAR(image_) << VAR(image_roi); |
| 241 | return { }; |
| 242 | } |
| 243 | |
| 244 | auto text = to_u16(reco_text); |
| 245 | Result result { .text = std::move(text), .box = { 0, 0, image_roi.cols, image_roi.rows }, .score = reco_score }; |
| 246 | |
| 247 | return result; |
| 248 | } |
| 249 | |
| 250 | OCRer::ResultsVec OCRer::predict_batch_rec(const std::vector<cv::Rect>& rois) const |
| 251 | { |