ubuntu 16.04 desktop + server LTS - OpenCV 安装 C API (C 语言接口)
The first step that we should do, is make an update of our repositories, so go and open the terminal and execute the follow commands.sudo apt-get update
sudo apt-get upgrade
# (OpenCV 2.4)
sudo apt-get install -y libopencv-dev
strong@foreverstrong:~$ sudo apt-get update [sudo] password for strong: Get:1 file:/var/cuda-repo-8-0-local-ga2 InRelease Ign:1 file:/var/cuda-repo-8-0-local-ga2 InRelease Get:2 file:/var/cuda-repo-8-0-local-ga2 Release [574 B] Get:2 file:/var/cuda-repo-8-0-local-ga2 Release [574 B] Ign:4 http://www.scootersoftware.com bcompare4 InRelease Hit:5 http://cn.archive.ubuntu.com/ubuntu xenial InRelease Get:6 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Hit:7 http://www.scootersoftware.com bcompare4 Release Hit:8 http://ppa.launchpad.net/djcj/hybrid/ubuntu xenial InRelease Get:9 http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Hit:11 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu xenial InRelease Get:12 http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:13 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [318 kB] Get:14 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [67.7 kB] Hit:15 http://ppa.launchpad.net/hzwhuang/ss-qt5/ubuntu xenial InRelease Get:16 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64x64 Icons [231 kB] Get:17 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [256 kB] Get:18 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64x64 Icons [68.0 kB] Get:19 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [246 kB] Get:20 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64x64 Icons [331 kB] Get:21 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [107 kB] Hit:22 http://ppa.launchpad.net/rvm/smplayer/ubuntu xenial InRelease Get:23 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,964 B] Get:24 http://cn.archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,328 B] Get:25 http://cn.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [5,100 B] Get:26 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64x64 Icons [142 kB] Fetched 2,104 kB in 4s (507 kB/s) Reading package lists... Done strong@foreverstrong:~$ strong@foreverstrong:~$ sudo apt-get install -y libopencv-dev Reading package lists... Done Building dependency tree Reading state information... Done libopencv-dev is already the newest version (2.4.9.1+dfsg-1.5ubuntu1). The following packages were automatically installed and are no longer required: libllvm4.0 linux-headers-4.10.0-40 linux-headers-4.10.0-40-generic linux-headers-4.10.0-42 linux-headers-4.10.0-42-generic linux-headers-4.13.0-26 linux-headers-4.13.0-26-generic linux-headers-4.13.0-31 linux-headers-4.13.0-31-generic linux-headers-4.13.0-32 linux-headers-4.13.0-32-generic linux-headers-4.13.0-36 linux-headers-4.13.0-36-generic linux-headers-4.13.0-37 linux-headers-4.13.0-37-generic linux-headers-4.13.0-38 linux-headers-4.13.0-38-generic linux-headers-4.13.0-39 linux-headers-4.13.0-39-generic linux-image-4.10.0-40-generic linux-image-4.10.0-42-generic linux-image-4.13.0-26-generic linux-image-4.13.0-31-generic linux-image-4.13.0-32-generic linux-image-4.13.0-36-generic linux-image-4.13.0-37-generic linux-image-4.13.0-38-generic linux-image-4.13.0-39-generic linux-image-extra-4.10.0-40-generic linux-image-extra-4.10.0-42-generic linux-image-extra-4.13.0-26-generic linux-image-extra-4.13.0-31-generic linux-image-extra-4.13.0-32-generic linux-image-extra-4.13.0-36-generic linux-image-extra-4.13.0-37-generic linux-image-extra-4.13.0-38-generic linux-image-extra-4.13.0-39-generic linux-signed-image-4.10.0-40-generic linux-signed-image-4.10.0-42-generic linux-signed-image-4.13.0-26-generic linux-signed-image-4.13.0-31-generic linux-signed-image-4.13.0-32-generic linux-signed-image-4.13.0-36-generic linux-signed-image-4.13.0-37-generic linux-signed-image-4.13.0-38-generic linux-signed-image-4.13.0-39-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 162 not upgraded. strong@foreverstrong:~$ strong@foreverstrong:~$ pkg-config --modversion opencv 2.4.9.1 strong@foreverstrong:~$ strong@foreverstrong:~$ pkg-config opencv --modversion 2.4.9.1 strong@foreverstrong:~$ strong@foreverstrong:~$ pkg-config --libs opencv /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so -lopencv_calib3d /usr/lib/x86_64-linux-gnu/libopencv_contrib.so -lopencv_contrib /usr/lib/x86_64-linux-gnu/libopencv_core.so -lopencv_core /usr/lib/x86_64-linux-gnu/libopencv_features2d.so -lopencv_features2d /usr/lib/x86_64-linux-gnu/libopencv_flann.so -lopencv_flann /usr/lib/x86_64-linux-gnu/libopencv_gpu.so -lopencv_gpu /usr/lib/x86_64-linux-gnu/libopencv_highgui.so -lopencv_highgui /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so -lopencv_imgproc /usr/lib/x86_64-linux-gnu/libopencv_legacy.so -lopencv_legacy /usr/lib/x86_64-linux-gnu/libopencv_ml.so -lopencv_ml /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so -lopencv_objdetect /usr/lib/x86_64-linux-gnu/libopencv_ocl.so -lopencv_ocl /usr/lib/x86_64-linux-gnu/libopencv_photo.so -lopencv_photo /usr/lib/x86_64-linux-gnu/libopencv_stitching.so -lopencv_stitching /usr/lib/x86_64-linux-gnu/libopencv_superres.so -lopencv_superres /usr/lib/x86_64-linux-gnu/libopencv_ts.so -lopencv_ts /usr/lib/x86_64-linux-gnu/libopencv_video.so -lopencv_video /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_videostab strong@foreverstrong:~$ strong@foreverstrong:~$ pkg-config opencv --libs /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so -lopencv_calib3d /usr/lib/x86_64-linux-gnu/libopencv_contrib.so -lopencv_contrib /usr/lib/x86_64-linux-gnu/libopencv_core.so -lopencv_core /usr/lib/x86_64-linux-gnu/libopencv_features2d.so -lopencv_features2d /usr/lib/x86_64-linux-gnu/libopencv_flann.so -lopencv_flann /usr/lib/x86_64-linux-gnu/libopencv_gpu.so -lopencv_gpu /usr/lib/x86_64-linux-gnu/libopencv_highgui.so -lopencv_highgui /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so -lopencv_imgproc /usr/lib/x86_64-linux-gnu/libopencv_legacy.so -lopencv_legacy /usr/lib/x86_64-linux-gnu/libopencv_ml.so -lopencv_ml /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so -lopencv_objdetect /usr/lib/x86_64-linux-gnu/libopencv_ocl.so -lopencv_ocl /usr/lib/x86_64-linux-gnu/libopencv_photo.so -lopencv_photo /usr/lib/x86_64-linux-gnu/libopencv_stitching.so -lopencv_stitching /usr/lib/x86_64-linux-gnu/libopencv_superres.so -lopencv_superres /usr/lib/x86_64-linux-gnu/libopencv_ts.so -lopencv_ts /usr/lib/x86_64-linux-gnu/libopencv_video.so -lopencv_video /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_videostab strong@foreverstrong:~$ strong@foreverstrong:~$ pkg-config --cflags opencv -I/usr/include/opencv strong@foreverstrong:~$ strong@foreverstrong:~$ pkg-config opencv --cflags -I/usr/include/opencv strong@foreverstrong:~$ strong@foreverstrong:~$ find /usr -name "opencv.pc" /usr/lib/x86_64-linux-gnu/pkgconfig/opencv.pc strong@foreverstrong:~$
查看 opencv 使用的头文件
pkg-config opencv --cflags
pkg-config --cflags opencv
查看 opencv 使用的库文件
pkg-config opencv --libs
pkg-config --libs opencv
查看 opencv pkg-config 的配置文件
find /usr -name "opencv.pc"
https://github.com/BVLC/caffe/wiki/Ubuntu-16.04-Installation-Guide
https://github.com/BVLC/caffe/wiki/OpenCV-3.3-Installation-Guide-on-Ubuntu-16.04