Skip to content

sjfricke/OpenCV-NDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenCV For Android NDK

This is a showcase how to get OpenCV up and running with just the Android NDK

  • This uses the NDK Camera2 API to get the image buffers
  • It then uses OpenCV to processes the image buffer
  • Lastly it gets the NDK ANativeWindow and displays the image for live previewing

Demo

demo gif

Prerequisites

How to setup

  • Clone or download repo and open the OpenCV-NDK folder. (The 2nd one that is the child)
    • Click "Open project" in Android studio and find the folder saved in
  • Change the OpenCV Android SDK library path in Android.mk file to your my/path/to/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk
  • Move all files in the Asset folder to your device
    • This is annoying af, but no good solution I could find easily fixed it since OpenCV requires a file string which the NDK only gives you a file descriptor.
    • Currently the folder location pointing to the asset files are listed in the CV_Main.h private values so make sure it matches
    • On your computer go to the ./OpenCV-NDK/app/src/main/assets folder and with your device plugged in run
      • adb push haarcascade_frontalface_alt.xml /sdcard/Download/opencv/haarcascade_frontalface_alt.xml
      • adb push haarcascade_eye_tree_eyeglasses.xml /sdcard/Download/opencv/haarcascade_eye_tree_eyeglasses.xml

How to run 32 bit (or x86)

To make compiling faster I only have it load and run ARM 64-bit (arm64-v8a). To add a different abi architecture:

About

Example of using OpenCV with Android NDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published