Skip to content

An Open Source Machine Learning Framework for Everyone

License

Notifications You must be signed in to change notification settings

Utree/AiLocker_v1

 
 

未来のデスクトップ -iOS APP-

使い方

  1. Tensor Flow Liteのでもアプリをつくる

TensorFlow Liteのサイトを参考にして、デモアプリをつくる

$ git clone https://github.com/tensorflow/tensorflow
$ xcode-select --install
$ sudo gem install cocoapods
$ sh tensorflow/lite/examples/ios/download_models.sh
$ cd tensorflow/lite/examples/ios/camera
$ pod install
$ pod update
$ open tflite_camera_example.xcworkspace
  1. CameraExampleViewController.mmを編集

551行目に追記 ただし、"https://NGROK_URL/"はよしなに変更する

      if(labelCount == 0) {
          if([[label capitalizedString] isEqualToString:@"Pencil Box"]) {
              UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"ロックを解除しますか?"
                                                                                       message:@""
                                                                                preferredStyle:UIAlertControllerStyleAlert];
              
              [alertController addAction:[UIAlertAction actionWithTitle:@"はい"
                                                                  style:UIAlertActionStyleDefault
                                                                handler:^(UIAlertAction *action) {
                                                                    // 送信したいURLを作成し、Requestを作成します。
                                                                    NSURL *url = [NSURL URLWithString:@"https://NGROK_URL/unlock/"];
                                                                    NSURLRequest  *request = [[NSURLRequest alloc] initWithURL:url];
                                                                    // NSURLConnectionのインスタンスを作成したら、すぐに
                                                                    // 指定したURLへリクエストを送信し始めます。
                                                                    // delegate指定すると、サーバーからデータを受信したり、
                                                                    // エラーが発生したりするとメソッドが呼び出される。
                                                                    NSURLConnection *aConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
                                                                    
                                                                    // 作成に失敗する場合には、リクエストが送信されないので
                                                                    // チェックする
                                                                    if (!aConnection) {
                                                                        NSLog(@"connection error.");
                                                                    }
                                                                }]];
              
              [alertController addAction:[UIAlertAction actionWithTitle:@"いいえ"
                                                                  style:UIAlertActionStyleDefault
                                                                handler:^(UIAlertAction *action) {
                                                                    // cancelボタンが押された時の処理
                                                                    
                                                                }]];
              
              [self presentViewController:alertController animated:YES completion:nil];
          } else if([[label capitalizedString] isEqualToString:@"Rubber Eraser"]) {
              UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"ロックしますか?"
                                                                                       message:@""
                                                                                preferredStyle:UIAlertControllerStyleAlert];
              
              [alertController addAction:[UIAlertAction actionWithTitle:@"はい"
                                                                  style:UIAlertActionStyleDefault
                                                                handler:^(UIAlertAction *action) {
                                                                    // 送信したいURLを作成し、Requestを作成します。
                                                                    NSURL *url = [NSURL URLWithString:@"https://NGROK_URL/lock/"];
                                                                    NSURLRequest  *request = [[NSURLRequest alloc] initWithURL:url];
                                                                    // NSURLConnectionのインスタンスを作成したら、すぐに
                                                                    // 指定したURLへリクエストを送信し始めます。
                                                                    // delegate指定すると、サーバーからデータを受信したり、
                                                                    // エラーが発生したりするとメソッドが呼び出される。
                                                                    NSURLConnection *aConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
                                                                    
                                                                    // 作成に失敗する場合には、リクエストが送信されないので
                                                                    // チェックする
                                                                    if (!aConnection) {
                                                                        NSLog(@"connection error.");
                                                                    }
                                                                }]];
              
              [alertController addAction:[UIAlertAction actionWithTitle:@"いいえ"
                                                                  style:UIAlertActionStyleDefault
                                                                handler:^(UIAlertAction *action) {
                                                                    // cancelボタンが押された時の処理
                                                                    
                                                                }]];
              
              [self presentViewController:alertController animated:YES completion:nil];
          }
      }
  1. TeamとBundle Identifierを編集

  2. 実行

参考サイト

License

Apache License 2.0

About

An Open Source Machine Learning Framework for Everyone

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 49.4%
  • Python 40.4%
  • HTML 4.4%
  • Jupyter Notebook 2.4%
  • Go 1.2%
  • Java 0.8%
  • Other 1.4%