Build OpenCV libraries for Android arm, x86 ubuntu

Source: Internet
Author: User

Don't say much nonsense.

Preparatory work:

1. Download Source: http://opencv.org/

Build platform: ubuntu14.04

OpenCV 2.4.6.1

I use this method to compile the Opecv 2.4.9 no problem, the problem is less than opencv2.4.6.1, in fact, their principle is the same.

OpenCV Source root directory----${opencv_home}

2.

Modify the ${opencv_home}/platforms/scripts/cmake_android_arm.sh file to add compilation options-dbuild_shared_libs=on and-DWITH_OPENCL=ON
The modified cmake_android_arm.sh file is as follows:

#!/bin/shcd ' dirname '/. Mkdir-p BUILD_ANDROID_ARMCD build_android_armcmake-dcmake_build_with_install_rpath=on-dcmake_toolchain_file=. /android/android.toolchain.cmake [email protected]. /..      -dbuild_shared_libs=on-dwith_opencl=on

3.

Modify ${opencv_home}/cmake/opencvdetectopencl.cmake

To generate compile options that support compiling OpenCL:

add after Opencvdetectopencl.cmake 40 lines

Set (Opencl_found YES) set (Opencl_include_dir your_ocl_include_dir) #set (opencl_library    You_opencl_lib_file_ Path

One is to set the OCL header file, a set of OpenCL library file, the above commented out because I want to use a dynamic display call the way to invoke the OpenCL Library API, so that it does not have to be compiled in the device-related OpenCL library.

4.

Modify ${opencv_home}/"Include OpenCL Runtimesupport" on IF (not IOS))

This step seems to be in the opencv2.4.9 version of the source code can not be set.

The main purpose of this is to enable the next generation of OpenCL-enabled options.


5. execution of ${opencv_home}/platforms/scripts/cmake_android_arm.sh

If there is a problem with the implementation, set the NDK path:

Terminal execution: Export ndkroot=/xxxx/android-ndk-r9d

--  Other Third-party libraries:
--    use IPP:   & nbsp                 NO
--    use Eigen:         &NBS P         NO
--    use TBB:                     NO
--    use OpenMP:                  no
--  & nbsp Use GCD                      no
–     use Concurrency              no
--    use c=:                      no
--    use Cuda:                    no
--    use OpenCL:                  yes

This makes it possible to compile the relevant libraries. However, if you do not set

Set (Opencl_library    You_opencl_lib_file_path)
This may lead to some test compilation does not pass, no relationship, OCL's related library has been able to compile.

6. Switch to the ${opencv_home}/platforms/build_android_arm directory:

Execution: Make

Wait for the compilation to complete ...

7. Final Andorid Dynamic library is generated under ${opencv_home}/platforms/build_android_arm/lib/armeabi-v7a


For Android x86 the same way Android Arm Library compilation method, just step 2, 5 operation script is ${opencv_home}/platforms/scripts/cmake_android_x86.sh



I wish you a pleasant use. What is the problem, please note that in order to correct it.









Build OpenCV libraries for Android arm, x86 ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.