当前位置:网站首页>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
.
边栏推荐
猜你喜欢
Faster-ILOD、maskrcnn_ Benchmark training coco data set and problem summary
A slide with two tables will help you quickly understand the target detection
MMDetection安装问题
Using compose to realize visible scrollbar
Record of problems in the construction process of IOD and detectron2
一份Slide两张表格带你快速了解目标检测
【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
【深度学习系列(八)】:Transoform原理及实战之原理篇
TimeCLR: A self-supervised contrastive learning framework for univariate time series representation
【信息检索导论】第三章 容错式检索
随机推荐
parser.parse_args 布尔值类型将False解析为True
SSM supermarket order management system
Optimization method: meaning of common mathematical symbols
iOD及Detectron2搭建过程问题记录
Three principles of architecture design
@Transitional step pit
腾讯机试题
[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video
Faster-ILOD、maskrcnn_ Benchmark training coco data set and problem summary
MySQL has no collation factor of order by
类加载器及双亲委派机制
Error in running test pyspark in idea2020
PHP returns the abbreviation of the month according to the numerical month
MySQL无order by的排序规则因素
A slide with two tables will help you quickly understand the target detection
MMDetection安装问题
【信息检索导论】第二章 词项词典与倒排记录表
常见的机器学习相关评价指标
A summary of a middle-aged programmer's study of modern Chinese history
yolov3训练自己的数据集(MMDetection)