当前位置:网站首页>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
.
边栏推荐
- Calculate the total in the tree structure data in PHP
- 【多模态】CLIP模型
- Drawing mechanism of view (3)
- MySQL composite index with or without ID
- Huawei machine test questions-20190417
- 離線數倉和bi開發的實踐和思考
- 【信息检索导论】第二章 词项词典与倒排记录表
- 实现接口 Interface Iterable&lt;T&gt;
- Generate random 6-bit invitation code in PHP
- Implementation of purchase, sales and inventory system with ssm+mysql
猜你喜欢
MySQL无order by的排序规则因素
[introduction to information retrieval] Chapter 7 scoring calculation in search system
Ding Dong, here comes the redis om object mapping framework
【信息检索导论】第三章 容错式检索
Faster-ILOD、maskrcnn_benchmark训练coco数据集及问题汇总
How to efficiently develop a wechat applet
SSM实验室设备管理
A slide with two tables will help you quickly understand the target detection
Faster-ILOD、maskrcnn_ Benchmark trains its own VOC data set and problem summary
《Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer》论文翻译
随机推荐
基于onnxruntime的YOLOv5单张图片检测实现
Faster-ILOD、maskrcnn_ Benchmark trains its own VOC data set and problem summary
Oracle EBS DataGuard setup
【模型蒸馏】TinyBERT: Distilling BERT for Natural Language Understanding
Practice and thinking of offline data warehouse and Bi development
华为机试题-20190417
MoCO ——Momentum Contrast for Unsupervised Visual Representation Learning
Delete the contents under the specified folder in PHP
Transform the tree structure into array in PHP (flatten the tree structure and keep the sorting of upper and lower levels)
parser. parse_ Args boolean type resolves false to true
Mmdetection installation problem
腾讯机试题
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
CONDA creates, replicates, and shares virtual environments
How to efficiently develop a wechat applet
SSM personnel management system
【Torch】最简洁logging使用指南
Faster-ILOD、maskrcnn_benchmark训练coco数据集及问题汇总
使用Matlab实现:Jacobi、Gauss-Seidel迭代
MySQL has no collation factor of order by