// // ViewController.m // Demo // // Created by lr on 2023/2/1. // #import "ViewController.h" #import #import #import #import //#import "LenzTensorFlow.h" #import @interface ViewController () @property (nonatomic) UIImagePickerController *imagePickerVc; @property (nonatomic) UIButton *takeButton; //@property (nonatomic) LenzTensorFlow *tensor; @property (nonatomic) UILabel *resultLabel; @property (nonatomic) UILabel *remakeLabel; @property (nonatomic) UITextView *textView; @property (nonatomic) UIButton *photoButton; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self.navigationController setNavigationBarHidden:YES animated:NO]; self.view.backgroundColor = [UIColor whiteColor]; self.photoButton = [[UIButton alloc]init]; self.photoButton.backgroundColor = [UIColor grayColor]; [self.photoButton setTitle:@"打开相机" forState:UIControlStateNormal]; [self.photoButton addTarget:self action:@selector(photoAction) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:self.photoButton]; [self.photoButton mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.view); make.bottom.mas_offset(-80); make.width.mas_offset(80); make.height.mas_offset(44); }]; self.textView = [[UITextView alloc]init]; self.textView.backgroundColor = [UIColor lightGrayColor]; [self.view addSubview:self.textView]; [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_offset(20); make.right.mas_offset(-20); make.top.mas_offset(50); make.bottom.mas_equalTo(self.photoButton.mas_top).mas_offset(-50); }]; } - (void)photoAction { self.textView.text = nil; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; dict[@"dataRetainedMode"] = @"retain"; dict[@"cameraMode"] = @[@"continuous",@"single",@"video", @"panorama", @"panoramaPlus"]; dict[@"flashMode"] = @"auto"; dict[@"type"] = @"back"; dict[@"videoQuality"] = @(720); dict[@"recTime"] = @(100); dict[@"keyframe"] = @(1); [LenzCameraSDK showCameraSDKWithParams:dict presentVC:self complete:^(NSDictionary * _Nonnull dict) { NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingSortedKeys error:&error]; NSString *jsonString; if (!jsonData) { NSLog(@"%@",error); } else { jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding]; } self.textView.text = jsonString; }]; } @end