forked from DayBreak-u/chineseocr_lite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DayBreak-u#370 from MistEO/onnx_c_dll
新增编译C++动态库的选项,并添加C++导出接口
- Loading branch information
Showing
20 changed files
with
333 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "OcrLitePort.h" | ||
#include "OcrStruct.h" | ||
|
||
namespace cv | ||
{ | ||
class Mat; | ||
} | ||
class OcrLite; | ||
|
||
class OCRLITE_PORT OcrLiteCaller | ||
{ | ||
public: | ||
OcrLiteCaller(); | ||
~OcrLiteCaller() = default; | ||
OcrLiteCaller(const OcrLite&) = delete; | ||
OcrLiteCaller(OcrLite&&) = delete; | ||
|
||
void setNumThread(int numOfThread); | ||
void setGpuIndex(int gpuIndex); | ||
void initModels(const std::string& detPath, const std::string& clsPath, | ||
const std::string& recPath, const std::string& keysPath); | ||
|
||
OcrResult detect(const cv::Mat& mat, | ||
int padding, int maxSideLen, | ||
float boxScoreThresh, float boxThresh, float unClipRatio, bool doAngle, bool mostAngle); | ||
|
||
OcrResult detect(const std::string& dir, const std::string& file, | ||
int padding, int maxSideLen, | ||
float boxScoreThresh, float boxThresh, float unClipRatio, bool doAngle, bool mostAngle); | ||
|
||
OcrLiteCaller& operator=(const OcrLiteCaller&) = delete; | ||
OcrLiteCaller& operator=(OcrLiteCaller&&) = delete; | ||
private: | ||
std::shared_ptr<OcrLite> m_ocrlite_ptr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#pragma once | ||
|
||
// The way how the function is called | ||
#if !defined(OCRLITE_CALL) | ||
#if defined(_WIN32) | ||
#define OCRLITE_CALL __stdcall | ||
#else | ||
#define OCRLITE_CALL | ||
#endif /* _WIN32 */ | ||
#endif /* ISSCALL */ | ||
|
||
#if defined _WIN32 || defined __CYGWIN__ | ||
#define OCRLITE_EXPORT __declspec(dllexport) | ||
#define OCRLITE_IMPORT __declspec(dllimport) | ||
#define OCRLITE_LOCAL | ||
#else // ! defined _WIN32 || defined __CYGWIN__ | ||
#if __GNUC__ >= 4 | ||
#define OCRLITE_EXPORT __attribute__ ((visibility ("default"))) | ||
#define OCRLITE_IMPORT __attribute__ ((visibility ("default"))) | ||
#define OCRLITE_LOCAL __attribute__ ((visibility ("hidden"))) | ||
#else // ! __GNUC__ >= 4 | ||
#define OCRLITE_EXPORT | ||
#define OCRLITE_IMPORT | ||
#endif // End __GNUC__ >= 4 | ||
#endif // End defined _WIN32 || defined __CYGWIN__ | ||
|
||
#ifdef __CLIB__ | ||
#define OCRLITE_PORT OCRLITE_EXPORT | ||
#else | ||
#define OCRLITE_PORT OCRLITE_IMPORT | ||
#endif // OCRLITE_PORT | ||
|
||
#define OCR_API OCRLITE_PORT OCRLITE_CALL | ||
|
||
#define OCR_LOCAL OCRLITE_LOCAL OCRLITE_CALL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifdef __CLIB__ | ||
|
||
#include "OcrLiteCaller.h" | ||
|
||
#include "OcrLite.h" | ||
|
||
OcrLiteCaller::OcrLiteCaller() | ||
: m_ocrlite_ptr(std::make_shared<OcrLite>()) | ||
{ | ||
; | ||
} | ||
|
||
void OcrLiteCaller::setNumThread(int numOfThread) | ||
{ | ||
m_ocrlite_ptr->setNumThread(numOfThread); | ||
} | ||
|
||
void OcrLiteCaller::setGpuIndex(int gpuIndex) | ||
{ | ||
m_ocrlite_ptr->setGpuIndex(gpuIndex); | ||
} | ||
|
||
void OcrLiteCaller::initModels(const std::string& detPath, const std::string& clsPath, const std::string& recPath, const std::string& keysPath) | ||
{ | ||
m_ocrlite_ptr->initModels(detPath, clsPath, recPath, keysPath); | ||
} | ||
|
||
OcrResult OcrLiteCaller::detect(const cv::Mat& mat, int padding, int maxSideLen, float boxScoreThresh, float boxThresh, float unClipRatio, bool doAngle, bool mostAngle) | ||
{ | ||
return m_ocrlite_ptr->detect(mat, padding, maxSideLen, boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle); | ||
} | ||
|
||
OcrResult OcrLiteCaller::detect(const std::string& dir, const std::string& file, int padding, int maxSideLen, float boxScoreThresh, float boxThresh, float unClipRatio, bool doAngle, bool mostAngle) | ||
{ | ||
return m_ocrlite_ptr->detect(dir.c_str(), file.c_str(), padding, maxSideLen, boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.