#pragma once #include #include "OCRToolBox.h" #include #include namespace uns { class EasyOCR_Detector { private: const float lowText = 0.4f; const float textThreshold = 0.7f; const float linkThreshold = 0.4f; private: const OrtApi* ort; Ort::Env ort_env; Ort::Session* ort_cpu_session; Ort::SessionOptions ort_session_options; bool ort_inited; std::wstring model_path; IONames input_names, output_names; IONamesStorage input_ns, output_ns; private: cv::Mat NormalizeMeanVariance(const cv::Mat& in); void AdjustResultCoordinates(EOCRD_Rects& polys, float ratioW, float ratioH, float ratioNet = 2.0f); void ResizeAspectRatio(const cv::Mat& src, cv::Mat& dst, float squareSize, float magRatio, float& ratio, cv::Size& heatmapSize); bool GetDetBoxesCore(const cv::Mat& textmap, const cv::Mat& linkmap, float textThresh, float linkThresh, float lowText, EOCRD_Rects& boxes, cv::Mat& labels, std::vector& mapper, bool estimateNumChars); public: EasyOCR_Detector(); EasyOCR_Detector(const EasyOCR_Detector&) = delete; public: bool Init(); bool UnInit(); bool RecheckModelInfo(); /// /// EasyOCR 文本检测函数 /// /// 待检测的图像(三通道BGR图像) /// 检测到的矩形框 EOCRD_Rects operator()(const cv::Mat& image); }; }