新增文稿自动方向识别
This commit is contained in:
parent
9ef1efab77
commit
afa11b6d16
|
@ -1,176 +1,176 @@
|
||||||
#include "./ocrcommon.h"
|
#include "./ocrcommon.h"
|
||||||
|
|
||||||
//文件类型
|
//文件类型
|
||||||
#define FILE_PDF 0 //输出精确版面复原的简体PDF文件
|
#define FILE_PDF 0 //输出精确版面复原的简体PDF文件
|
||||||
#define FILE_RTF 2 //输出精确版面复原的简体RTF文件
|
#define FILE_RTF 2 //输出精确版面复原的简体RTF文件
|
||||||
#define FILE_XLS 5 //输出简体XLS文件
|
#define FILE_XLS 5 //输出简体XLS文件
|
||||||
#define FILE_TXT 100 //输出为文本格式
|
#define FILE_TXT 100 //输出为文本格式
|
||||||
#define FILE_PDF_TXT 101 //输出文本加pdf
|
#define FILE_PDF_TXT 101 //输出文本加pdf
|
||||||
#define FILE_JSON 200 //输出为json格式
|
#define FILE_JSON 200 //输出为json格式
|
||||||
#define FILE_OFD 300 //输出双层ofd格式
|
#define FILE_OFD 300 //输出双层ofd格式
|
||||||
|
|
||||||
#define STATUS_OK 0
|
#define STATUS_OK 0
|
||||||
#define STATUS_NO_MEMORY -1
|
#define STATUS_NO_MEMORY -1
|
||||||
#define STATUS_INVALID_PARAMETER -2
|
#define STATUS_INVALID_PARAMETER -2
|
||||||
#define STATUS_FAILED -3
|
#define STATUS_FAILED -3
|
||||||
|
|
||||||
//顺时针角度
|
//顺时针角度
|
||||||
enum ROTATETYPEOUT
|
enum ROTATETYPEOUT
|
||||||
{
|
{
|
||||||
ROT0, //未旋转
|
ROT0, //未旋转
|
||||||
ROT90, //顺时针旋转90度
|
ROT90, //顺时针旋转90度
|
||||||
ROT180, //顺时针旋转180度
|
ROT180, //顺时针旋转180度
|
||||||
ROT270, //顺时针旋转270度
|
ROT270, //顺时针旋转270度
|
||||||
};
|
};
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能: 初始化
|
功能: 初始化
|
||||||
参数: ppstOcrHandle [I/O] 初始化识别句柄
|
参数: ppstOcrHandle [I/O] 初始化识别句柄
|
||||||
|
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
int HWOCR_SDKInitialize(void **ppstOcrHandle);
|
int HWOCR_SDKInitialize(void **ppstOcrHandle);
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出txt/json/rtf/xls/pdf格式
|
功能:识别jpg/bmp/tiff/png/gif图像文件,输出txt/json/rtf/xls/pdf格式
|
||||||
参数: ImgFile [I] 输入图像路径及文件名
|
参数: ImgFile [I] 输入图像路径及文件名
|
||||||
OutFile [I] 输出文件名
|
OutFile [I] 输出文件名
|
||||||
nFileType [I] 输出文件类型
|
nFileType [I] 输出文件类型
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
pLibDir [I] db文件所在目录
|
pLibDir [I] db文件所在目录
|
||||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成tmp.jpg图像。
|
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成tmp.jpg图像。
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
int HWOCR_RecognizeFile(unsigned char*ImgFile, unsigned char *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir=NULL);
|
int HWOCR_RecognizeFile(unsigned char*ImgFile, unsigned char *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir=NULL);
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能:识别jpg/bmp/tiff/png/gif批量图像文件,输出txt/json/rtf/xls/pdf格式
|
功能:识别jpg/bmp/tiff/png/gif批量图像文件,输出txt/json/rtf/xls/pdf格式
|
||||||
参数: ppImageFiles [I] 输入图像路径及文件名
|
参数: ppImageFiles [I] 输入图像路径及文件名
|
||||||
OutFile [I] 输出文件名
|
OutFile [I] 输出文件名
|
||||||
nFileType [I] 输出文件类型
|
nFileType [I] 输出文件类型
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
pLibDir [I] db文件所在目录
|
pLibDir [I] db文件所在目录
|
||||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成jpg图像。
|
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成jpg图像。
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
int HWOCR_RecognizeFileBatch(char ** ppImageFiles, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir = NULL);
|
int HWOCR_RecognizeFileBatch(char ** ppImageFiles, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir = NULL);
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能:识别内存图像的指定块,输出txt/json/rtf格式
|
功能:识别内存图像的指定块,输出txt/json/rtf格式
|
||||||
参数: pbImage [I] 图像数据
|
参数: pbImage [I] 图像数据
|
||||||
nWidth [I] 图像宽度
|
nWidth [I] 图像宽度
|
||||||
nHeight [I] 图像高度
|
nHeight [I] 图像高度
|
||||||
aLayoutInfo [I] 块属性
|
aLayoutInfo [I] 块属性
|
||||||
nColorType [I] 颜色属性
|
nColorType [I] 颜色属性
|
||||||
OutFile [I] 输出文件名
|
OutFile [I] 输出文件名
|
||||||
nFileType [I] 输出文件类型
|
nFileType [I] 输出文件类型
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
pLibDir [I] db文件所在目录
|
pLibDir [I] db文件所在目录
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
int HWOCR_RecognizeImgBlock(unsigned char*pbImage, int nWidth, int nHeight, TOCRLayoutBlockInfo aLayoutInfo,
|
int HWOCR_RecognizeImgBlock(unsigned char*pbImage, int nWidth, int nHeight, TOCRLayoutBlockInfo aLayoutInfo,
|
||||||
TColorType nColorType, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir);
|
TColorType nColorType, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir);
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出识别结果字符串
|
功能:识别jpg/bmp/tiff/png/gif图像文件,输出识别结果字符串
|
||||||
参数: ImgFile [I] 输入图像路径及文件名
|
参数: ImgFile [I] 输入图像路径及文件名
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
ppRst [O] 识别结果字符串
|
ppRst [O] 识别结果字符串
|
||||||
pnLen [O] 字符串长度
|
pnLen [O] 字符串长度
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
int HWOCR_RecognizeFile2Str(BYTE*ImgFile, void *pstHandle,char **ppRst,int* pnLen);
|
int HWOCR_RecognizeFile2Str(BYTE*ImgFile, void *pstHandle,char **ppRst,int* pnLen);
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能: 释放识别结果
|
功能: 释放识别结果
|
||||||
参数: ppRst [I] 识别结果字符串
|
参数: ppRst [I] 识别结果字符串
|
||||||
|
|
||||||
返回值: 无
|
返回值: 无
|
||||||
****************************************/
|
****************************************/
|
||||||
void HWOCR_FreeStrRst(char **ppRst);
|
void HWOCR_FreeStrRst(char **ppRst);
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能: 判断识别方向
|
功能: 判断识别方向
|
||||||
参数: ImgFile [I] 输入图像路径及文件名
|
参数: ImgFile [I] 输入图像路径及文件名
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
pDirect [O] 图像方向
|
pDirect [O] 图像方向
|
||||||
//顺时针角度
|
//顺时针角度
|
||||||
enum ROTATETYPEOUT
|
enum ROTATETYPEOUT
|
||||||
{
|
{
|
||||||
ROT0, //未旋转
|
ROT0, //未旋转
|
||||||
ROT90, //顺时针旋转90度
|
ROT90, //顺时针旋转90度
|
||||||
ROT180, //顺时针旋转180度
|
ROT180, //顺时针旋转180度
|
||||||
ROT270, //顺时针旋转270度
|
ROT270, //顺时针旋转270度
|
||||||
};
|
};
|
||||||
|
|
||||||
返回值: 正常为0,否则<0
|
返回值: 正常为0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
int HWOCR_GetFileDirect(BYTE*ImgFile, void *pstHandle, int *pDirect);
|
int HWOCR_GetFileDirect(BYTE*ImgFile, void *pstHandle, int *pDirect);
|
||||||
|
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能: 判断识别方向,支持24bit 8bit 1bit内存图像。
|
功能: 判断识别方向,支持24bit 8bit 1bit内存图像。
|
||||||
参数: pbImage [I] 输入内存图像
|
参数: pbImage [I] 输入内存图像
|
||||||
nWidth [I] 图像宽度
|
nWidth [I] 图像宽度
|
||||||
nHeight [I] 图像高度
|
nHeight [I] 图像高度
|
||||||
nColorType [I] 颜色属性
|
nColorType [I] 颜色属性
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
pDirect [O] 图像方向
|
pDirect [O] 图像方向
|
||||||
//顺时针角度
|
//顺时针角度
|
||||||
enum ROTATETYPEOUT
|
enum ROTATETYPEOUT
|
||||||
{
|
{
|
||||||
ROT0, //未旋转
|
ROT0, //未旋转
|
||||||
ROT90, //顺时针旋转90度
|
ROT90, //顺时针旋转90度
|
||||||
ROT180, //顺时针旋转180度
|
ROT180, //顺时针旋转180度
|
||||||
ROT270, //顺时针旋转270度
|
ROT270, //顺时针旋转270度
|
||||||
};
|
};
|
||||||
|
|
||||||
返回值: 正常为0,否则<0
|
返回值: 正常为0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
|
|
||||||
int HWOCR_GetFileDirectImage(BYTE*pbImage, int nWidth, int nHeight, TColorType nColorType, void *pstHandle, int *pDirect);
|
int HWOCR_GetFileDirectImage(BYTE*pbImage, int nWidth, int nHeight, TColorType nColorType, void *pstHandle, int *pDirect);
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能:识别ofd图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
功能:识别ofd图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||||
参数: OfdFile [I] 输入文件路径及文件名
|
参数: OfdFile [I] 输入文件路径及文件名
|
||||||
OutFile [I] 输出文件名
|
OutFile [I] 输出文件名
|
||||||
nFileType [I] 输出文件类型
|
nFileType [I] 输出文件类型
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
pLibDir [I] 传NULL
|
pLibDir [I] 传NULL
|
||||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。
|
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
int HWOCR_RecognizeOFD(BYTE*OfdFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
int HWOCR_RecognizeOFD(BYTE*OfdFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
功能:识别pdf图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
功能:识别pdf图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||||
参数: PdfFile [I] 输入文件路径及文件名
|
参数: PdfFile [I] 输入文件路径及文件名
|
||||||
OutFile [I] 输出文件名
|
OutFile [I] 输出文件名
|
||||||
nFileType [I] 输出文件类型
|
nFileType [I] 输出文件类型
|
||||||
pstHandle [I] 输入句柄,初始化返回的结果
|
pstHandle [I] 输入句柄,初始化返回的结果
|
||||||
pLibDir [I] 传NULL
|
pLibDir [I] 传NULL
|
||||||
pTmpDir [I] 保存临时文件的目录,需要有写权限。
|
pTmpDir [I] 保存临时文件的目录,需要有写权限。
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
int HWOCR_RecognizePDF(BYTE*PdfFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
int HWOCR_RecognizePDF(BYTE*PdfFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
功能:调用识别pdf函数前,调用此初始化函数
|
功能:调用识别pdf函数前,调用此初始化函数
|
||||||
**********************************/
|
**********************************/
|
||||||
void HWOCR_InitPdf();
|
void HWOCR_InitPdf();
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
功能:调用识别pdf函数后,调用此退出函数
|
功能:调用识别pdf函数后,调用此退出函数
|
||||||
**********************************/
|
**********************************/
|
||||||
void HWOCR_ExitPdf();
|
void HWOCR_ExitPdf();
|
||||||
/**************************************
|
/**************************************
|
||||||
功能: 释放识别句柄
|
功能: 释放识别句柄
|
||||||
参数: pstOcrHandle [I] 初始化时的句柄
|
参数: pstOcrHandle [I] 初始化时的句柄
|
||||||
|
|
||||||
返回值:正常返回0,否则<0
|
返回值:正常返回0,否则<0
|
||||||
****************************************/
|
****************************************/
|
||||||
void HWOCR_SDKExit(void *pstOcrHandle);
|
void HWOCR_SDKExit(void *pstOcrHandle);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "ocrcommon.h"
|
||||||
#include "hanwangOCRdetect.h"
|
#include "hanwangOCRdetect.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned char pbIn[] = ".\\1.bmp";
|
unsigned char pbIn[] = "1.jpg";
|
||||||
|
|
||||||
unsigned char pbOut[] = ".\\1.pdf";
|
unsigned char pbOut[] = ".\\1.pdf";
|
||||||
char pbDir[] = ".\\";
|
char pbDir[] = ".\\";
|
||||||
|
@ -17,17 +17,17 @@ int main()
|
||||||
TOCRLayoutBlockInfo aLayoutInfo;
|
TOCRLayoutBlockInfo aLayoutInfo;
|
||||||
TColorType nColorType;
|
TColorType nColorType;
|
||||||
HWOCR_SDKInitialize(&pHandel);
|
HWOCR_SDKInitialize(&pHandel);
|
||||||
HWOCR_RecognizeFile((unsigned char*)pbIn, (unsigned char* )pbOut, 0, pHandel, NULL, pbDir);
|
HWOCR_RecognizeFile((unsigned char*)pbIn, (unsigned char* )pbOut, 0, pHandel, NULL, pbDir);
|
||||||
|
|
||||||
char *pRst = NULL;
|
char *pRst = NULL;
|
||||||
int nLen = 0;
|
int nLen = 0;
|
||||||
HWOCR_RecognizeFile2Str((unsigned char*) pbIn, pHandel,&pRst, &nLen);
|
HWOCR_RecognizeFile2Str((unsigned char*) pbIn, pHandel,&pRst, &nLen);
|
||||||
FILE *fp = fopen(“rst.txt”, “wb”);
|
FILE *fp = fopen("rst.txt", "wb");
|
||||||
fwrite(pRst, 1, nLen, fp);
|
fwrite(pRst, 1, nLen, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
HWOCR_FreeStrRst(&pRst);
|
HWOCR_FreeStrRst(&pRst);
|
||||||
int nDirect = 0;
|
int nDirect = 0;
|
||||||
HWOCR_GetFileDirect((unsigned char*)pImgPath, pHandel, &nDirect);
|
HWOCR_GetFileDirect((unsigned char*)pbOut, pHandel, &nDirect);
|
||||||
fp = fopen("rst.txt", "wb");
|
fp = fopen("rst.txt", "wb");
|
||||||
fprintf(fp,"%d\r\n",nDirect);
|
fprintf(fp,"%d\r\n",nDirect);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
|
@ -42,9 +42,10 @@ target_link_libraries(${PROJECT_NAME} PRIVATE usb-1.0)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}
|
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/nick
|
${PROJECT_SOURCE_DIR}/../3rdparty/nick
|
||||||
${PROJECT_SOURCE_DIR}/../ImageProcess
|
${PROJECT_SOURCE_DIR}/../ImageProcess
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/include/hanwangOCRdetect.h
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/include/ocrcommon.h
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/include
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/include
|
||||||
${PROJECT_SOURCE_DIR}/../../../sdk/include
|
${PROJECT_SOURCE_DIR}/../../../sdk/include
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/hanwangOCRdetect.h
|
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocrcommon.h
|
|
||||||
)
|
)
|
||||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../../../build/)
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../../../build/)
|
||||||
|
|
|
@ -727,7 +727,7 @@ typedef struct _scan_conf
|
||||||
unsigned char papertype; /**< the current paper source ADF or Flatbed*/
|
unsigned char papertype; /**< the current paper source ADF or Flatbed*/
|
||||||
unsigned char paperAlign;
|
unsigned char paperAlign;
|
||||||
unsigned char en_sizecheck; /**< 尺寸检测*/
|
unsigned char en_sizecheck; /**< 尺寸检测*/
|
||||||
float imageRotateDegree;
|
float imageRotateDegree; /**< 旋转 */
|
||||||
unsigned char is_duplex; /**< True to use duplex false for simplex, ignored if flatbed*/
|
unsigned char is_duplex; /**< True to use duplex false for simplex, ignored if flatbed*/
|
||||||
unsigned char en_fold; /**<对折*/
|
unsigned char en_fold; /**<对折*/
|
||||||
int pixtype; /**< type of pixels to transfer image as */
|
int pixtype; /**< type of pixels to transfer image as */
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -15,7 +15,14 @@
|
||||||
#include "../ImageProcess/ImageApplyHeaders.h"
|
#include "../ImageProcess/ImageApplyHeaders.h"
|
||||||
#include "ImageMultiOutput.h"
|
#include "ImageMultiOutput.h"
|
||||||
#include "PaperSize.h"
|
#include "PaperSize.h"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "ocr/hanwangOCRdetect.h"
|
||||||
|
#include "ocr/ocrcommon.h"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include "scanner_manager.h"
|
#include "scanner_manager.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -515,9 +522,11 @@ namespace hg_imgproc
|
||||||
int ret = HG_ERR_OK;
|
int ret = HG_ERR_OK;
|
||||||
std::vector<cv::Mat> mats(mats_);
|
std::vector<cv::Mat> mats(mats_);
|
||||||
mats_.clear();
|
mats_.clear();
|
||||||
|
mats_.resize(mats.size());
|
||||||
|
|
||||||
CImageApplyRotation::RotationType rotatetype = CImageApplyRotation::RotationType::Invalid;
|
CImageApplyRotation::RotationType rotatetype = CImageApplyRotation::RotationType::Invalid;
|
||||||
switch ((CImageApplyRotation::RotationType)img_conf_.is_autotext)
|
|
||||||
|
switch ((CImageApplyRotation::RotationType)img_conf_.imageRotateDegree)
|
||||||
{
|
{
|
||||||
case CImageApplyRotation::RotationType::Rotate_90_clockwise:
|
case CImageApplyRotation::RotationType::Rotate_90_clockwise:
|
||||||
rotatetype = CImageApplyRotation::RotationType::Rotate_90_clockwise;
|
rotatetype = CImageApplyRotation::RotationType::Rotate_90_clockwise;
|
||||||
|
@ -532,7 +541,7 @@ namespace hg_imgproc
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img_conf_.is_autotext== TEXT_DIRECTION_AUTO)
|
if (img_conf_.is_autotext)
|
||||||
rotatetype = CImageApplyRotation::RotationType::AutoTextOrientation;
|
rotatetype = CImageApplyRotation::RotationType::AutoTextOrientation;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
char szIniFile[MAX_PATH] = {0};
|
char szIniFile[MAX_PATH] = {0};
|
||||||
|
@ -684,8 +693,44 @@ namespace hg_imgproc
|
||||||
}
|
}
|
||||||
return HG_ERR_OK;
|
return HG_ERR_OK;
|
||||||
}
|
}
|
||||||
// final
|
|
||||||
//int ocr
|
int ocr_auto_txtdirect()
|
||||||
|
{
|
||||||
|
|
||||||
|
int pDirect = -1;
|
||||||
|
int ret = HG_ERR_OK;
|
||||||
|
void *pHanld = NULL;
|
||||||
|
#ifndef x86_64 //linux x86_64 暂时没有OCR三方
|
||||||
|
std::vector<cv::Mat> mats(mats_);
|
||||||
|
mats_.clear();
|
||||||
|
|
||||||
|
|
||||||
|
ret = HWOCR_SDKInitialize(&pHanld);
|
||||||
|
for (size_t i = 0; i < mats.size(); i++)
|
||||||
|
{
|
||||||
|
ret = HWOCR_GetFileDirectImage(const_cast<uchar*>(mats[i].data),mats[i].cols,mats[i].rows,mats[i].channels()== 1 ? TColorType::EGray256:TColorType::EColor16M,pHanld,&pDirect);
|
||||||
|
printf("ret = %d pDirect=%d\r\n",ret,pDirect);
|
||||||
|
|
||||||
|
if(ret != 0)
|
||||||
|
{
|
||||||
|
return HG_ERR_NO_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pDirect == 1)
|
||||||
|
pDirect = 3;
|
||||||
|
else if(pDirect == 3)
|
||||||
|
pDirect = 1;
|
||||||
|
|
||||||
|
CImageApplyRotation(CImageApplyRotation::RotationType(pDirect)).apply(mats[i],false);
|
||||||
|
mats_.push_back(mats[i]);
|
||||||
|
}
|
||||||
|
HWOCR_SDKExit(pHanld);
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// final
|
||||||
public:
|
public:
|
||||||
int final(void)
|
int final(void)
|
||||||
{
|
{
|
||||||
|
@ -901,6 +946,10 @@ namespace hg_imgproc
|
||||||
{
|
{
|
||||||
return ((imgproc*)himg)->quality(dpi);
|
return ((imgproc*)himg)->quality(dpi);
|
||||||
}
|
}
|
||||||
|
int ocr_auto_txtdirect(HIMGPRC himg)
|
||||||
|
{
|
||||||
|
return ((imgproc*)himg)->ocr_auto_txtdirect();
|
||||||
|
}
|
||||||
int final(HIMGPRC himg)
|
int final(HIMGPRC himg)
|
||||||
{
|
{
|
||||||
return ((imgproc*)himg)->final();
|
return ((imgproc*)himg)->final();
|
||||||
|
|
|
@ -192,6 +192,8 @@ namespace hg_imgproc
|
||||||
int imgtypechange(HIMGPRC himg,std::string img_type_,void *buf,std::vector<unsigned char> &bmpdata);
|
int imgtypechange(HIMGPRC himg,std::string img_type_,void *buf,std::vector<unsigned char> &bmpdata);
|
||||||
int fold(HIMGPRC himg);
|
int fold(HIMGPRC himg);
|
||||||
int quality(HIMGPRC himg,int dpi);
|
int quality(HIMGPRC himg,int dpi);
|
||||||
|
int ocr_auto_txtdirect(HIMGPRC himg);
|
||||||
|
|
||||||
int final(HIMGPRC himg);
|
int final(HIMGPRC himg);
|
||||||
|
|
||||||
// pimh must not to be NULL, and pimh->total_bytes indicates the length of 'buf'
|
// pimh must not to be NULL, and pimh->total_bytes indicates the length of 'buf'
|
||||||
|
|
|
@ -20,9 +20,9 @@ message(STATUS ${CMAKE_HOST_SYSTEM_NAME})
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||||
${PROJECT_SOURCE_DIR}/../../../build/libgdev.a
|
${PROJECT_SOURCE_DIR}/../../../build/libgdev.a
|
||||||
${PROJECT_SOURCE_DIR}/../../../build/libgimgproc.a
|
${PROJECT_SOURCE_DIR}/../../../build/libgimgproc.a
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libopencv_world.a
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libopencv_world.a
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libIlmImf.a
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libIlmImf.a
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/liblibjasper.a
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/liblibjasper.a
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/liblibjpeg-turbo.a
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/liblibjpeg-turbo.a
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/liblibpng.a
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/liblibpng.a
|
||||||
|
@ -48,16 +48,18 @@ elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libittnotify.a
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libittnotify.a
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libtegra_hal.a
|
${PROJECT_SOURCE_DIR}/../3rdparty/opencv/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/libtegra_hal.a
|
||||||
|
|
||||||
|
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libexportfile.so
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libcnocr.so
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libcnocr.so
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libconvert.so
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libconvert.so
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libdocseg.so
|
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libexportfile.so
|
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libhwocrdetect.so
|
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libhwocrjni.so
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libhwocrjni.so
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libcrypto.so.1.0.0
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libdocseg.so
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libofd.so
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libofd.so
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libpdfparse.so
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libpdfparse.so
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libtinyxml2.so
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libtinyxml2.so
|
||||||
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libzip.so
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libzip.so
|
||||||
|
${PROJECT_SOURCE_DIR}/../3rdparty/ocr/lib/uos/${CMAKE_SYSTEM_PROCESSOR}/lib/libhwocrdetect.so
|
||||||
#message("静态库预留03")
|
#message("静态库预留03")
|
||||||
#message("静态库预留04")
|
#message("静态库预留04")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue