This commit is contained in:
恍兮惚兮 2024-11-15 03:44:19 +08:00
parent fcb05dbcc4
commit ec1e74ce41

View File

@ -1,3 +1,4 @@
#ifndef WINXP
#include <onnxruntime/core/session/onnxruntime_cxx_api.h>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc.hpp>
@ -632,13 +633,13 @@ std::vector<cv::Mat> OcrLite::getPartImages(cv::Mat &src, std::vector<TextBox> &
return partImages;
}
void matRotateClockWise180(cv::Mat& src)
void matRotateClockWise180(cv::Mat &src)
{
flip(src, src, 0);
flip(src, src, 1);
}
void matRotateClockWise90(cv::Mat& src)
void matRotateClockWise90(cv::Mat &src)
{
transpose(src, src);
flip(src, src, 1);
@ -704,13 +705,14 @@ std::vector<TextBlock> OcrLite::detect_internal(cv::Mat &src, cv::Rect &originRe
return textBlocks;
}
#endif
struct ocrpoints
{
int x1, y1, x2, y2, x3, y3, x4, y4;
};
DECLARE_API OcrLite *OcrInit(const wchar_t *szDetModel, const wchar_t *szRecModel, const wchar_t *szKeyPath, int nThreads)
{
#ifndef WINXP
OcrLite *pOcrObj = nullptr;
try
{
@ -727,10 +729,14 @@ DECLARE_API OcrLite *OcrInit(const wchar_t *szDetModel, const wchar_t *szRecMode
{
return nullptr;
}
#else
return nullptr;
#endif
}
DECLARE_API void OcrDetect(OcrLite *pOcrObj, const void *binptr, size_t size, Directional mode, void (*cb)(ocrpoints, const char *))
{
#ifndef WINXP
if (!pOcrObj)
return;
@ -750,10 +756,13 @@ DECLARE_API void OcrDetect(OcrLite *pOcrObj, const void *binptr, size_t size, Di
catch (...)
{
}
#endif
}
DECLARE_API void OcrDestroy(OcrLite *pOcrObj)
{
#ifndef WINXP
if (pOcrObj)
delete pOcrObj;
#endif
}