#pragma once #include "RTOCRTypes.h" #include "engine.h" #include "engine/EnginePoolManager.h" #include #include namespace ANSCENTER { namespace rtocr { class RTOCRDetector { public: RTOCRDetector() = default; ~RTOCRDetector(); RTOCRDetector(const RTOCRDetector&) = delete; RTOCRDetector& operator=(const RTOCRDetector&) = delete; bool Initialize(const std::string& onnxPath, int gpuId = 0, const std::string& engineCacheDir = "", int maxSideLen = kDetMaxSideLen); std::vector Detect(const cv::Mat& image, int maxSideLen = kDetMaxSideLen, float dbThresh = kDetDbThresh, float boxThresh = kDetBoxThresh, float unclipRatio = kDetUnclipRatio, bool useDilation = false); private: // Postprocessing helpers (matches ONNX/PaddleOCR official flow exactly) std::array GetMiniBoxes(const cv::RotatedRect& rect); float BoxScoreFast(const cv::Mat& probMap, const std::array& box); std::vector UnclipPolygon(const std::array& box, float unclipRatio); std::shared_ptr> m_engine = nullptr; EnginePoolManager::PoolKey m_poolKey; bool m_usingSharedPool = false; int m_engineMaxSideLen = kDetMaxSideLen; // Actual TRT engine max spatial dim std::mutex _mutex; }; } // namespace rtocr } // namespace ANSCENTER