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.

47 lines
1.4 KiB
C++

#pragma once
#include <map>
#include <vector>
#include <string>
#include "OCRConfig.h"
#include <opencv2/core/core.hpp>
#include "LibEasyOCR-CPP-Export.h"
namespace uns
{
namespace easyocr
{
using EOCR_Result = std::tuple<std::wstring, float>;
using EOCR_Result_Single = std::tuple<std::wstring, float, cv::Rect>;
using EOCR_ResultSet = std::map<size_t, EOCR_Result_Single>;
using EOCRD_Rects = std::vector<std::vector<cv::Point2f>>;
}
class LIBEASYOCRCPP_API EasyOCR_CPP
{
public:
static OCRConfig& GlobalOCRConfig();
static void SetRecognitionModel(const std::wstring& reco_model, easyocr::CharsetType language);
static bool CleanupOCR();
static bool InitDetectionModel();
static bool InitRecognitionModel();
static easyocr::EOCRD_Rects Detect(const cv::Mat& img);
static easyocr::EOCR_Result Recognize(const cv::Mat& img);
static easyocr::EOCR_ResultSet Recognize(const cv::Mat& img, const easyocr::EOCRD_Rects& rects);
static easyocr::EOCR_ResultSet FullAuto(const cv::Mat& img);
};
class LIBEASYOCRCPP_API EOCR_SupportTools
{
public:
static std::string WtoA(const std::wstring& wstr);
static std::wstring AtoW(const std::string& str);
static std::string AtoUTF8(const std::string& str);
static std::string UTF8toA(const std::string& utf8);
static cv::Mat ReadImage(const std::string& file, bool blur = false, int blur_size = 3);
static cv::Mat ReadImage(const std::wstring& file, bool blur = false, int blur_size = 3);
};
}