ViewController.m 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // ViewController.m
  3. // Demo
  4. //
  5. // Created by lr on 2023/2/1.
  6. //
  7. #import "ViewController.h"
  8. #import <AVFoundation/AVFoundation.h>
  9. #import <Photos/Photos.h>
  10. #import <Masonry/Masonry.h>
  11. #import <MobileCoreServices/MobileCoreServices.h>
  12. //#import "LenzTensorFlow.h"
  13. #import <LenzCameraNativeModuleForRN/LenzCameraSDK.h>
  14. @interface ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
  15. @property (nonatomic) UIImagePickerController *imagePickerVc;
  16. @property (nonatomic) UIButton *takeButton;
  17. //@property (nonatomic) LenzTensorFlow *tensor;
  18. @property (nonatomic) UILabel *resultLabel;
  19. @property (nonatomic) UILabel *remakeLabel;
  20. @property (nonatomic) UITextView *textView;
  21. @property (nonatomic) UIButton *photoButton;
  22. @end
  23. @implementation ViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. [self.navigationController setNavigationBarHidden:YES animated:NO];
  27. self.view.backgroundColor = [UIColor whiteColor];
  28. self.photoButton = [[UIButton alloc]init];
  29. self.photoButton.backgroundColor = [UIColor grayColor];
  30. [self.photoButton setTitle:@"打开相机" forState:UIControlStateNormal];
  31. [self.photoButton addTarget:self action:@selector(photoAction) forControlEvents:UIControlEventTouchUpInside];
  32. [self.view addSubview:self.photoButton];
  33. [self.photoButton mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.centerX.mas_equalTo(self.view);
  35. make.bottom.mas_offset(-80);
  36. make.width.mas_offset(80);
  37. make.height.mas_offset(44);
  38. }];
  39. self.textView = [[UITextView alloc]init];
  40. self.textView.backgroundColor = [UIColor lightGrayColor];
  41. [self.view addSubview:self.textView];
  42. [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_offset(20);
  44. make.right.mas_offset(-20);
  45. make.top.mas_offset(50);
  46. make.bottom.mas_equalTo(self.photoButton.mas_top).mas_offset(-50);
  47. }];
  48. }
  49. - (void)photoAction {
  50. self.textView.text = nil;
  51. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  52. dict[@"dataRetainedMode"] = @"retain";
  53. dict[@"cameraMode"] = @[@"continuous",@"single",@"video", @"panorama", @"panoramaPlus"];
  54. dict[@"flashMode"] = @"auto";
  55. dict[@"type"] = @"back";
  56. dict[@"videoQuality"] = @(720);
  57. dict[@"recTime"] = @(10);
  58. dict[@"keyframe"] = @(1);
  59. [LenzCameraSDK showCameraSDKWithParams:dict presentVC:self complete:^(NSDictionary * _Nonnull dict) {
  60. NSError *error;
  61. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
  62. options:NSJSONWritingSortedKeys
  63. error:&error];
  64. NSString *jsonString;
  65. if (!jsonData) {
  66. NSLog(@"%@",error);
  67. } else {
  68. jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
  69. }
  70. self.textView.text = jsonString;
  71. }];
  72. }
  73. @end