菜单

TK1初学软件教程-安装OpenCV(五)

2018年5月17日 - TK1初学软件教程

TK1入门教程软件篇-安装OpenCV

说明:

OpenCV简介:

OpenCV特点:

OpenCV核心功能:

安装准备:

SIFT/SURF的注意事项

安装预建的OpenCV4Tegra库:

sudo apt-add-repository universe
sudo apt-get update
sudo dpkg -i libopencv4tegra_2.4.10.1_armhf.deb
sudo dpkg -i libopencv4tegra-dev_2.4.10.1_armhf.deb
sudo dpkg -i libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb  (does not work, please fix!)
sudo apt-get update
sudo apt-get install libopencv4tegra libopencv4tegra-dev
# Some general development libraries  
sudo apt-get install build-essential make cmake cmake-curses-gui g++  
# libav video input/output development libraries  
sudo apt-get install libavformat-dev libavutil-dev libswscale-dev  
# Video4Linux camera development libraries  
sudo apt-get install libv4l-dev  
# Eigen3 math development libraries  
sudo apt-get install libeigen3-dev  
# OpenGL development libraries (to allow creating graphical windows)  
sudo apt-get install libglew1.6-dev  
# GTK development libraries (to allow creating graphical windows)  
sudo apt-get install libgtk2.0-dev  

源码安装:

cd ~/opencv
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip  
unzip opencv-2.4.9.zip  
mv opencv-2.4.9 ~  
cd ~/opencv-2.4.9  
mkdir build  
cd build  
cmake -DWITH_CUDA=ON -DCUDA_ARCH_BIN="3.2" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF 
sudo make -j4 install  
echo "# Use OpenCV and other custom-built libraries." >> ~/.bashrc  
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/" >> ~/.bashrc  
source ~/.bashrc  

测试OpenCV:

# Make sure we have installed a C++ compiler.  
sudo apt-get install build-essential g++  
# Test a simple OpenCV program. Creates a graphical window, hence you should plug a HDMI monitor in or use a remote viewer such as X Tunneling or VNC or TeamViewer on your desktop.  
cd ~/opencv-2.4.9/samples/cpp  
g++ edge.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -o edge  
./edge  

请输入图片描述

# If you have a USB webcam plugged in to your board, then test one of the live camera programs.  
g++ laplace.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o laplace  
./laplace  
# Test a GPU accelerated OpenCV sample.  
cd ../gpu  
g++ houghlines.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o houghlines  
./houghlines ../cpp/logo_in_clutter.png  

请输入图片描述

请输入图片描述

请输入图片描述

参考:

发表评论