赞
踩
属性 --> VC++ 目录 --> 包含目录
E:\opencv455\build\include
E:\cpp_code\PaddleOCR\paddle_inference\paddle\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\cryptopp\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\protobuf\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\glog\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\gflags\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\xxhash\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\onnxruntime\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\paddle2onnx\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\mklml\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\mkldnn\include
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\utf8proc\include
E:\cpp_code\PaddleOCR\ocr_cpu
属性 --> VC++ 目录 --> 库目录
E:\opencv455\build\x64\vc15\lib
E:\cpp_code\PaddleOCR\paddle_inference\paddle\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\cryptopp\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\protobuf\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\glog\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\gflags\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\xxhash\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\onnxruntime\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\paddle2onnx\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\mklml\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\mkldnn\lib
E:\cpp_code\PaddleOCR\paddle_inference\third_party\install\utf8proc\lib
属性 --> 链接器 --> 输入 --> 附加依赖项
opencv_world455.lib
paddle_inference.lib
libpaddle_inference.lib
cryptopp-static.lib
gflags_static.lib
shlwapi.lib
glog.lib
mkldnn.lib
mklml.lib
libiomp5md.lib
onnxruntime.lib
paddle2onnx.lib
libprotobuf.lib
utf8proc_static.lib
xxhash.lib
将 opencv_world455.dll,paddle_inference.dll,paddle2onnx.dll 和 onnxruntime.dll复制到项目的x64\Release目录下
修改 main.cpp文件
int main() { SetConsoleOutputCP(CP_UTF8); FLAGS_det_model_dir = "E:\\cpp_code\\weights\\PP-OCRv4\\ch_PP-OCRv4_det_infer"; FLAGS_rec_model_dir = "E:\\cpp_code\\weights\\PP-OCRv4\\ch_PP-OCRv4_rec_infer"; FLAGS_cls_model_dir = "E:\\cpp_code\\weights\\PP-OCRv4\\ch_ppocr_mobile_v2.0_cls_infer"; FLAGS_rec_char_dict_path = "E:\\cpp_code\\paddle_compile\\PaddleOCR\\ppocr\\utils\\ppocr_keys_v1.txt"; FLAGS_image_dir = "E:\\cpp_code\\images\\img_20230926_105631025.jpg"; FLAGS_cpu_threads = 64; FLAGS_type = "ocr"; // "structure" FLAGS_output = ".\\output"; std::vector<cv::String> cv_all_img_names; cv::glob(FLAGS_image_dir, cv_all_img_names); std::cout << "total images num: " << cv_all_img_names.size() << std::endl; if (FLAGS_type == "ocr") { ocr(cv_all_img_names); } else if (FLAGS_type == "structure") { structure(cv_all_img_names); } else { std::cout << "only value in ['ocr','structure'] is supported" << std::endl; } }
遇到的问题和解决方法:
1>gflags_static.lib(gflags.cc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu.obj 中)
1>gflags_static.lib(gflags_reporting.cc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu.obj 中)
1>gflags_static.lib(gflags_completions.cc.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu.obj 中)
1>libcpmt.lib(locale0.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu.obj 中)
1>libcpmt.lib(cerr.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu.obj 中)
1>libcpmt.lib(locale.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu.obj 中)
1>libcpmt.lib(iosptrs.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MT_StaticRelease”不匹配值“MD_DynamicRelease”(ocr_cpu.obj 中)
解决方法: 属性 -> C/C++ -> 代码生成 -> 运行库
1>paddleocr.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl google::LogMessage::stream(void)" (__imp_?stream@LogMessage@google@@QEAAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ)
1>paddleocr.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl google::LogMessage::~LogMessage(void)" (__imp_??1LogMessage@google@@QEAA@XZ)
1>paddleocr.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl google::LogMessage::LogMessage(char const *,int)" (__imp_??0LogMessage@google@@QEAA@PEBDH@Z)
1>paddleocr.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::basic_ostream<char,struct std::char_traits<char> >::operator<<(bool)" (__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z)
解决方法: 属性 ->C/C++ ->预处理器 ->预处理器定义:GOOGLE_GLOG_DLL_DECL=
3. gflags_static.lib(gflags.cc.obj) : error LNK2001: 无法解析的外部符号 __imp_PathMatchSpecA
解决方法:项目属性 -》链接器-》输入-》附加依赖项-》加上shlwapi.lib
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。