All Projects → makbn → opencv_android_setup_tutorial

makbn / opencv_android_setup_tutorial

Licence: other
Tutorial on OpenCV for Android with Android Studio

Programming Languages

java
68154 projects - #9 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to opencv android setup tutorial

Androiddevwithcpp
Android Develop With C++
Stars: ✭ 106 (+231.25%)
Mutual labels:  ndk
Stunning Signature
Native Signature Verification For Android (with example)
Stars: ✭ 139 (+334.38%)
Mutual labels:  ndk
Appaddupdate
Android app 增量更新
Stars: ✭ 192 (+500%)
Mutual labels:  ndk
Androidtrainingdemo
android training demo
Stars: ✭ 116 (+262.5%)
Mutual labels:  ndk
Awesome Android Ndk
🔥 全面深入地掌握NDK技术,成为下一波5G时代的浪潮儿~
Stars: ✭ 138 (+331.25%)
Mutual labels:  ndk
Androidsecurity
Android安全实践
Stars: ✭ 150 (+368.75%)
Mutual labels:  ndk
Ndcrash
A powerful crash reporting library for Android NDK. Don't forget to run git submodule update --init --recursive after checking out.
Stars: ✭ 91 (+184.38%)
Mutual labels:  ndk
Sol2
Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
Stars: ✭ 2,791 (+8621.88%)
Mutual labels:  ndk
Lpr
Android 车牌识别--OCR
Stars: ✭ 139 (+334.38%)
Mutual labels:  ndk
Mwengine
Audio engine and DSP for Android, written in C++ providing low latency performance in a musical context, supporting both OpenSL and AAudio.
Stars: ✭ 190 (+493.75%)
Mutual labels:  ndk
Googleserialport
Android串口通信:抱歉,学会它真的可以为所欲为 ! ! !
Stars: ✭ 130 (+306.25%)
Mutual labels:  ndk
Byopen
🎉A dlopen library that bypasses mobile system limitation
Stars: ✭ 133 (+315.63%)
Mutual labels:  ndk
Jpegkit Android
Efficient JPEG operations for Android without the risk of an OutOfMemoryException.
Stars: ✭ 154 (+381.25%)
Mutual labels:  ndk
Crashsdk
catch crash on Android(arm/x86)
Stars: ✭ 107 (+234.38%)
Mutual labels:  ndk
Ffmpeg Android Maker
Contains a script that assembles FFmpeg library for Android
Stars: ✭ 207 (+546.88%)
Mutual labels:  ndk
Termux Ndk
android-ndk for termux
Stars: ✭ 91 (+184.38%)
Mutual labels:  ndk
Cargo Ndk
Compile Rust projects against the Android NDK without hassle
Stars: ✭ 141 (+340.63%)
Mutual labels:  ndk
Android Disassembler
Disassemble ANY files including .so (NDK, JNI), Windows PE(EXE, DLL, SYS, etc), linux binaries, libraries, and any other files such as pictures, audios, etc(for fun)files on Android. Capstone-based disassembler application on android. 안드로이드 NDK 공유 라이브러리, Windows 바이너리, etc,... 리버싱 앱
Stars: ✭ 250 (+681.25%)
Mutual labels:  ndk
Relinker
A robust native library loader for Android.
Stars: ✭ 2,612 (+8062.5%)
Mutual labels:  ndk
Hidex Hack
anti reverse by hack dex file
Stars: ✭ 160 (+400%)
Mutual labels:  ndk

Tutorial on OpenCV for Android Setup

Welcome guys! my goal is to make it easy to create an android CV application with OpenCV libraries.

before starting tutorial its better to know the version of tools that i used!

OpenCV for Android

Tools Version

Tool Version
OpenCV Android SDK openCV-3.2.0
Android Studio v2.2.2
Android SDK build-tools v25
Android SDK platform-tools v25.0.3
Android Official NDK android-ndk-r12b
  • OS: Windows 10 💩

