当前位置:网站首页>Win10+vs2017+denseflow compilation
Win10+vs2017+denseflow compilation
2022-07-02 07:35:00 【wxplol】
Because you need to train your own motion recognition model , So we need to make relevant data sets , One of them is to make optical flow data , Try using tradition opencv To do it , Found that the speed is too slow . Finally find denseflow library , So it is recorded here win10 Next installation process .
List of articles
One 、 Installation dependency
1.1、CUDA
- CUDA (driver version > 400)
By default, it has been installed , Engage in in-depth learning and installation pyTorch/Tensorflow It should have been installed . Here mine cuda The environment is :CUDA10.0
C:\Users\Administrator>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:04_Central_Daylight_Time_2018
Cuda compilation tools, release 10.0, V10.0.130
1.2、OpenCV
- OpenCV (with CUDA support)
Installation support is required here CUDA Of OpenCV, Bloggers have been stuck here for a long time ..., Here you need to compile OpenCV Pay attention to the following options :
BUILD_CUDA_STUBS: ChooseOPENCV_DNN_CUDA: Not selectedWITH_CUDA: Choose
meanwhile , It mainly needs opencv_contrib modular , Need and OpenCV With the installation
When selecting a compiler , Best choice vs2017 or vs2015, Others may not compile successfully .
Please refer to the following link for installation :VS2019+opencv4.5+CMake compile opencv_contrib-4.5.0 modular ( A more detailed tutorial )
1.3、Boost
- Boost
normal setup , There are also many related tutorials online , Such as :Windows10 The configuration Boost
Two 、Cmake compile
2.1、 Generate compileable files sln
here , We can refer to github The last tutorial is directly executed :
git clone https://github.com/open-mmlab/denseflow.git
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/app -DUSE_HDF5=no -DUSE_NVFLOW=no ..
It can also be in clone After the source code , Use cmake-gui Compile , Here I choose the first method . therefore , We need to change the relevant CMakeLists.txt The contents of the document , Revised as follows :
- add to OpenCV library
This step is mainly to make Cmake Find out OpenCV The location of , Revised as follows :
set(OpenCV_DIR D:\\cplusplus\\library\\opencv\\opencv-4.5.2\\build)
Please refer to your OpenCV Compilation location .
- add to Boost library
set(Boost_USE_STATIC_LIBS ON)
set(BOOST_ROOT D:\\cplusplus\\library\\boost_1_73_0)
- Delete pthread rely on
target_link_libraries(${DenseFlow_LIB} ${OpenCV_LIBS} Boost::filesystem ${Boost_LIBRARIES})
complete CMakeLists.txt The documents are as follows :
cmake_minimum_required(VERSION 3.12)
project(DenseFlow)
option(USE_HDF5 "Whether to build hdf5 for optical flow image saving" OFF)
option(USE_NVFLOW "Whether to use nvidia hardware optical flow" OFF)
set(OpenCV_DIR D:\\cplusplus\\library\\opencv\\opencv-4.5.2\\build)
set(Boost_USE_STATIC_LIBS ON)
set(BOOST_ROOT D:\\cplusplus\\library\\boost_1_73_0)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
find_package(CUDA REQUIRED)
find_package(OpenCV REQUIRED)
set(DenseFlow_LIB zzdenseflow)
message(STATUS "OpenCV library status:")
message(STATUS " config: ${OpenCV_DIR}")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
find_package(Boost REQUIRED COMPONENTS date_time filesystem iostreams)
message(STATUS "Boost library status:")
message(STATUS " version: ${Boost_VERSION}")
message(STATUS " libraries: ${Boost_LIBRARIES}")
message(STATUS " include path: ${Boost_INCLUDE_DIRS}")
add_library(${DenseFlow_LIB} src/common.cpp src/utils.cpp src/denseflow_gpu.cpp)
include_directories(${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} include ${PROJECT_BINARY_DIR})
link_directories(${OpenCV_LIB_DIRS})
target_link_libraries(${DenseFlow_LIB} ${OpenCV_LIBS} Boost::filesystem ${Boost_LIBRARIES})
if (USE_HDF5)
find_package(HDF5 COMPONENTS HL REQUIRED)
message(STATUS "HDF5 library status:")
message(STATUS " version: ${HDF5_VERSION}")
message(STATUS " libraries: ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}")
message(STATUS " include path: ${HDF5_INCLUDE_DIRS} ${HDF5_HL_INCLUDE_DIR}")
set(HDF5_DEFINITION 1)
include_directories(${HDF5_INCLUDE_DIRS} ${HDF5_HL_INCLUDE_DIR})
target_link_libraries(${DenseFlow_LIB} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES})
else()
set(HDF5_DEFINITION 0)
endif()
if (USE_NVFLOW)
set(NVFLOW_DEFINITION 1)
else()
set(NVFLOW_DEFINITION 0)
endif()
configure_file(
"${PROJECT_SOURCE_DIR}/include/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
add_executable(denseflow tools/denseflow.cpp)
target_link_libraries(denseflow ${DenseFlow_LIB})
install (
TARGETS denseflow ${DenseFlow_LIB}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
After execution, you can find .sln file , Open it to vs Compile the .

2.2、 Compile the generated denseflow.exe
Click on the open vs2017, Compile . The following errors will occur :
- error C2872: “ACCESS_MASK”: Ambiguous symbols
reason :include/common.h in using namespace cv; Caused by space conflict
resolvent : Delete include/common.h Medium using namespace cv; Space naming , meanwhile , Need to be used in OpenCV Add cv:: Namespace
Such as :void convertFlowToImage(const Mat &flow_x, const Mat &flow_y, Mat &img_x, Mat &img_y, double lowerBound,double higherBound);
Change it to void convertFlowToImage(const cv::Mat &flow_x, const cv::Mat &flow_y, cv::Mat &img_x, cv::Mat &img_y, double lowerBound,double higherBound);
Other places are similar . This requires changing all relevant codes , Otherwise, it will report a mistake .
- fatal error C1083: Can't open include file : “sys/syscall.h”: No such file or directory
reason : When this header file linux Upper , If in windwos What I said , Need to be changed to windows.h The header file
resolvent : stay src/denseflow_gpu.cpp Cancellation #include <sys/syscall.h>, Add the following :
//#include <sys/syscall.h>
#if __linux
#include <sys/syscall.h>
#elif defined(_WIN32) || defined(_WIN64)
#include <windows.h> // Or something like it.
#endif
Final , We compiled successfully .

stay build/Release We found our generated denseflow.exe.

边栏推荐
- 第一个快应用(quickapp)demo
- 離線數倉和bi開發的實踐和思考
- 【论文介绍】R-Drop: Regularized Dropout for Neural Networks
- Using MATLAB to realize: power method, inverse power method (origin displacement)
- iOD及Detectron2搭建过程问题记录
- SSM garbage classification management system
- Faster-ILOD、maskrcnn_benchmark训练自己的voc数据集及问题汇总
- 【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
- PointNet理解(PointNet实现第4步)
- Tencent machine test questions
猜你喜欢

Faster-ILOD、maskrcnn_benchmark训练自己的voc数据集及问题汇总

腾讯机试题

Spark SQL task performance optimization (basic)

【论文介绍】R-Drop: Regularized Dropout for Neural Networks
![[introduction to information retrieval] Chapter 3 fault tolerant retrieval](/img/75/ac2fdcd256f5c2336ca53c7a2744b8.png)
[introduction to information retrieval] Chapter 3 fault tolerant retrieval
![[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video](/img/bc/c54f1f12867dc22592cadd5a43df60.png)
[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video

win10+vs2017+denseflow编译

spark sql任务性能优化(基础)

@Transational踩坑

架构设计三原则
随机推荐
The first quickapp demo
allennlp 中的TypeError: Object of type Tensor is not JSON serializable错误
CRP implementation methodology
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
Implement interface Iterable & lt; T&gt;
点云数据理解(PointNet实现第3步)
常见CNN网络创新点
PHP returns the abbreviation of the month according to the numerical month
How to efficiently develop a wechat applet
MMDetection安装问题
@Transitional step pit
【信息检索导论】第三章 容错式检索
Record of problems in the construction process of IOD and detectron2
机器学习理论学习:感知机
view的绘制机制(三)
如何高效开发一款微信小程序
Feeling after reading "agile and tidy way: return to origin"
【Ranking】Pre-trained Language Model based Ranking in Baidu Search
Generate random 6-bit invitation code in PHP
【Torch】解决tensor参数有梯度,weight不更新的若干思路