LENZViewController.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // ViewController.m
  3. // Demo
  4. //
  5. // Created by lr on 2023/2/1.
  6. //
  7. #import <LenzSDK/LenzCameraSDK.h>
  8. #import "LENZViewController.h"
  9. #import <AVFoundation/AVFoundation.h>
  10. #import <Photos/Photos.h>
  11. #import <Masonry/Masonry.h>
  12. #import <MobileCoreServices/MobileCoreServices.h>
  13. //#import "LenzTensorFlow.h"
  14. @interface LENZViewController ()<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 LENZViewController
  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. // {
  51. // "cameraMode": [{
  52. // "flashMode": "auto",
  53. // "isRemake": true,
  54. // "mode": "continuous",
  55. // "quality": 100,
  56. // "type": "back"
  57. // }, {
  58. // "flashMode": "auto",
  59. // "isRemake": true,
  60. // "mode": "single",
  61. // "quality": 100,
  62. // "type": "back"
  63. // }, {
  64. // "flashMode": "auto",
  65. // "isRemake": true,
  66. // "mode": "video",
  67. // "quantity": 0,
  68. // "recTime": 30,
  69. // "type": "back",
  70. // "videoQuality": 480
  71. // }, {
  72. // "flashMode": "auto",
  73. // "isRemake": true,
  74. // "mode": "parnorama",
  75. // "type": "back",
  76. // "videoQuality": 480
  77. // }],
  78. // "dataRetainedMode": "retain"
  79. // }
  80. self.textView.text = nil;
  81. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  82. dict[@"dataRetainedMode"] = @"retain";
  83. NSArray *array = @[@{@"flashMode": @"auto", @"isRemake":@(1),@"mode":@"continuous", @"quality":@(100),@"type":@"back" },
  84. @{@"flashMode": @"auto", @"isRemake":@(1),@"mode":@"single", @"quality":@(100),@"type":@"back" },
  85. @{@"flashMode": @"auto", @"isRemake":@(1),@"mode":@"video", @"quality":@(100),@"type":@"back", @"videoQuality":@(1080)},
  86. @{@"flashMode": @"auto", @"isRemake":@(1),@"mode":@"panorama", @"quality":@(100),@"type":@"back", @"videoQuality":@(1080)},
  87. @{@"flashMode": @"auto", @"isRemake":@(1),@"mode":@"panoramaPlus", @"quality":@(100),@"type":@"back", @"videoQuality":@(480)}];
  88. dict[@"cameraMode"] = array;
  89. // dict[@"flashMode"] = @"auto";
  90. // dict[@"type"] = @"back";
  91. // dict[@"videoQuality"] = @(720);
  92. // dict[@"recTime"] = @(100);
  93. // dict[@"keyframe"] = @(1);
  94. [LenzCameraSDK showCameraSDKWithParams:dict presentVC:self complete:^(NSDictionary * _Nonnull dict) {
  95. NSError *error;
  96. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
  97. options:NSJSONWritingSortedKeys
  98. error:&error];
  99. NSString *jsonString;
  100. if (!jsonData) {
  101. NSLog(@"%@",error);
  102. } else {
  103. jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
  104. }
  105. self.textView.text = jsonString;
  106. }];
  107. }
  108. @end