Commit 1587a9f5 authored by benjaminwan's avatar benjaminwan
Browse files

修改benchmark

parent 99ac0d4a
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "version.h" #include "version.h"
#include "OcrLite.h" #include "OcrLite.h"
#include "OcrUtils.h" #include "OcrUtils.h"
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#endif #endif
...@@ -164,29 +165,43 @@ int main(int argc, char **argv) { ...@@ -164,29 +165,43 @@ int main(int argc, char **argv) {
//ocrLite.enableResultTxt(imgDir.c_str(), imgName.c_str()); //ocrLite.enableResultTxt(imgDir.c_str(), imgName.c_str());
printf("=====Input Params=====\n"); printf("=====Input Params=====\n");
printf( printf("numThread(%d),padding(%d),maxSideLen(%d),boxScoreThresh(%f),boxThresh(%f),unClipRatio(%f),doAngle(%d),mostAngle(%d)\n",
"numThread(%d),padding(%d),maxSideLen(%d),boxScoreThresh(%f),boxThresh(%f),unClipRatio(%f),doAngle(%d),mostAngle(%d)\n",
numThread, padding, maxSideLen, boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle); numThread, padding, maxSideLen, boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle);
bool initModelsRet = ocrLite.initModels(modelDetPath, modelClsPath, modelRecPath, keysPath);
ocrLite.initModels(modelDetPath, modelClsPath, modelRecPath, keysPath); if (!initModelsRet) return -1;
printf("=====warmup=====\n"); printf("=====Warmup 2 cycles=====\n");
for (int i = 0; i < 2; ++i) {
OcrResult result = ocrLite.detect(imgDir.c_str(), imgName.c_str(), padding, maxSideLen, OcrResult result = ocrLite.detect(imgDir.c_str(), imgName.c_str(), padding, maxSideLen,
boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle); boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle);
printf("dbNetTime(%f) detectTime(%f)\n", result.dbNetTime, result.detectTime); printf("Warmup time(%f)\n", result.detectTime);
double dbTime = 0.0f; }
double detectTime = 0.0f; printf("=====Start Test Loop=====\n");
double allDbTime = 0.0f;
double allClsTime = 0.0f;
double allRecTime = 0.0f;
double allFullTime = 0.0f;
for (int i = 0; i < loopCount; ++i) { for (int i = 0; i < loopCount; ++i) {
printf("=====loop:%d=====\n", i + 1); printf("=====Cycle:%d Take Time(ms)=====\n", i + 1);
OcrResult ocrResult = ocrLite.detect(imgDir.c_str(), imgName.c_str(), OcrResult ocrResult = ocrLite.detect(imgDir.c_str(), imgName.c_str(),
padding, maxSideLen, padding, maxSideLen,
boxScoreThresh, boxThresh, boxScoreThresh, boxThresh,
unClipRatio, doAngle, mostAngle); unClipRatio, doAngle, mostAngle);
printf("dbNetTime(%f) detectTime(%f)\n", ocrResult.dbNetTime, ocrResult.detectTime); double dbTime = ocrResult.dbNetTime;
dbTime += ocrResult.dbNetTime; double clsTime = 0.0f;
detectTime += ocrResult.detectTime; double recTime = 0.0f;
for (const auto &item: ocrResult.textBlocks) {
clsTime += item.angleTime;
recTime += item.crnnTime;
}
double fullTime = ocrResult.detectTime;
printf("det=%f cls=%f rec=%f full=%f\n", dbTime, clsTime, recTime, fullTime);
allDbTime += dbTime;
allClsTime += clsTime;
allRecTime += recTime;
allFullTime += fullTime;
} }
printf("=====result=====\n"); printf("=====Result:Average Time(ms)=====\n");
printf("average dbNetTime=%fms, average detectTime=%fms\n", dbTime / loopCount, printf("det=%f cls=%f rec=%f full=%f\n", allDbTime / loopCount, allClsTime / loopCount,
detectTime / loopCount); allRecTime / loopCount, allFullTime / loopCount);
return 0; return 0;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment