Skip to content

yge58/caffe2-opencv-ndkcamera

Repository files navigation

What is it?

An android ndk app integrating caffe2, opencv and ndk camera.

How to build

<1> Android Studio 2.3.0 or above

<2> Android-21 or above

If building this app failed, please build google ndk camera sample.

Which parts of program are in NDK?

<1> camera

<2> opencv

<3> caffe2

Screenshot

screenshot

Source Code Structure

In texture-view,

          |__build
          |__build.gradle
          |__src
               |__main
                     |__assets
                           |__squeeze_init_net.pb    (squeeze net architecture file)
                           |__squeeze_predict_net.pb (squeeze net pretrained weights)
                     |__cpp
                           |__caffe2  (caffe2 headers)
                           |__camera  (Android NDK native Camera API)
                           |__Eigen   (Eigen headers)
                           |__google  (protobuf headers)
                           |__opencv  (opencv headers)
                           |__opencv2 (opencv2 headers)
                           |__android_main.cpp   ( 1. contains all c++ files that are called from Java via JNI)
                                                 ( 2. handles all the native activities including camera, caffe, opencv.)
                           |__classes.h (Imagenet classes)
                           |__CMakeLists.txt     ( CMake )
                     |__Java
                           |__com__sample__textureview
                                                   |__ViewActivity.java (App's life cycle, UI)
                     |__libs
                           |__armeabi-v7a (This is the only ABI supported unfortunately)
                                        |__opencv (opencv4android libraries)
                                        |__(the rest libraries are copied from AICamera)
                     |__res
                     |__AndroidManifest.xml

Source code is based upon the following, and I am grateful to them.

[1] NDK sample code is from Google NDK camera texture-view sample

[2] Caffe2 C++ classification procedure is from Caffe2 example

[3] Caffe2 pretrained protobuf and libraries are from AIcamera

[4] The OpenCV libraries are from OpenCV4Android

And these NDK documentation are very helpful.

Issues and bugs (memory leaks, resource allocation and free, threads concurrency, how to balance workload between threads and etc ... ) if you see any of them or have any improvement suggestions, please help me by filing as many issues as you want. I will be very grateful.

About

Integrating Caffe2, OpenCV with Android Native Camera API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages