diff --git a/deploy/cpp/CMakeLists.txt b/deploy/cpp/CMakeLists.txt index 1c4a2304a7a2028e8722246df75d9e3e9a9311d7..ceaa448253f18bb8ea55423ed323aeb3cb459fdc 100644 --- a/deploy/cpp/CMakeLists.txt +++ b/deploy/cpp/CMakeLists.txt @@ -114,6 +114,14 @@ include_directories(${OpenCV_INCLUDE_DIRS}) if (WIN32) add_definitions("/DGOOGLE_GLOG_DLL_DECL=") + find_package(OpenMP REQUIRED) + if (OPENMP_FOUND) + message("OPENMP FOUND") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OpenMP_C_FLAGS}") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OpenMP_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OpenMP_CXX_FLAGS}") + endif() set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /bigobj /MTd") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /bigobj /MT") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj /MTd") diff --git a/deploy/cpp/CMakeSettings.json b/deploy/cpp/CMakeSettings.json index bc18d376daba4a2fb2b3982ecc43eca5fbac0c85..535ff1a8b8aac2ddfc70e0f1c2a25a3b910976d4 100644 --- a/deploy/cpp/CMakeSettings.json +++ b/deploy/cpp/CMakeSettings.json @@ -26,11 +26,6 @@ "value": "", "type": "PATH" }, - { - "name": "CMAKE_BUILD_TYPE", - "value": "Release", - "type": "STRING" - }, { "name": "WITH_STATIC_LIB", "value": "True", diff --git a/deploy/cpp/demo/detector.cpp b/deploy/cpp/demo/detector.cpp index 81046552914d21c1cf1d0d408217663708b25f80..07bb7665537a8b7ee9d3bd40694eb6368938321e 100644 --- a/deploy/cpp/demo/detector.cpp +++ b/deploy/cpp/demo/detector.cpp @@ -56,7 +56,6 @@ int main(int argc, char** argv) { std::cerr << "--image or --image_list need to be defined" << std::endl; return -1; } - std::cout << "Thread num: " << FLAGS_thread_num << std::endl; // 加载模型 PaddleX::Model model; model.Init(FLAGS_model_dir, @@ -132,9 +131,16 @@ int main(int argc, char** argv) { } } } else { + auto start = system_clock::now(); PaddleX::DetResult result; cv::Mat im = cv::imread(FLAGS_image, 1); model.predict(im, &result); + auto end = system_clock::now(); + auto duration = duration_cast(end - start); + total_running_time_s += static_cast(duration.count()) * + microseconds::period::num / + microseconds::period::den; + // 输出结果目标框 for (int i = 0; i < result.boxes.size(); ++i) { std::cout << "image file: " << FLAGS_image << std::endl; std::cout << ", predict label: " << result.boxes[i].category diff --git a/docs/tutorials/deploy/deploy_server/deploy_cpp/deploy_cpp_win_vs2019.md b/docs/tutorials/deploy/deploy_server/deploy_cpp/deploy_cpp_win_vs2019.md index 17fc3b162438a000c635f4b0a6e16bebf8445cd4..9c1566fd42f6a2940c56c8b7ae9f4fb65445bdb4 100755 --- a/docs/tutorials/deploy/deploy_server/deploy_cpp/deploy_cpp_win_vs2019.md +++ b/docs/tutorials/deploy/deploy_server/deploy_cpp/deploy_cpp_win_vs2019.md @@ -106,7 +106,7 @@ yaml-cpp.zip文件下载后无需解压,在cmake/yaml.cmake中将`URL https:// 上述`Visual Studio 2019`编译产出的可执行文件在`out\build\x64-Release`目录下,打开`cmd`,并切换到该目录: ``` -d: +D: cd D:\projects\PaddleX\deploy\cpp\out\build\x64-Release ```