From 9c6c15e7a2cc8d24ec5e637dd52bfb3e4caef4e7 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 27 Jul 2021 00:26:55 +0800 Subject: [PATCH] add TestOCR project --- MeoAssistance.sln | 13 +++ Tools/TestOCR/TestOCR.filters | 22 +++++ Tools/TestOCR/TestOCR.vcxproj | 161 ++++++++++++++++++++++++++++++++++ Tools/TestOCR/main.cpp | 32 +++++++ 4 files changed, 228 insertions(+) create mode 100644 Tools/TestOCR/TestOCR.filters create mode 100644 Tools/TestOCR/TestOCR.vcxproj create mode 100644 Tools/TestOCR/main.cpp diff --git a/MeoAssistance.sln b/MeoAssistance.sln index eb0b1f567e..c83acaba6c 100644 --- a/MeoAssistance.sln +++ b/MeoAssistance.sln @@ -22,6 +22,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Screenshot", "Tools\Screens EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{6C4B8D52-51D1-45F8-AAEC-808035443FD6}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestOCR", "Tools\TestOCR\TestOCR.vcxproj", "{4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -74,6 +76,16 @@ Global {4AC1CFFF-D7B8-4FDA-BCFD-E4754275979B}.Release|x64.Build.0 = Release|x64 {4AC1CFFF-D7B8-4FDA-BCFD-E4754275979B}.Release|x86.ActiveCfg = Release|Win32 {4AC1CFFF-D7B8-4FDA-BCFD-E4754275979B}.Release|x86.Build.0 = Release|Win32 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Debug|x64.ActiveCfg = Debug|x64 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Debug|x64.Build.0 = Debug|x64 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Debug|x86.ActiveCfg = Debug|Win32 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Debug|x86.Build.0 = Debug|Win32 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Release|Any CPU.ActiveCfg = Release|Win32 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Release|x64.ActiveCfg = Release|x64 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Release|x64.Build.0 = Release|x64 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Release|x86.ActiveCfg = Release|Win32 + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -81,6 +93,7 @@ Global GlobalSection(NestedProjects) = preSolution {36BC08F3-71CF-429A-AE69-291BE8962CB2} = {6C4B8D52-51D1-45F8-AAEC-808035443FD6} {4AC1CFFF-D7B8-4FDA-BCFD-E4754275979B} = {6C4B8D52-51D1-45F8-AAEC-808035443FD6} + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED} = {6C4B8D52-51D1-45F8-AAEC-808035443FD6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4F2C0E4B-4FE9-47C6-A878-6BD2FAD8B9B2} diff --git a/Tools/TestOCR/TestOCR.filters b/Tools/TestOCR/TestOCR.filters new file mode 100644 index 0000000000..65fa6d5ae5 --- /dev/null +++ b/Tools/TestOCR/TestOCR.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + \ No newline at end of file diff --git a/Tools/TestOCR/TestOCR.vcxproj b/Tools/TestOCR/TestOCR.vcxproj new file mode 100644 index 0000000000..226decc66c --- /dev/null +++ b/Tools/TestOCR/TestOCR.vcxproj @@ -0,0 +1,161 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + 16.0 + Win32Proj + {4FD37A7B-BBE0-4703-8CBC-7029F4CF98ED} + Tools + 10.0 + TestOCR + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + $(SolutionDir)MeoAssistance\include;$(SolutionDir)3rdPart\include;$(SolutionDir)3rdPart\include\meojson;$(SolutionDir)\3rdPart\include\opencv;$(SolutionDir)\3rdPart\include\opencv2;$(SolutionDir)3drPart\include\OcrLiteNcnn;$(IncludePath) + $(TargetDir);$(LibraryPath) + + + false + $(SolutionDir)MeoAssistance\include;$(SolutionDir)3rdPart\include;$(SolutionDir)3rdPart\include\meojson;$(SolutionDir)\3rdPart\include\opencv;$(SolutionDir)\3rdPart\include\opencv2;$(SolutionDir)3drPart\include\OcrLiteNcnn;$(IncludePath) + $(TargetDir);$(LibraryPath) + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + + + Console + true + MeoAssistance.lib;OcrLiteNcnnd.lib;%(AdditionalDependencies) + $(TargetDir);$(SolutionDir)\3rdPart\lib;%(AdditionalLibraryDirectories) + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + stdc11 + MultiThreaded + + + Console + true + true + true + MeoAssistance.lib;OcrLiteNcnn.lib;%(AdditionalDependencies) + $(TargetDir);$(SolutionDir)\3rdPart\lib;%(AdditionalLibraryDirectories) + + + + + + \ No newline at end of file diff --git a/Tools/TestOCR/main.cpp b/Tools/TestOCR/main.cpp new file mode 100644 index 0000000000..3e38d60075 --- /dev/null +++ b/Tools/TestOCR/main.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +int main(int argc, char** argv) +{ + using namespace ocr; + using namespace asst; + + const std::string filename = "test.png"; + + OcrLite ocr_lite; + ocr_lite.setNumThread(4); + ocr_lite.enableResultTxt(GetCurrentDir().c_str(), filename.c_str()); + ocr_lite.setGpuIndex(0); + + const std::string models_dir = GetResourceDir() + "OcrLiteNcnn\\models\\"; + + bool init_ret = ocr_lite.initModels(models_dir + "dbnet_op", models_dir + "angle_op", models_dir + "crnn_lite_op", models_dir + "keys.txt"); + if (!init_ret) { + std::cerr << "initModels failed" << std::endl; + } + + OcrResult result = ocr_lite.detect(GetCurrentDir().c_str(), filename.c_str(), + 50, 1024, + 0.6f, 0.3f, + 2.0f, true, true); + + std::cout << result.strRes << std::endl; + + return 0; +} \ No newline at end of file