twain3.0/3rdparty/gpdf/hg_gpdf.h

86 lines
2.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* ====================================================
* 功能本地图片进行OCR并生成多页PDF功能
* 作者:刘丁维
* 生成时间2020/3/5
* 最近修改时间2020/3/5
* 版本号v1.0
* ====================================================
*/
#ifndef HG_GPDF_H
#define HG_GPDF_H
#if defined (_WIN32)
#if !defined (HG_GPDF_API_BUILD)
#define HG_GPDF_API __declspec(dllexport)
#else
#define HG_GPDF_API __declspec(dllimport)
#endif
#else
#define HG_GPDF_API
#endif
class HG_GPDF_API HG_OCR
{
public:
//识别模式
enum RECOGNITION_MODE
{
RECOGNITION_OSD, //文稿方向识别模式
RECOGNITION_OCR //字符识别模式
};
//字符识别保存模式
enum SAVE_MODE
{
SAVE_PDF = 0x01, //PDF保存字符识别结果
SAVE_TXT = 0x02, //TXT保存字符识别结果
SAVE_PDF_TXT = 0x03 //同时采用PDF和TXT保存字符识别结果
};
public:
HG_OCR();
~HG_OCR();
/*
* 函数功能初始化PDF生成器
* trainFile:[in] 训练库文件路径,不含文件名,末尾无需'/'结尾
* mode[in] 具体选项参照 enum RECOGNITION_MODE默认值为RECOGNITION_OCR
* 返回值0为成功否则为异常。异常查看打印输出
*/
int init(const char* trainFile, RECOGNITION_MODE mode = RECOGNITION_OCR);
/*
* 函数功能:字符识别,并生成文本
* inputFileNames:[in] 本地待识别图片完整路径,可同时输入多个图片路径
* numOfFiles[in] inputFileNames长度
* numOfFiles[in] inputFileNames长度
* outputFileName[in] 识别结果保存路径,包含文件基础名字,不含文件后缀名
* flag[in] 字符识别保存模式,参照 enum SAVE_MODE
* 返回值true为成功否则为异常。异常查看打印输出
*/
bool ocr(const char** inputFileNames, int numOfFiles, const char* outputFileName, SAVE_MODE flag = SAVE_PDF);
/*
* 函数功能:文本方向识别
* data:[in] 图像数据指针
* width[in] 图像宽度
* height[in] 图像高度
* channels[in] 图像通道
* dpi[in] 图片DPI
* 返回值以顺时针进行计数输出0,90,180,270四种结果
*/
int orientation(const unsigned char* data, int width, int height, int channels, int dpi);
private:
void* m_ptr;
};
#endif //HG_GPDF_H