mirror of
https://github.com/RapidAI/RapidOCR.git
synced 2026-11-13 06:20:49 +08:00
first edition of api4cpp
This commit is contained in:
1 parent
dfff645592
commit
391794cc1b
3 files changed
+71
-8
No files matched your search
@@ -24,13 +24,62 @@ extern "C"
|
||||
|
||||
}
|
||||
|
||||
_QM_OCR_API const char* BPOcrDoOcr(BPHANDLE handle, const char* szImgPath, BOOL bAutoParam,BPOCR_PARAM *pParam)
|
||||
|
||||
_QM_OCR_API const char* BPOcrDoOcr(BPHANDLE handle, const char* szImgPath, BOOL bAutoParam,BOOL bLongPic,BPOCR_PARAM *pParam)
|
||||
{
|
||||
|
||||
OcrLite * pOcrObj=( OcrLite *)handle;
|
||||
if(!pOcrObj)
|
||||
return NULL;
|
||||
|
||||
BPOCR_PARAM Param = *pParam;
|
||||
if(bAutoParam)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// -numThread %NUMBER_OF_PROCESSORS% ^
|
||||
// --padding 0 ^
|
||||
// --maxSideLen %MAX_SIDE_LEN% ^
|
||||
// --boxScoreThresh 0.5 ^
|
||||
// --boxThresh 0.3 ^
|
||||
// --unClipRatio %CLIP_RATE% ^
|
||||
// --doAngle 1 ^
|
||||
// --mostAngle 0
|
||||
if(Param.boxScoreThresh ==0)
|
||||
Param.boxScoreThresh = 0.5;
|
||||
if(Param.boxThresh ==0)
|
||||
Param.boxThresh =0.3;
|
||||
if(Param.flagDoAngle ==0)
|
||||
Param.flagDoAngle =1;
|
||||
if(Param.flagMostAngle ==0)
|
||||
Param.flagMostAngle =0;
|
||||
|
||||
if( bLongPic)
|
||||
{
|
||||
if(Param.maxSideLen ==0)
|
||||
Param.maxSideLen =0;
|
||||
if(Param.unClipRatio ==0)
|
||||
Param.unClipRatio = 3.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Param.maxSideLen ==0)
|
||||
Param.maxSideLen =1024;
|
||||
if(Param.unClipRatio ==0)
|
||||
Param.unClipRatio = 1.5;
|
||||
}
|
||||
}
|
||||
std::string imgPath,imgDir,imgName;
|
||||
imgPath=szImgPath;
|
||||
imgDir.assign(imgPath.substr(0, imgPath.find_last_of('/') + 1));
|
||||
imgName.assign(imgPath.substr(imgPath.find_last_of('/') + 1));
|
||||
OcrResult result=pOcrObj->detect(imgPath.c_str(),imgName.c_str(),Param.padding,Param.maxSideLen,Param.boxScoreThresh,Param.boxThresh,Param.unClipRatio,Param.flagDoAngle?true:false,Param.flagMostAngle?true:false);
|
||||
if(result.strRes.length()>0)
|
||||
return result.strRes.c_str();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user