diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index a76548363c..358920fb3d 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -340,9 +340,23 @@ if(WITH_ONNXRUNTIME) if(WIN32) if(ONNXRT_ROOT_DIR) file(GLOB _ort_runtime_libs "${ONNXRT_ROOT_DIR}/bin/onnxruntime*.dll") + if(NOT _ort_runtime_libs) + file(GLOB _ort_runtime_libs "${ONNXRT_ROOT_DIR}/lib/onnxruntime*.dll") + endif() endif() if(_ort_runtime_libs) install(FILES ${_ort_runtime_libs} DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs) + foreach(_ort_dll ${_ort_runtime_libs}) + if(MSVC_IDE) + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_ort_dll}" "${EXECUTABLE_OUTPUT_PATH}/Release/" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_ort_dll}" "${EXECUTABLE_OUTPUT_PATH}/Debug/") + elseif(MSVC AND (CMAKE_GENERATOR MATCHES "Visual")) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_ort_dll}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/") + else() + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_ort_dll}" "${EXECUTABLE_OUTPUT_PATH}/") + endif() + endforeach() endif() elseif(APPLE) if(ONNXRT_ROOT_DIR) diff --git a/modules/dnn/src/net_impl_backend.cpp b/modules/dnn/src/net_impl_backend.cpp index 0e4bdf1f41..47536c0ebf 100644 --- a/modules/dnn/src/net_impl_backend.cpp +++ b/modules/dnn/src/net_impl_backend.cpp @@ -96,7 +96,12 @@ void Net::Impl::finalizeOrt() ort_profile_data.clear(); if (profilingMode != DNN_PROFILE_NONE) { ort_profile_path_prefix = cv::tempfile("opencv_ort_profile_"); +#ifdef _WIN32 + std::wstring w_profile_path(ort_profile_path_prefix.begin(), ort_profile_path_prefix.end()); + opts.EnableProfiling(w_profile_path.c_str()); +#else opts.EnableProfiling(ort_profile_path_prefix.c_str()); +#endif } #ifdef _WIN32