OpenCV3 install tutorial for Mac

引用链接
http://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html#gsc.tab=0
http://blog.sciencenet.cn/blog-702148-657754.html
https://www.youtube.com/watch?v=XJeP1juuHHY
https://www.youtube.com/watch?v=37RvqZVddAw&list=PLwQFhGFowuPshqdOGaMipClEeFa8is5H8

install OpenCV

Getting OpenCV Source Code

  1. Getting the Latest Stable OpenCV Version from github or http://www.opencv.org

Building OpenCV from Source Using CMake

cd ~/opencv
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make -j8
sudo make install

Remember: Never change opencv_dirctory path after install.

How to develop OpenCV with Xcode

Create C++ Project (pro_name)

pro_name Build Setting > Search Paths

Hearder Search Paths: /usr/local/include
Library Search Paths: /usr/local/lib

pro_name Build Setting > Linking

Other Linker Flags:

-lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core

可在终端中可查看opencv 头文件和动态链接包 pkg-config --cflags opencvpkg-config --libs opencv

$pkg-config --cflags opencv
-I/usr/local/include/opencv -I/usr/local/include
$pkg-config --libs opencv
-L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lippicv -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core

最后测试配置是否成功

#include <iostream>
#include <opencv2/opencv.hpp>
int main(int argc, const char    * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    std::cout << "opencv version:" << CV_VERSION << std::endl;
    return 0;
}

Output:

Hello, World!
opencv version:3.1.0
Program ended with exit code: 0

原文地址: http://blog.csdn.net/lijiang1991/article/details/50756065

Logo

更多推荐