Skip to content

A simple android app using TensorFlow and pre-trained model to detect objects captured from camera

Notifications You must be signed in to change notification settings

taoran6/AndroidTensorFlowDetectObjectExample

 
 

Repository files navigation

Android TensorFlow Detect Object Example

A simple android using Tensor Flow and pre-trained model to detect objects captured from camera

################################################

Let build Tensor Flow first


android_sdk_repository(
    name = "androidsdk",
    api_level = 23,
    build_tools_version = "25.0.2",
    # Replace with path to Android SDK on your system
    path = "/Android/sdk/",
)

android_ndk_repository(
    name="androidndk",
    path="/Android/android-ndk-r12b/",
    api_level=14)
    
  • Build TensorFlow with Bazel, must go to folder of tensor flow source code to run this command
 
    bazel build -c opt //tensorflow/contrib/android:lib_tensorflow.so \
   --crosstool_top=//external:android/crosstool \
   --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
   --cpu=armeabi-v7a \
   --strategy=CppCompile=standalone
 
  • When build finished successfully, you will find lib_tensorflow.so file in

 [tensorflow source code path]/bazel-bin/tensorflow/contrib/android/lib_tensorflow.so
 
  • Now you need to generate jar file to import into android project, run this command

 bazel build //tensorflow/contrib/android:android_tensorflow_java
 
  • So now you have android_tensorflow_java.jar in folder [tensorflow source code path]/bazel-bin/tensorflow/contrib/android/ and can add as library to android project, create jniLibs folder in src/main and copy lib_tensorflow.so to there.

  • In this example will use the Google pre-trained model which does the object detection on a given image. Download here https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip . Then copy them to assest folder of android project.

About

A simple android app using TensorFlow and pre-trained model to detect objects captured from camera

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%