You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB
C

#pragma once
#include <vector>
#include "OCRToolBox.h"
#include <opencv2/opencv.hpp>
#include <onnxruntime_cxx_api.h>
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<int>& mapper, bool estimateNumChars);
public:
EasyOCR_Detector();
EasyOCR_Detector(const EasyOCR_Detector&) = delete;
public:
bool Init();
bool UnInit();
bool RecheckModelInfo();
/// <summary>
/// EasyOCR <20>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><E2BAAF>
/// </summary>
/// <param name="image"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>BGRͼ<52><CDBC><EFBFBD><EFBFBD></param>
/// <returns><3E><><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE>ο<EFBFBD></returns>
EOCRD_Rects operator()(const cv::Mat& image);
};
}