Home | History | Annotate | Download | only in camera
      1 // Copyright 2017 The TensorFlow Authors. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //    http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #import <AVFoundation/AVFoundation.h>
     16 #import <UIKit/UIKit.h>
     17 
     18 #include <vector>
     19 
     20 #include "tensorflow/contrib/lite/kernels/register.h"
     21 #include "tensorflow/contrib/lite/model.h"
     22 
     23 @interface CameraExampleViewController
     24     : UIViewController<UIGestureRecognizerDelegate, AVCaptureVideoDataOutputSampleBufferDelegate> {
     25   IBOutlet UIView* previewView;
     26   AVCaptureVideoPreviewLayer* previewLayer;
     27   AVCaptureVideoDataOutput* videoDataOutput;
     28   dispatch_queue_t videoDataOutputQueue;
     29   UIView* flashView;
     30   BOOL isUsingFrontFacingCamera;
     31   NSMutableDictionary* oldPredictionValues;
     32   NSMutableArray* labelLayers;
     33   AVCaptureSession* session;
     34 
     35   std::vector<std::string> labels;
     36   std::unique_ptr<tflite::FlatBufferModel> model;
     37   tflite::ops::builtin::BuiltinOpResolver resolver;
     38   std::unique_ptr<tflite::Interpreter> interpreter;
     39 
     40   double total_latency;
     41   int total_count;
     42 }
     43 @property(strong, nonatomic) CATextLayer* predictionTextLayer;
     44 
     45 - (IBAction)takePicture:(id)sender;
     46 - (IBAction)switchCameras:(id)sender;
     47 
     48 @end
     49