编译得到OpenCv+Contrib SDK for android

来自:http://tzutalin.blogspot.jp/2016/01/installing-opencv-310-and-contrib-lib.html

Build and install OpenCV and contrib lib on Ubuntu / Android


I am going to show you how to clone the opencv source from  Git repository. After cloing the source, I will build and install it.

Build for ubuntu
Download the source of opencv and opencv_contrib from github and checkout to the tag, 3.1.0:
cd ~/<my_working _directory>
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
cd ~/<my_working _directory>/opencv
git checkout -b 3.1.0 3.1.0
cd ~/<my_working _directory>/opencv_contrib
git checkout -b 3.1.0 3.1.0

Use cmake: 
cd opencv
mkdir release
cd release
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

If your environment contains CUDA, by default, it will build it with CUDA. If you don't want to build it with CUDA,   add  -DWITH_CUDA=OFF  to your  cmake  command line.

Start to build and install to /usr/local/include and /usr/local/lib. You can change the installed dir by change CMAKE_INSTALL_PREFIX
make -j8 # -j8 runs 8 jobs in parallel.
         # Change 8 to number of hardware threads available.
sudo make install

You can check your current opencv version:
$ pkg-config --modversion opencv

It will be 3.1.0 !

You can also look at the headers or libs installed. Using pkg-config can tell you where they are: 
$ pkg-config --cflags opencv
$ pkg-config --libs opencv

Actually, you can use the latest stable OpenCV version available in sourceforge without building the source.

How to speed up building process?
You can use Ninja to speed up instead of using Makefile
cd opencv
mkdir release
cd release
cmake -G Ninja -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
ninja -j8
ninja install
Build for Android version:
export ANDROID_NDK=[YourNDKPath]
cd ~/<my_working _directory>git clone https://gist.github.com/tzutalin/f07f5633fd599001101006561689062b
sh build-android-opencv.sh

You can change your target API in  build_android_opencv.sh. For example, you can build the target for arm by changing the variable, ANDROID_ABI, in build_android_opencv.sh which you clone from the above commands.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值