Getting Start

First of all you need to download OpenCv Android SDK and Android Official NDK!

  • Extract downloaded NDK in a simple direction without space in dir path! like C:\work\android-ndk-r12b
  • Extract extract OpenCV SDK beside NDK folder (technically this direction is Not important! 😄)

Edit system environment for java and ndk-build:

  1. Right click on This PC and go to Properties find Advanced dystem Settings on right side and open it!

  2. In new Window go to Advanced tab and click on Environment Variables.

  3. Find PATH variable for current user and click on Edit

  4. Click New button in opened window and paste the direction of your java bin folder! like : *C:\Program Files\Java\jdk1.8.0_40\bin*

  5. Add the path of NDK like step 4!for NDK you need to add root direction! like : C:\work\android-ndk-r12b

  6. Done!

Installing Cmake for Android SDK:

  1. Open Android Studio and go to Settings
  2. Go to Appearance & Behavior and click on System settings on opened sublist,and find Android SDK!
  3. Click on SDK Tools tab and make sure that CMake is install. if not!check it for install!

Creating Project

Time to creating New Android Project

  1. Open Android Studio and clcik on New Projcet (its all over and done! 😄)
  2. Its clear that you need to fill Application Name and Company Domain but most Important Job here is to check Include C++ Support
  3. Continue like all other default android project and in the last step before click on Finish you need to set your C++ Standard! i use Toolchain Default!
  • if you got an exceptin with this message : Error:NDK not configured. Download it with SDK manager.) you should follow this steps:

    1. open Project Structure under File tab.
    2. set you NDK direction in Android NDK location and Done!

Add OpenCV Java Wrapper Module!

  1. On File menu click on New and click on Import Module!
  2. Go to {YOUR_OPENCV_SDK_DIR}\sdk\ and select java folder!click on OK!
  3. Click on next then finish.
  4. Open app level gradle and add this line under dependencies scope:
compile project(':openCVLibrary320')
  • openCVLibrary320 is the name of added module from OpenCV and it may have different name for you!

Add jniLibs folder

  1. Right click on app folder (or its better to say app module) of your project!
  2. Click on New an go to Folder submenu, select JNI Folder.
  3. Check Change Folder Location
  4. Change src/main/jni/ to src/main/jniLibs/ and click on Finish

Add native libs

You need to add native libraries for different type of proccessors!fortunetly OpenCV provides all of them for you and you can find them under OpenCV SDK directory \sdk\native\libs!

In order to add a specific proccessor's library you just need to copy that folder and paste it under jniLibs folder!

  • you can add them all but its better to add what you need specificly!

Create Android.mk file and configure it!

  1. Create new File under jniLibs dir and name it Android.mk!
  2. Copy this lines and paste there:
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCV_LIB_TYPE:=SHARED
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on

include {OpenCV.mk_DIR}

LOCAL_SRC_FILES  := native-lib.cpp
LOCAL_C_INCLUDES += {INCLUDE_DIR}
LOCAL_LDLIBS     += -llog -ldl
LOCAL_CFLAGS    += -DOPENCV_OLDER_VISION

LOCAL_CPP_FEATURES += exceptions (Recommended)
LOCAL_CPPFLAGS += -fexceptions


LOCAL_MODULE     := native-lib

include $(BUILD_SHARED_LIBRARY)
  • {OpenCV.mk_DIR} : directory of OpenCV.mk file under under OpenCV SDK directory \sdk\native\jni\OpenCV.mk
  • {INCLUDE_DIR} : directory of OpenCV include folder under OpenCV SDK directory \sdk\native\jni\include
  • LOCAL_MODULE : name of native cpp file that you need for writing native cpp code! skip for now.

Optional config:

  • OPENCV_CAMERA_MODULES and OPENCV_INSTALL_MODULES : if you turn this option off your application need external OpenCV Package Manager installed on user device to work!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].