解决websocket增加上传功能后在linux上编译不过的问题
This commit is contained in:
parent
3dba99c968
commit
62146c7dbe
|
@ -29,6 +29,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <dlfcn.h>
|
||||
#include <iconv.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#endif /* __HGINC_H__ */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/uos/amd64/include" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-L../../../third_party/opencv/uos/amd64/lib" />
|
||||
|
@ -26,6 +27,7 @@
|
|||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../HGBase/bin/uos_x86_64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/uos_x86_64_Debug -lHGImgFmt" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_x86_64_Release">
|
||||
|
@ -38,6 +40,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/uos/amd64/include" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -48,7 +51,7 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../../release/uos/x86_64 -lHGBase" />
|
||||
<Add option="-L../../../../release/uos/x86_64 -lHGBase -lHGImgFmt" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_aarch64_Debug">
|
||||
|
@ -61,6 +64,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/uos/aarch64/include" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-L../../../third_party/opencv/uos/aarch64/lib" />
|
||||
|
@ -71,6 +75,7 @@
|
|||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../HGBase/bin/uos_aarch64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/uos_aarch64_Debug -lHGImgFmt" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_aarch64_Release">
|
||||
|
@ -83,6 +88,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/uos/aarch64/include" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -93,7 +99,7 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../../release/uos/aarch64 -lHGBase" />
|
||||
<Add option="-L../../../../release/uos/aarch64 -lHGBase -lHGImgFmt" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_mips64_Debug">
|
||||
|
@ -106,6 +112,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/uos/mips64/include" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-L../../../third_party/opencv/uos/mips64/lib" />
|
||||
|
@ -115,6 +122,7 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../HGBase/bin/uos_mips64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/uos_mips64_Debug -lHGImgFmt" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_mips64_Release">
|
||||
|
@ -127,6 +135,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/uos/mips64/include" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -136,7 +145,7 @@
|
|||
<Add option="-lopencv_imgproc" />
|
||||
<Add option="-lopencv_core" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../../release/uos/mips64 -lHGBase" />
|
||||
<Add option="-L../../../../release/uos/mips64 -lHGBase -lHGImgGmt" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
|
@ -155,6 +164,14 @@
|
|||
<Unit filename="../../../imgproc/HGImgProc.cpp" />
|
||||
<Unit filename="../../../imgproc/HGImgProc.h" />
|
||||
<Unit filename="../../../imgproc/HGImgProcErr.h" />
|
||||
<Unit filename="../../../imgproc/HGOCR.cpp" />
|
||||
<Unit filename="../../../imgproc/HGOCR.h" />
|
||||
<Unit filename="../../../imgproc/HGOCRBase.cpp" />
|
||||
<Unit filename="../../../imgproc/HGOCRBase.hpp" />
|
||||
<Unit filename="../../../imgproc/HGOCRHanvon.cpp" />
|
||||
<Unit filename="../../../imgproc/HGOCRHanvon.hpp" />
|
||||
<Unit filename="../../../imgproc/HGOCRRetImpl.cpp" />
|
||||
<Unit filename="../../../imgproc/HGOCRRetImpl.hpp" />
|
||||
<Unit filename="../../../imgproc/hg_imageprocess.cpp" />
|
||||
<Unit filename="../../../imgproc/hg_imageprocess.hpp" />
|
||||
<Extensions>
|
||||
|
|
|
@ -2,31 +2,9 @@
|
|||
#include "../../../base/HGBase.h"
|
||||
#include "../../../imgfmt/HGImgFmt.h"
|
||||
#include "../../../imgproc/HGImgProc.h"
|
||||
#include "../../../imgproc/HGOCR.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
HGImage img = NULL;
|
||||
|
||||
HGImgFmt_LoadImage("1.pdf", 0, NULL, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_TOP, &img);
|
||||
HGImgFmt_SaveImage(img, 0, NULL, 0, "pdf2pdf.pdf");
|
||||
HGBase_DestroyImage(img);
|
||||
|
||||
HGImgFmt_LoadImage("1.jpg", 0, NULL, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_TOP, &img);
|
||||
HGImgFmt_SaveImage(img, 0, NULL, 0, "jpg2pdf.pdf");
|
||||
HGBase_DestroyImage(img);
|
||||
|
||||
HGImgFmt_LoadImage("1.pdf", 0, NULL, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_TOP, &img);
|
||||
HGImgFmt_SaveImage(img, 0, NULL, 0, "pdf2jpg.jpg");
|
||||
HGBase_DestroyImage(img);
|
||||
|
||||
HGImgFmt_LoadImage("1.bmp", 0, NULL, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_BOTTOM, &img);
|
||||
HGImage imgCrop = NULL;
|
||||
HGImgProc_ImageDeskew(img, HGFALSE, HGFALSE, NULL, 800, 1200, HGBASE_IMGTYPE_BGRA, HGBASE_IMGORIGIN_TOP, &imgCrop);
|
||||
HGImgFmt_SaveImage(imgCrop, 0, NULL, 0, "deskew.bmp");
|
||||
HGBase_DestroyImage(imgCrop);
|
||||
HGBase_DestroyImage(img);
|
||||
|
||||
HGBase_WriteInfo(HGBASE_INFOTYPE_DEBUG, "%d", 123456);
|
||||
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "%d", 12345);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/libzip/uos/amd64/include" />
|
||||
<Add directory="../../../third_party/libcurl/uos/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-L../HGBase/bin/uos_x86_64_Debug -lHGBase" />
|
||||
|
@ -25,6 +26,7 @@
|
|||
<Add option="-lhgdriver" />
|
||||
<Add option="-L../../../third_party/libzip/uos/amd64/lib -lzip" />
|
||||
<Add option="-L../../../third_party/zlib/uos/amd64/lib -lz" />
|
||||
<Add option="-L../../../third_party/libcurl/uos/amd64/lib -lcurl" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_x86_64_Release">
|
||||
|
@ -35,6 +37,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/libzip/uos/amd64/include" />
|
||||
<Add directory="../../../third_party/libcurl/uos/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -47,6 +50,7 @@
|
|||
<Add option="-lhgdriver" />
|
||||
<Add option="-L../../../third_party/libzip/uos/amd64/lib -lzip" />
|
||||
<Add option="-L../../../third_party/zlib/uos/amd64/lib -lz" />
|
||||
<Add option="-L../../../third_party/libcurl/uos/amd64/lib -lcurl" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_aarch64_Debug">
|
||||
|
@ -57,6 +61,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/libzip/uos/aarch64/include" />
|
||||
<Add directory="../../../third_party/libcurl/uos/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-L../HGBase/bin/uos_aarch64_Debug -lHGBase" />
|
||||
|
@ -68,6 +73,7 @@
|
|||
<Add option="-lhgdriver" />
|
||||
<Add option="-L../../../third_party/libzip/uos/aarch64/lib -lzip" />
|
||||
<Add option="-L../../../third_party/zlib/uos/aarch64/lib -lz" />
|
||||
<Add option="-L../../../third_party/libcurl/uos/aarch64/lib -lcurl" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_aarch64_Release">
|
||||
|
@ -78,6 +84,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/libzip/uos/aarch64/include" />
|
||||
<Add directory="../../../third_party/libcurl/uos/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -90,6 +97,7 @@
|
|||
<Add option="-lhgdriver" />
|
||||
<Add option="-L../../../third_party/libzip/uos/aarch64/lib -lzip" />
|
||||
<Add option="-L../../../third_party/zlib/uos/aarch64/lib -lz" />
|
||||
<Add option="-L../../../third_party/libcurl/uos/aarch64/lib -lcurl" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_mips64_Debug">
|
||||
|
@ -100,6 +108,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/libzip/uos/mips64/include" />
|
||||
<Add directory="../../../third_party/libcurl/uos/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-L../HGBase/bin/uos_mips64_Debug -lHGBase" />
|
||||
|
@ -111,6 +120,7 @@
|
|||
<Add option="-lhgdriver" />
|
||||
<Add option="-L../../../third_party/libzip/uos/mips64/lib -lzip" />
|
||||
<Add option="-L../../../third_party/zlib/uos/mips64/lib -lz" />
|
||||
<Add option="-L../../../third_party/libcurl/uos/mips64/lib -lcurl" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="uos_mips64_Release">
|
||||
|
@ -121,6 +131,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/libzip/uos/mips64/include" />
|
||||
<Add directory="../../../third_party/libcurl/uos/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -133,6 +144,7 @@
|
|||
<Add option="-lhgdriver" />
|
||||
<Add option="-L../../../third_party/libzip/uos/mips64/lib -lzip" />
|
||||
<Add option="-L../../../third_party/zlib/uos/mips64/lib -lz" />
|
||||
<Add option="-L../../../third_party/libcurl/uos/mips64/lib -lcurl" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
|
@ -144,6 +156,9 @@
|
|||
<Add directory="../../../third_party/json" />
|
||||
<Add directory="../../../../sdk/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-lpthread" />
|
||||
</Linker>
|
||||
<Unit filename="../../../sdk/webservice/HttpHead.cpp" />
|
||||
<Unit filename="../../../sdk/webservice/HttpHead.h" />
|
||||
<Unit filename="../../../sdk/webservice/HttpUser.cpp" />
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
</Project>
|
||||
<Project filename="HGImgProc/HGImgProc.cbp">
|
||||
<Depends filename="HGBase/HGBase.cbp" />
|
||||
<Depends filename="HGImgFmt/HGImgFmt.cbp" />
|
||||
</Project>
|
||||
<Project filename="HGSaneUser/HGSaneUser.cbp">
|
||||
<Depends filename="HGBase/HGBase.cbp" />
|
||||
|
|
|
@ -578,7 +578,7 @@ bool HGOfdImageWriterImpl::AddDocXml()
|
|||
|
||||
tinyxml2::XMLElement* physicalBox = xmlDoc.NewElement("ofd:PhysicalBox");
|
||||
char physicalBoxText[512];
|
||||
sprintf(physicalBoxText, "0.000000 0.000000 %f %f", A4page_page_PhysicalBox_Width,
|
||||
sprintf(physicalBoxText, "0.000000 0.000000 %f %f", A4page_page_PhysicalBox_Width,
|
||||
A4page_page_PhysicalBox_Height);
|
||||
physicalBox->SetText(physicalBoxText);
|
||||
pageArea->InsertEndChild(physicalBox);
|
||||
|
@ -752,7 +752,7 @@ bool HGOfdImageWriterImpl::AddContentXmlFile(HGUInt index, HGFloat physicalWidth
|
|||
imgObject->SetAttribute("CTM", ctmText);
|
||||
layer->InsertEndChild(imgObject);
|
||||
|
||||
HGChar name[128];
|
||||
HGChar name[256];
|
||||
sprintf(name, "%s/Content.xml", dir);
|
||||
return AddXmlFile(xmlDoc, name);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ HGResult HGOCRHanvon::Init()
|
|||
#if defined(HG_CMP_MSC)
|
||||
HGResult ret = HGBase_CreateDll("hanwangOCRdetect.dll", &m_dll);
|
||||
#else
|
||||
HGResult ret = HGBase_CreateDll("hanwangOCRdetect.so", &m_dll);
|
||||
HGResult ret = HGBase_CreateDll("libhwocrdetect.so", &m_dll);
|
||||
#endif
|
||||
HGBase_SetCurrentDir(oldDir);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
|
@ -288,4 +288,4 @@ int HGOCRHanvon::HWOCR_GetFileDirect(unsigned char* ImgFile, void* pstHandle, in
|
|||
}
|
||||
|
||||
return func(ImgFile, pstHandle, pDirect);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1355,8 +1355,8 @@ bool Manager::GetImageBase64(const std::string& devId, const std::string& imgNam
|
|||
|
||||
std::string Manager::GetFilePath(const std::string& devId)
|
||||
{
|
||||
HGChar docsPath[512];
|
||||
HGBase_GetDocumentsPath(docsPath, 512);
|
||||
HGChar docsPath[256];
|
||||
HGBase_GetDocumentsPath(docsPath, 256);
|
||||
HGChar imgPath[512];
|
||||
sprintf(imgPath, "%sHuago/WebService/%s/", docsPath, Utf8ToStdString(devId.c_str()).c_str());
|
||||
HGChar stdImgPath[512];
|
||||
|
@ -1547,7 +1547,7 @@ bool Manager::SaveBase64(const std::string& fileName, const char* base64)
|
|||
HGBase_Base64Decode((const HGByte*)base64, (HGSize)base64Size, data, &size);
|
||||
|
||||
size_t writeLen = fwrite(data, 1, size, file);
|
||||
if (writeLen == size)
|
||||
if (writeLen == (size_t)size)
|
||||
ret = true;
|
||||
|
||||
delete[] data;
|
||||
|
@ -1560,7 +1560,7 @@ bool Manager::SaveBase64(const std::string& fileName, const char* base64)
|
|||
static std::string MakePreFileData(const char* pszBoundary, const char* pszRemoteFileName)
|
||||
{
|
||||
char data[512];
|
||||
sprintf(data, "--%s\r\nContent-Disposition: form-data; name=\"filedata\"; filename=\"%s\"\r\n",
|
||||
sprintf(data, "--%s\r\nContent-Disposition: form-data; name=\"filedata\"; filename=\"%s\"\r\n",
|
||||
pszBoundary, pszRemoteFileName);
|
||||
std::string ret = data;
|
||||
ret += "Content-Type: application/octet-stream; charset=utf-8\r\n";
|
||||
|
@ -1663,8 +1663,12 @@ bool Manager::HTTPUpload(const std::string& localFileName, const std::string& ht
|
|||
assert(-1 != sockClient);
|
||||
#endif
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
u_long ul = 1; // 设为非阻塞
|
||||
ioctlsocket(sockClient, FIONBIO, &ul);
|
||||
#else
|
||||
ioctl(sockClient, FIONBIO, 1);
|
||||
#endif
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
SOCKADDR_IN addrServer = { 0 };
|
||||
|
@ -1674,7 +1678,7 @@ bool Manager::HTTPUpload(const std::string& localFileName, const std::string& ht
|
|||
if (0 != connect(sockClient, (SOCKADDR*)&addrServer, sizeof(SOCKADDR_IN)))
|
||||
#else
|
||||
struct sockaddr_in addrServer = { 0 };
|
||||
addrServer.sin_addr.S_un.S_addr = inet_addr(addr.c_str());
|
||||
addrServer.sin_addr.s_addr = inet_addr(addr.c_str());
|
||||
addrServer.sin_family = AF_INET;
|
||||
addrServer.sin_port = htons(port);
|
||||
if (0 != connect(sockClient, (struct sockaddr*)&addrServer, sizeof(addrServer)))
|
||||
|
@ -1710,8 +1714,12 @@ bool Manager::HTTPUpload(const std::string& localFileName, const std::string& ht
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
ul = 0; // 设为阻塞
|
||||
ioctlsocket(sockClient, FIONBIO, &ul);
|
||||
#else
|
||||
ioctl(sockClient, FIONBIO, 0);
|
||||
#endif
|
||||
|
||||
char remoteName[256];
|
||||
HGBase_GetFileName(localFileName.c_str(), remoteName, 256);
|
||||
|
@ -1780,7 +1788,7 @@ static size_t read_callback(char* ptr, size_t size, size_t nmemb, void* stream)
|
|||
return retcode;
|
||||
}
|
||||
|
||||
bool Manager::FTPUpload(const std::string& localFileName, const std::string& ftpUrl, int ftpPort, const std::string& ftpPath,
|
||||
bool Manager::FTPUpload(const std::string& localFileName, const std::string& ftpUrl, int ftpPort, const std::string& ftpPath,
|
||||
const std::string& ftpUser, const std::string& ftpPassword, int ftpMode)
|
||||
{
|
||||
FILE* file = fopen(localFileName.c_str(), "rb");
|
||||
|
@ -1805,9 +1813,9 @@ bool Manager::FTPUpload(const std::string& localFileName, const std::string& ftp
|
|||
char remoteName[256];
|
||||
HGBase_GetFileName(localFileName.c_str(), remoteName, 256);
|
||||
|
||||
char ftp_rnfr[256];
|
||||
char ftp_rnfr[512];
|
||||
sprintf(ftp_rnfr, "RNFR %s", tmpName);
|
||||
char ftp_rnto[256];
|
||||
char ftp_rnto[512];
|
||||
sprintf(ftp_rnto, "RNTO %s", remoteName);
|
||||
|
||||
struct curl_slist* headerlist = NULL;
|
||||
|
|
Binary file not shown.
|
@ -17,7 +17,7 @@ old_library='libcurl.a'
|
|||
inherited_linker_flags=' -pthread'
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lidn2 -lzstd -lz'
|
||||
dependency_libs=' -lz'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
@ -38,4 +38,4 @@ dlopen=''
|
|||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/data/home/luoliangyi/hgproject/third_party/libcurl/uos/amd64/curl-7.82.0/release/lib'
|
||||
libdir='/data/home/luoliangyi/code_app/third_party/libcurl/uos/amd64/curl-7.82.0/release/lib'
|
||||
|
|
|
@ -23,17 +23,17 @@
|
|||
# This should most probably benefit from getting a "Requires:" field added
|
||||
# dynamically by configure.
|
||||
#
|
||||
prefix=/data/home/luoliangyi/hgproject/third_party/libcurl/uos/amd64/curl-7.82.0/release
|
||||
prefix=/data/home/luoliangyi/code_app/third_party/libcurl/uos/amd64/curl-7.82.0/release
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
supported_protocols="DICT FILE FTP GOPHER HTTP IMAP MQTT POP3 RTSP SMTP TELNET TFTP"
|
||||
supported_features="AsynchDNS IDN IPv6 Largefile UnixSockets alt-svc libz zstd"
|
||||
supported_features="AsynchDNS IPv6 Largefile UnixSockets alt-svc libz"
|
||||
|
||||
Name: libcurl
|
||||
URL: https://curl.se/
|
||||
Description: Library to transfer files with ftp, http, etc.
|
||||
Version: 7.82.0
|
||||
Libs: -L${libdir} -lcurl -lidn2 -lzstd -lz -pthread
|
||||
Libs.private: -lidn2 -lzstd -lz -pthread
|
||||
Libs: -L${libdir} -lcurl -lz -pthread
|
||||
Libs.private: -lz -pthread
|
||||
Cflags: -I${includedir} -DCURL_STATICLIB
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
#include "./ocrcommon.h"
|
||||
|
||||
//使用动态库的时候需要将 hwusbdev.key 放到应用程序相同路径
|
||||
//文件类型
|
||||
#define FILE_PDF 0 //输出精确版面复原的简体PDF文件
|
||||
#define FILE_RTF 2 //输出精确版面复原的简体RTF文件
|
||||
#define FILE_XLS 5 //输出简体XLS文件
|
||||
#define FILE_TXT 100 //输出为文本格式
|
||||
#define FILE_PDF_TXT 101 //输出文本加pdf
|
||||
#define FILE_JSON 200 //输出为json格式
|
||||
#define FILE_OFD 300 //输出双层ofd格式
|
||||
|
||||
#define STATUS_OK 0
|
||||
#define STATUS_NO_MEMORY -1
|
||||
#define STATUS_INVALID_PARAMETER -2
|
||||
#define STATUS_FAILED -3
|
||||
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
/**************************************
|
||||
功能: 初始化
|
||||
参数: ppstOcrHandle [I/O] 初始化识别句柄
|
||||
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_SDKInitialize(void **ppstOcrHandle);
|
||||
|
||||
/**************************************
|
||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出txt/json/rtf/xls/pdf格式
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成tmp.jpg图像。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
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格式
|
||||
参数: ppImageFiles [I] 输入图像路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成jpg图像。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
|
||||
int HWOCR_RecognizeFileBatch(char ** ppImageFiles, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir = NULL);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能:识别内存图像的指定块,输出txt/json/rtf格式
|
||||
参数: pbImage [I] 图像数据
|
||||
nWidth [I] 图像宽度
|
||||
nHeight [I] 图像高度
|
||||
aLayoutInfo [I] 块属性
|
||||
nColorType [I] 颜色属性
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeImgBlock(unsigned char*pbImage, int nWidth, int nHeight, TOCRLayoutBlockInfo aLayoutInfo,
|
||||
TColorType nColorType, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出识别结果字符串
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
ppRst [O] 识别结果字符串
|
||||
pnLen [O] 字符串长度
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeFile2Str(BYTE*ImgFile, void *pstHandle,char **ppRst,int* pnLen);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能: 释放识别结果
|
||||
参数: ppRst [I] 识别结果字符串
|
||||
|
||||
返回值: 无
|
||||
****************************************/
|
||||
void HWOCR_FreeStrRst(char **ppRst);
|
||||
|
||||
/**************************************
|
||||
功能: 判断识别方向
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pDirect [O] 图像方向
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
返回值: 正常为0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_GetFileDirect(BYTE*ImgFile, void *pstHandle, int *pDirect);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能: 判断识别方向,支持24bit 8bit 1bit内存图像。
|
||||
参数: pbImage [I] 输入内存图像
|
||||
nWidth [I] 图像宽度
|
||||
nHeight [I] 图像高度
|
||||
nColorType [I] 颜色属性
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pDirect [O] 图像方向
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
返回值: 正常为0,否则<0
|
||||
****************************************/
|
||||
|
||||
int HWOCR_GetFileDirectImage(BYTE*pbImage, int nWidth, int nHeight, TColorType nColorType, void *pstHandle, int *pDirect);
|
||||
|
||||
/**************************************
|
||||
功能:识别ofd图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||
参数: OfdFile [I] 输入文件路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] 传NULL
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeOFD(BYTE*OfdFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||
|
||||
/**************************************
|
||||
功能:识别pdf图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||
参数: PdfFile [I] 输入文件路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] 传NULL
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizePDF(BYTE*PdfFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||
|
||||
/*********************************
|
||||
功能:调用识别pdf函数前,调用此初始化函数
|
||||
**********************************/
|
||||
void HWOCR_InitPdf();
|
||||
|
||||
/*********************************
|
||||
功能:调用识别pdf函数后,调用此退出函数
|
||||
**********************************/
|
||||
void HWOCR_ExitPdf();
|
||||
/**************************************
|
||||
功能: 释放识别句柄
|
||||
参数: pstOcrHandle [I] 初始化时的句柄
|
||||
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
void HWOCR_SDKExit(void *pstOcrHandle);
|
|
@ -0,0 +1,146 @@
|
|||
/*--------------------------------------------------------------------------
|
||||
Embedded OCR Engine for embedded platform v1.0
|
||||
Copyright (c) 2006£¬HanWang Technology Co., Ltd. All Rights Reserved.
|
||||
|
||||
File: ocrcommon.h
|
||||
|
||||
Description:
|
||||
common file for embedded OCR module.
|
||||
|
||||
Author: Hanwang Embedded OCR Group
|
||||
History:
|
||||
Nov.7, 2006 Created
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef OCRCOMMON_H
|
||||
#define OCRCOMMON_H
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Typedef's */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
typedef unsigned char BYTE;
|
||||
typedef int BOOL;
|
||||
typedef unsigned short WORD;
|
||||
|
||||
//Data type define
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
typedef void (*RecogProgress)( int nPercent);
|
||||
typedef int (*IsCanceled)();
|
||||
|
||||
typedef void* (*BCRHeapAlloc)( unsigned int lSize );
|
||||
typedef void (*BCRHeapFree)( void *memblock );
|
||||
|
||||
#define MAX_PATH 260
|
||||
|
||||
|
||||
typedef struct _OCRRect //rectangle
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
} TOCRRECT;
|
||||
|
||||
|
||||
enum TLayoutType //layout text type
|
||||
{
|
||||
ETypeHorizontal, // TYPE_HORIZONTAL,
|
||||
ETypeVertical // TYPE_VERTICAL
|
||||
};
|
||||
|
||||
enum TTextType
|
||||
{
|
||||
ETextMultiLine, //multi-text line
|
||||
ETextSingleLine //sigle text line
|
||||
};
|
||||
enum TImageBackground //brightness for text background
|
||||
{
|
||||
EBackgroundLight, // dark character with light background
|
||||
EBackgroundDark, //light character with dark background
|
||||
EBackgroundUnknown // unknown
|
||||
};
|
||||
|
||||
|
||||
enum TColorType //color type
|
||||
{
|
||||
EGray2 = 0, //black and white image, 1 bit per pixel
|
||||
EGray256, // gray image, 8 bit per pixel
|
||||
EColor16M, // color image, 24 bit per pixel
|
||||
};
|
||||
|
||||
struct TOCRTextLineInfo // data structure of text line
|
||||
{
|
||||
char *iText; // during layout analyze, this is null
|
||||
short *psDistance;
|
||||
TOCRRECT iRect; //
|
||||
|
||||
TOCRRECT *iCharRect; // This is an array which returns the regions of every single character in this line
|
||||
int iCharCount; // How many characters in this line
|
||||
};
|
||||
|
||||
struct TOCRBlockInfo // data structure of layout infomation
|
||||
{
|
||||
|
||||
TOCRRECT iRect; // block coordinates
|
||||
TLayoutType iType; //vertical or horizontal
|
||||
int iBlockId; // block's ID
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TOCRTextRgnInfo // data structure of recognition result
|
||||
{
|
||||
TOCRRECT iRect; // block coordinates
|
||||
TLayoutType iType; //vertical or horizontal
|
||||
int iBlockId; // block's ID
|
||||
|
||||
TOCRTextLineInfo *iLines;
|
||||
int iLineCount; // Lines' count in each block
|
||||
};
|
||||
|
||||
|
||||
struct TOCRLayoutSetting // data structure of layout settings
|
||||
{
|
||||
enum TBrightness // brightness
|
||||
{
|
||||
ENormal, // Normal
|
||||
ELight, // Light
|
||||
EDark // Dark
|
||||
};
|
||||
|
||||
int iSkew; // switch of skew adjustment 1: do skew adjustment; 0: dont do it
|
||||
TBrightness iBrightness; // switch of brightness adjustment
|
||||
};
|
||||
|
||||
struct TOCRRecognizeSetting // data structure of Recognition settings
|
||||
{
|
||||
int iRotate;
|
||||
void* iCandidate; // for later usage
|
||||
};
|
||||
|
||||
|
||||
struct TOCRLayoutBlockInfo // COCRLayoutBlockInfo
|
||||
{
|
||||
TOCRRECT iRect; //block coordinates
|
||||
TLayoutType iLayout; //vertical or horzontal text
|
||||
TTextType iText; //mulitline or single line
|
||||
TImageBackground iBackgroundColor;//brightness for text background
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct TRegionInfo
|
||||
{
|
||||
TOCRRECT iRect;
|
||||
TImageBackground iBackgroundColor;
|
||||
|
||||
enum TRegionType
|
||||
{
|
||||
EEmailAddress,
|
||||
ETelephoneNumber,
|
||||
EWWWAddress
|
||||
};
|
||||
|
||||
TRegionType iType;
|
||||
};
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,177 @@
|
|||
#include "./ocrcommon.h"
|
||||
|
||||
//使用动态库的时候需要将 hwusbdev.key 放到应用程序相同路径
|
||||
//文件类型
|
||||
#define FILE_PDF 0 //输出精确版面复原的简体PDF文件
|
||||
#define FILE_RTF 2 //输出精确版面复原的简体RTF文件
|
||||
#define FILE_XLS 5 //输出简体XLS文件
|
||||
#define FILE_TXT 100 //输出为文本格式
|
||||
#define FILE_PDF_TXT 101 //输出文本加pdf
|
||||
#define FILE_JSON 200 //输出为json格式
|
||||
#define FILE_OFD 300 //输出双层ofd格式
|
||||
|
||||
#define STATUS_OK 0
|
||||
#define STATUS_NO_MEMORY -1
|
||||
#define STATUS_INVALID_PARAMETER -2
|
||||
#define STATUS_FAILED -3
|
||||
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
/**************************************
|
||||
功能: 初始化
|
||||
参数: ppstOcrHandle [I/O] 初始化识别句柄
|
||||
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_SDKInitialize(void **ppstOcrHandle);
|
||||
|
||||
/**************************************
|
||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出txt/json/rtf/xls/pdf格式
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成tmp.jpg图像。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
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格式
|
||||
参数: ppImageFiles [I] 输入图像路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成jpg图像。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
|
||||
int HWOCR_RecognizeFileBatch(char ** ppImageFiles, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir = NULL);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能:识别内存图像的指定块,输出txt/json/rtf格式
|
||||
参数: pbImage [I] 图像数据
|
||||
nWidth [I] 图像宽度
|
||||
nHeight [I] 图像高度
|
||||
aLayoutInfo [I] 块属性
|
||||
nColorType [I] 颜色属性
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeImgBlock(unsigned char*pbImage, int nWidth, int nHeight, TOCRLayoutBlockInfo aLayoutInfo,
|
||||
TColorType nColorType, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出识别结果字符串
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
ppRst [O] 识别结果字符串
|
||||
pnLen [O] 字符串长度
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeFile2Str(BYTE*ImgFile, void *pstHandle,char **ppRst,int* pnLen);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能: 释放识别结果
|
||||
参数: ppRst [I] 识别结果字符串
|
||||
|
||||
返回值: 无
|
||||
****************************************/
|
||||
void HWOCR_FreeStrRst(char **ppRst);
|
||||
|
||||
/**************************************
|
||||
功能: 判断识别方向
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pDirect [O] 图像方向
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
返回值: 正常为0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_GetFileDirect(BYTE*ImgFile, void *pstHandle, int *pDirect);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能: 判断识别方向,支持24bit 8bit 1bit内存图像。
|
||||
参数: pbImage [I] 输入内存图像
|
||||
nWidth [I] 图像宽度
|
||||
nHeight [I] 图像高度
|
||||
nColorType [I] 颜色属性
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pDirect [O] 图像方向
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
返回值: 正常为0,否则<0
|
||||
****************************************/
|
||||
|
||||
int HWOCR_GetFileDirectImage(BYTE*pbImage, int nWidth, int nHeight, TColorType nColorType, void *pstHandle, int *pDirect);
|
||||
|
||||
/**************************************
|
||||
功能:识别ofd图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||
参数: OfdFile [I] 输入文件路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] 传NULL
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeOFD(BYTE*OfdFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||
|
||||
/**************************************
|
||||
功能:识别pdf图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||
参数: PdfFile [I] 输入文件路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] 传NULL
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizePDF(BYTE*PdfFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||
|
||||
/*********************************
|
||||
功能:调用识别pdf函数前,调用此初始化函数
|
||||
**********************************/
|
||||
void HWOCR_InitPdf();
|
||||
|
||||
/*********************************
|
||||
功能:调用识别pdf函数后,调用此退出函数
|
||||
**********************************/
|
||||
void HWOCR_ExitPdf();
|
||||
/**************************************
|
||||
功能: 释放识别句柄
|
||||
参数: pstOcrHandle [I] 初始化时的句柄
|
||||
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
void HWOCR_SDKExit(void *pstOcrHandle);
|
|
@ -0,0 +1,146 @@
|
|||
/*--------------------------------------------------------------------------
|
||||
Embedded OCR Engine for embedded platform v1.0
|
||||
Copyright (c) 2006£¬HanWang Technology Co., Ltd. All Rights Reserved.
|
||||
|
||||
File: ocrcommon.h
|
||||
|
||||
Description:
|
||||
common file for embedded OCR module.
|
||||
|
||||
Author: Hanwang Embedded OCR Group
|
||||
History:
|
||||
Nov.7, 2006 Created
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef OCRCOMMON_H
|
||||
#define OCRCOMMON_H
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Typedef's */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
typedef unsigned char BYTE;
|
||||
typedef int BOOL;
|
||||
typedef unsigned short WORD;
|
||||
|
||||
//Data type define
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
typedef void (*RecogProgress)( int nPercent);
|
||||
typedef int (*IsCanceled)();
|
||||
|
||||
typedef void* (*BCRHeapAlloc)( unsigned int lSize );
|
||||
typedef void (*BCRHeapFree)( void *memblock );
|
||||
|
||||
#define MAX_PATH 260
|
||||
|
||||
|
||||
typedef struct _OCRRect //rectangle
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
} TOCRRECT;
|
||||
|
||||
|
||||
enum TLayoutType //layout text type
|
||||
{
|
||||
ETypeHorizontal, // TYPE_HORIZONTAL,
|
||||
ETypeVertical // TYPE_VERTICAL
|
||||
};
|
||||
|
||||
enum TTextType
|
||||
{
|
||||
ETextMultiLine, //multi-text line
|
||||
ETextSingleLine //sigle text line
|
||||
};
|
||||
enum TImageBackground //brightness for text background
|
||||
{
|
||||
EBackgroundLight, // dark character with light background
|
||||
EBackgroundDark, //light character with dark background
|
||||
EBackgroundUnknown // unknown
|
||||
};
|
||||
|
||||
|
||||
enum TColorType //color type
|
||||
{
|
||||
EGray2 = 0, //black and white image, 1 bit per pixel
|
||||
EGray256, // gray image, 8 bit per pixel
|
||||
EColor16M, // color image, 24 bit per pixel
|
||||
};
|
||||
|
||||
struct TOCRTextLineInfo // data structure of text line
|
||||
{
|
||||
char *iText; // during layout analyze, this is null
|
||||
short *psDistance;
|
||||
TOCRRECT iRect; //
|
||||
|
||||
TOCRRECT *iCharRect; // This is an array which returns the regions of every single character in this line
|
||||
int iCharCount; // How many characters in this line
|
||||
};
|
||||
|
||||
struct TOCRBlockInfo // data structure of layout infomation
|
||||
{
|
||||
|
||||
TOCRRECT iRect; // block coordinates
|
||||
TLayoutType iType; //vertical or horizontal
|
||||
int iBlockId; // block's ID
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TOCRTextRgnInfo // data structure of recognition result
|
||||
{
|
||||
TOCRRECT iRect; // block coordinates
|
||||
TLayoutType iType; //vertical or horizontal
|
||||
int iBlockId; // block's ID
|
||||
|
||||
TOCRTextLineInfo *iLines;
|
||||
int iLineCount; // Lines' count in each block
|
||||
};
|
||||
|
||||
|
||||
struct TOCRLayoutSetting // data structure of layout settings
|
||||
{
|
||||
enum TBrightness // brightness
|
||||
{
|
||||
ENormal, // Normal
|
||||
ELight, // Light
|
||||
EDark // Dark
|
||||
};
|
||||
|
||||
int iSkew; // switch of skew adjustment 1: do skew adjustment; 0: dont do it
|
||||
TBrightness iBrightness; // switch of brightness adjustment
|
||||
};
|
||||
|
||||
struct TOCRRecognizeSetting // data structure of Recognition settings
|
||||
{
|
||||
int iRotate;
|
||||
void* iCandidate; // for later usage
|
||||
};
|
||||
|
||||
|
||||
struct TOCRLayoutBlockInfo // COCRLayoutBlockInfo
|
||||
{
|
||||
TOCRRECT iRect; //block coordinates
|
||||
TLayoutType iLayout; //vertical or horzontal text
|
||||
TTextType iText; //mulitline or single line
|
||||
TImageBackground iBackgroundColor;//brightness for text background
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct TRegionInfo
|
||||
{
|
||||
TOCRRECT iRect;
|
||||
TImageBackground iBackgroundColor;
|
||||
|
||||
enum TRegionType
|
||||
{
|
||||
EEmailAddress,
|
||||
ETelephoneNumber,
|
||||
EWWWAddress
|
||||
};
|
||||
|
||||
TRegionType iType;
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,177 @@
|
|||
#include "./ocrcommon.h"
|
||||
|
||||
//使用动态库的时候需要将 hwusbdev.key 放到应用程序相同路径
|
||||
//文件类型
|
||||
#define FILE_PDF 0 //输出精确版面复原的简体PDF文件
|
||||
#define FILE_RTF 2 //输出精确版面复原的简体RTF文件
|
||||
#define FILE_XLS 5 //输出简体XLS文件
|
||||
#define FILE_TXT 100 //输出为文本格式
|
||||
#define FILE_PDF_TXT 101 //输出文本加pdf
|
||||
#define FILE_JSON 200 //输出为json格式
|
||||
#define FILE_OFD 300 //输出双层ofd格式
|
||||
|
||||
#define STATUS_OK 0
|
||||
#define STATUS_NO_MEMORY -1
|
||||
#define STATUS_INVALID_PARAMETER -2
|
||||
#define STATUS_FAILED -3
|
||||
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
/**************************************
|
||||
功能: 初始化
|
||||
参数: ppstOcrHandle [I/O] 初始化识别句柄
|
||||
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_SDKInitialize(void **ppstOcrHandle);
|
||||
|
||||
/**************************************
|
||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出txt/json/rtf/xls/pdf格式
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成tmp.jpg图像。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
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格式
|
||||
参数: ppImageFiles [I] 输入图像路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。没有传此参数或者传NULL时,必要时会在pLibDir下生成jpg图像。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
|
||||
int HWOCR_RecognizeFileBatch(char ** ppImageFiles, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir = NULL);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能:识别内存图像的指定块,输出txt/json/rtf格式
|
||||
参数: pbImage [I] 图像数据
|
||||
nWidth [I] 图像宽度
|
||||
nHeight [I] 图像高度
|
||||
aLayoutInfo [I] 块属性
|
||||
nColorType [I] 颜色属性
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] db文件所在目录
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeImgBlock(unsigned char*pbImage, int nWidth, int nHeight, TOCRLayoutBlockInfo aLayoutInfo,
|
||||
TColorType nColorType, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能:识别jpg/bmp/tiff/png/gif图像文件,输出识别结果字符串
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
ppRst [O] 识别结果字符串
|
||||
pnLen [O] 字符串长度
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeFile2Str(BYTE*ImgFile, void *pstHandle,char **ppRst,int* pnLen);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能: 释放识别结果
|
||||
参数: ppRst [I] 识别结果字符串
|
||||
|
||||
返回值: 无
|
||||
****************************************/
|
||||
void HWOCR_FreeStrRst(char **ppRst);
|
||||
|
||||
/**************************************
|
||||
功能: 判断识别方向
|
||||
参数: ImgFile [I] 输入图像路径及文件名
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pDirect [O] 图像方向
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
返回值: 正常为0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_GetFileDirect(BYTE*ImgFile, void *pstHandle, int *pDirect);
|
||||
|
||||
|
||||
/**************************************
|
||||
功能: 判断识别方向,支持24bit 8bit 1bit内存图像。
|
||||
参数: pbImage [I] 输入内存图像
|
||||
nWidth [I] 图像宽度
|
||||
nHeight [I] 图像高度
|
||||
nColorType [I] 颜色属性
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pDirect [O] 图像方向
|
||||
//顺时针角度
|
||||
enum ROTATETYPEOUT
|
||||
{
|
||||
ROT0, //未旋转
|
||||
ROT90, //顺时针旋转90度
|
||||
ROT180, //顺时针旋转180度
|
||||
ROT270, //顺时针旋转270度
|
||||
};
|
||||
|
||||
返回值: 正常为0,否则<0
|
||||
****************************************/
|
||||
|
||||
int HWOCR_GetFileDirectImage(BYTE*pbImage, int nWidth, int nHeight, TColorType nColorType, void *pstHandle, int *pDirect);
|
||||
|
||||
/**************************************
|
||||
功能:识别ofd图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||
参数: OfdFile [I] 输入文件路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] 传NULL
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限,有时需要生成tmp.jpg文件。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizeOFD(BYTE*OfdFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||
|
||||
/**************************************
|
||||
功能:识别pdf图像文件,输出txt/json/rtf/xls/pdf/ofd格式
|
||||
参数: PdfFile [I] 输入文件路径及文件名
|
||||
OutFile [I] 输出文件名
|
||||
nFileType [I] 输出文件类型
|
||||
pstHandle [I] 输入句柄,初始化返回的结果
|
||||
pLibDir [I] 传NULL
|
||||
pTmpDir [I] 保存临时文件的目录,需要有写权限。
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
int HWOCR_RecognizePDF(BYTE*PdfFile, BYTE *OutFile, int nFileType, void *pstHandle, char *pLibDir, char *pTmpDir);
|
||||
|
||||
/*********************************
|
||||
功能:调用识别pdf函数前,调用此初始化函数
|
||||
**********************************/
|
||||
void HWOCR_InitPdf();
|
||||
|
||||
/*********************************
|
||||
功能:调用识别pdf函数后,调用此退出函数
|
||||
**********************************/
|
||||
void HWOCR_ExitPdf();
|
||||
/**************************************
|
||||
功能: 释放识别句柄
|
||||
参数: pstOcrHandle [I] 初始化时的句柄
|
||||
|
||||
返回值:正常返回0,否则<0
|
||||
****************************************/
|
||||
void HWOCR_SDKExit(void *pstOcrHandle);
|
|
@ -0,0 +1,146 @@
|
|||
/*--------------------------------------------------------------------------
|
||||
Embedded OCR Engine for embedded platform v1.0
|
||||
Copyright (c) 2006£¬HanWang Technology Co., Ltd. All Rights Reserved.
|
||||
|
||||
File: ocrcommon.h
|
||||
|
||||
Description:
|
||||
common file for embedded OCR module.
|
||||
|
||||
Author: Hanwang Embedded OCR Group
|
||||
History:
|
||||
Nov.7, 2006 Created
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
#ifndef OCRCOMMON_H
|
||||
#define OCRCOMMON_H
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Typedef's */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
typedef unsigned char BYTE;
|
||||
typedef int BOOL;
|
||||
typedef unsigned short WORD;
|
||||
|
||||
//Data type define
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
typedef void (*RecogProgress)( int nPercent);
|
||||
typedef int (*IsCanceled)();
|
||||
|
||||
typedef void* (*BCRHeapAlloc)( unsigned int lSize );
|
||||
typedef void (*BCRHeapFree)( void *memblock );
|
||||
|
||||
#define MAX_PATH 260
|
||||
|
||||
|
||||
typedef struct _OCRRect //rectangle
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
} TOCRRECT;
|
||||
|
||||
|
||||
enum TLayoutType //layout text type
|
||||
{
|
||||
ETypeHorizontal, // TYPE_HORIZONTAL,
|
||||
ETypeVertical // TYPE_VERTICAL
|
||||
};
|
||||
|
||||
enum TTextType
|
||||
{
|
||||
ETextMultiLine, //multi-text line
|
||||
ETextSingleLine //sigle text line
|
||||
};
|
||||
enum TImageBackground //brightness for text background
|
||||
{
|
||||
EBackgroundLight, // dark character with light background
|
||||
EBackgroundDark, //light character with dark background
|
||||
EBackgroundUnknown // unknown
|
||||
};
|
||||
|
||||
|
||||
enum TColorType //color type
|
||||
{
|
||||
EGray2 = 0, //black and white image, 1 bit per pixel
|
||||
EGray256, // gray image, 8 bit per pixel
|
||||
EColor16M, // color image, 24 bit per pixel
|
||||
};
|
||||
|
||||
struct TOCRTextLineInfo // data structure of text line
|
||||
{
|
||||
char *iText; // during layout analyze, this is null
|
||||
short *psDistance;
|
||||
TOCRRECT iRect; //
|
||||
|
||||
TOCRRECT *iCharRect; // This is an array which returns the regions of every single character in this line
|
||||
int iCharCount; // How many characters in this line
|
||||
};
|
||||
|
||||
struct TOCRBlockInfo // data structure of layout infomation
|
||||
{
|
||||
|
||||
TOCRRECT iRect; // block coordinates
|
||||
TLayoutType iType; //vertical or horizontal
|
||||
int iBlockId; // block's ID
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TOCRTextRgnInfo // data structure of recognition result
|
||||
{
|
||||
TOCRRECT iRect; // block coordinates
|
||||
TLayoutType iType; //vertical or horizontal
|
||||
int iBlockId; // block's ID
|
||||
|
||||
TOCRTextLineInfo *iLines;
|
||||
int iLineCount; // Lines' count in each block
|
||||
};
|
||||
|
||||
|
||||
struct TOCRLayoutSetting // data structure of layout settings
|
||||
{
|
||||
enum TBrightness // brightness
|
||||
{
|
||||
ENormal, // Normal
|
||||
ELight, // Light
|
||||
EDark // Dark
|
||||
};
|
||||
|
||||
int iSkew; // switch of skew adjustment 1: do skew adjustment; 0: dont do it
|
||||
TBrightness iBrightness; // switch of brightness adjustment
|
||||
};
|
||||
|
||||
struct TOCRRecognizeSetting // data structure of Recognition settings
|
||||
{
|
||||
int iRotate;
|
||||
void* iCandidate; // for later usage
|
||||
};
|
||||
|
||||
|
||||
struct TOCRLayoutBlockInfo // COCRLayoutBlockInfo
|
||||
{
|
||||
TOCRRECT iRect; //block coordinates
|
||||
TLayoutType iLayout; //vertical or horzontal text
|
||||
TTextType iText; //mulitline or single line
|
||||
TImageBackground iBackgroundColor;//brightness for text background
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct TRegionInfo
|
||||
{
|
||||
TOCRRECT iRect;
|
||||
TImageBackground iBackgroundColor;
|
||||
|
||||
enum TRegionType
|
||||
{
|
||||
EEmailAddress,
|
||||
ETelephoneNumber,
|
||||
EWWWAddress
|
||||
};
|
||||
|
||||
TRegionType iType;
|
||||
};
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue