前提条件:可以自由S网。
参考文章:
1.拉取源码
git clone https://github.com/opencv/opencv.git
cd opencv && git checkout 4.1.1
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib && git checkout 4.1.1
cd ..
2.Cmake
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DOPENCV_EXTRA_MODULES_PATH=~/opencv/opencv_contrib/modules \
-DBUILD_EXAMPLES=ON \
-DWITH_GSTREAMER=ON \
-DVIDEOIO_PLUGIN_LIST=gstreamer \
-DBUILD_opencv_python2=OFF \
-DBUILD_opencv_python3=OFF \
-DWITH_EIGEN=ON \
-DWITH_OPENGL=ON \
-DCUDA_nppicom_LIBRARY=stdc++ \
-DCUDA_GENERATION=Auto \
-DWITH_CUDA=ON \
-DWITH_CUBLAS=ON \
-DWITH_CUDNN=ON ..
报错解决:CUDA_nppicom_LIBRARY (ADVANCED) 未定义
目前该报错已知为CUDA和OpenCV环境导致,。
解决方法
在编译参数中加入:
-DCUDA_nppicom_LIBRARY=stdc++ \
3.Make
make -j12
sudo make install
sudo ldconfig
报错解决:Unsupported gpu architecture ‘compute_30’
解决方法
在编译选项中加入:
-DCUDA_GENERATION=Auto \
报错解决:对‘TIFFReadRGBAStrip@LIBTIFF_4.0’未定义的引
解决方法
-DBUILD_TIFF=ON \
CMakeLists.txt 模板
OpenCV程序
cmake_minimum_required(VERSION 3.0.2)
project(XXXX)
set(OpenCV_DIR /home/innox/opencv/build)
find_package(OpenCV REQUIRED)
include_directories(
include
${OpenCV_INCLUDE_DIRS}
)
add_executable(image_sub src/image_sub.cpp)
target_link_libraries(image_sub ${OpenCV_LIBS})
ROS-OpenCV程序
cmake_minimum_required(VERSION 3.0.2)
project(XXXX)
set(OpenCV_DIR /home/innox/opencv/build)
find_package(catkin REQUIRED COMPONENTS
roscpp
rosmsg
rospy
message_filters
cv_bridge
OpenCV
image_transport
)
find_package(Boost REQUIRED)
find_package(OpenCV REQUIRED)
catkin_package()
include_directories(
include
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
)
add_executable(image_sub src/image_sub.cpp)
target_link_libraries(image_sub ${OpenCV_LIBS})
|