LoginSignup
2
1

More than 5 years have passed since last update.

AndroidStudio での Tensorflow 導入からエミュレータ(PCカメラ)のデモまで

Posted at

前提

  • 開発PCはMacです
  • AndroidStudio インストール済であること

Tensorflow をクローンする

任意の場所にクローンする
git clone https://github.com/tensorflow/tensorflow

ビルド前に設定を変更する

tensorflow/examples/android/build.gradle の編集

build.gradle
buildscript {
    repositories {
        google()
        jcenter()
    }
build.gradle
// set to 'bazel', 'cmake', 'makefile', 'none'
def nativeBuildSystem = 'none'

使用カメラの設定

エミュレータで使用するカメラをPCカメラにする必要があるので、設定をする

AndroidStudio のAVDマネージャーを開く
スクリーンショット 2018-06-17 12.54.04.png

編集ボタンを押下
スクリーンショット 2018-06-17 12.59.01.png

Show Advanced Settings を押下
スクリーンショット 2018-06-17 13.00.38.png

CameraWebcam0に変更
スクリーンショット 2018-06-17 13.02.05.png

これでエミュレータのカメラがPCカメラで起動するようになります。

プロジェクトを開く

tensorflow/examples/android をAndroidStudioでオープンし、ビルドが終わるのを待ちます。
※ツールのバージョンが古いすぎる等何度か怒られましたが、基本的には指示に従ってアップデートをするだけでビルド成功するようになりました。

エミュレータを起動→エミュレータ内部のカメラを起動します。
しばらくすると、青い部分が出現して、画面に映っているものの名前を表示してくれます。

財布を写してみました。
スクリーンショット 2018-06-17 13.16.00.png

wallet: 0.23740001と表示されています。
数字はリアルタイムでどんどん変化していくので、色々映してみると楽しいです!

今回はとりあえずデモの起動までを行いました。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1