BDFaceSuccessViewController.m 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // BDFaceSuccessViewController.m
  3. // FaceSDKSample_IOS
  4. //
  5. // Created by 孙明喆 on 2020/3/12.
  6. // Copyright © 2020 Baidu. All rights reserved.
  7. //
  8. #import "BDFaceSuccessViewController.h"
  9. #import "BDFaceLivingConfigViewController.h"
  10. #import "BDFaceDetectionViewController.h"
  11. #import "BDFaceLivenessViewController.h"
  12. #import "IDLFaceSDK/IDLFaceSDK.h"
  13. #import "BDFaceLivingConfigModel.h"
  14. #import "BDFaceLogoView.h"
  15. #import "BDFaceImageShow.h"
  16. #import "NSBundle+AssociatedBundle.h"
  17. #define ScreenWidth [UIScreen mainScreen].bounds.size.width
  18. #define ScreenHeight [UIScreen mainScreen].bounds.size.height
  19. #define ImageBundle [NSBundle bundleWithBundleName:@"ImageBundle.bundle" podName:@"fltbdface"]
  20. @interface BDFaceSuccessViewController ()
  21. @end
  22. @implementation BDFaceSuccessViewController
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.view.backgroundColor = [UIColor whiteColor];
  26. UIButton *backButton = [[UIButton alloc] init];
  27. backButton.frame = CGRectMake(23.3, 43.3, 20, 20);
  28. [backButton setImage:[UIImage imageNamed:@"icon_titlebar_close"] forState:UIControlStateNormal];
  29. [backButton addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
  30. [self.view addSubview:backButton];
  31. // 成功图片显示和label
  32. UIImageView *successImageView = [[UIImageView alloc] init];
  33. successImageView.frame = CGRectMake((ScreenWidth-97.3) / 2, 156, 97.3, 97.3);
  34. UIImage *showImage = [[BDFaceImageShow sharedInstance] getSuccessImage];
  35. successImageView.image = showImage;
  36. successImageView.layer.masksToBounds = YES;
  37. successImageView.layer.cornerRadius = 50;
  38. [self.view addSubview:successImageView];
  39. UILabel *successLabel = [[UILabel alloc] init];
  40. successLabel.frame = CGRectMake(0, 276.3, ScreenWidth, 22);
  41. successLabel.text = @"人脸采集成功";
  42. successLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:22];
  43. successLabel.textColor = [UIColor colorWithRed:0 / 255.0 green:0 / 255.0 blue:0 / 255.0 alpha:1 / 1.0];
  44. successLabel.textAlignment = NSTextAlignmentCenter;
  45. [self.view addSubview:successLabel];
  46. // 活体UI默认关闭
  47. // UILabel *liveScoreLabel = [[UILabel alloc] init];
  48. // liveScoreLabel.frame = CGRectMake(0, 300, ScreenWidth, 22);
  49. // NSString *liveScoreTxt = [NSString stringWithFormat:@"活体分值 %f ",[[BDFaceImageShow sharedInstance] getSilentliveScore]];
  50. // liveScoreLabel.text = liveScoreTxt;
  51. // liveScoreLabel.font = [UIFont systemFontOfSize:16];
  52. // liveScoreLabel.textColor = [UIColor colorWithRed:102 / 255.0 green:102 / 255.0 blue:102 / 255.0 alpha:1 / 1.0];
  53. // liveScoreLabel.textAlignment = NSTextAlignmentCenter;
  54. // [self.view addSubview:liveScoreLabel];
  55. // 上下两个button
  56. UIButton *btnFirst = [[UIButton alloc] init];
  57. btnFirst.frame = CGRectMake((ScreenWidth-260) / 2, 452, 260, 44);
  58. [btnFirst setImage:[[UIImage alloc] initWithContentsOfFile:[ImageBundle pathForResource:@"btn_main_normal" ofType:@"png"]] forState:UIControlStateNormal];
  59. [btnFirst addTarget:self action:@selector(restartClick:) forControlEvents:UIControlEventTouchUpInside];
  60. [self.view addSubview:btnFirst];
  61. UIButton *btnSecond = [[UIButton alloc] init];
  62. btnSecond.frame = CGRectMake((ScreenWidth-260) / 2, 516, 260, 44);
  63. [btnSecond setImage:[[UIImage alloc] initWithContentsOfFile:[ImageBundle pathForResource:@"btn_less_normal" ofType:@"png"]] forState:UIControlStateNormal];
  64. [btnSecond addTarget:self action:@selector(backToViewController:) forControlEvents:UIControlEventTouchUpInside];
  65. [self.view addSubview:btnSecond];
  66. // 对应的label
  67. UILabel *labelFirst = [[UILabel alloc] init];
  68. labelFirst.frame = CGRectMake((ScreenWidth-72) / 2, 465, 72, 18);
  69. labelFirst.text = @"重新采集";
  70. labelFirst.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18];
  71. labelFirst.textColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1 / 1.0];
  72. [self.view addSubview:labelFirst];
  73. UILabel *labelSecond = [[UILabel alloc] init];
  74. labelSecond.frame = CGRectMake((ScreenWidth-72) / 2, 529, 72, 18);
  75. labelSecond.text = @"回到首页";
  76. labelSecond.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18];
  77. labelSecond.textColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:1 / 1.0];
  78. [self.view addSubview:labelSecond];
  79. // 设置logo,底部的位置和大小,实例化显示
  80. BDFaceLogoView* logoView = [[BDFaceLogoView alloc] initWithFrame:CGRectMake(0, (ScreenHeight-15-12), ScreenWidth, 12)];
  81. [self.view addSubview:logoView];
  82. }
  83. - (void)viewDidDisappear:(BOOL)animated {
  84. [super viewDidDisappear:animated];
  85. [[BDFaceImageShow sharedInstance] reset];
  86. }
  87. #pragma mark - Button
  88. - (IBAction)settingAction:(UIButton *)sender{
  89. // TODO
  90. BDFaceLivingConfigViewController *lvc = [[BDFaceLivingConfigViewController alloc] init];
  91. UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:lvc];
  92. navi.navigationBarHidden = true;
  93. navi.modalPresentationStyle = UIModalPresentationFullScreen;
  94. [self presentViewController:navi animated:YES completion:nil];
  95. }
  96. - (IBAction)restartClick:(UIButton *)sender{
  97. // TODO
  98. NSLog(@"点击");
  99. NSNumber *LiveMode = [[NSUserDefaults standardUserDefaults] objectForKey:@"LiveMode"];
  100. if (LiveMode.boolValue) {
  101. UIViewController* fatherViewController = self.presentingViewController;
  102. [self dismissViewControllerAnimated:YES completion:^{
  103. [[IDLFaceLivenessManager sharedInstance] reset];
  104. BDFaceLivenessViewController *lvc = [[BDFaceLivenessViewController alloc] init];
  105. BDFaceLivingConfigModel *model = [BDFaceLivingConfigModel sharedInstance];
  106. [lvc livenesswithList:model.liveActionArray order:model.isByOrder numberOfLiveness:model.numOfLiveness];
  107. lvc.modalPresentationStyle = UIModalPresentationFullScreen;
  108. [fatherViewController presentViewController:lvc animated:YES completion:nil];
  109. }];
  110. } else {
  111. UIViewController *fatherViewController = self.presentingViewController;
  112. [self dismissViewControllerAnimated:YES completion:^{
  113. [[IDLFaceDetectionManager sharedInstance] reset];
  114. BDFaceDetectionViewController* lvc = [[BDFaceDetectionViewController alloc] init];
  115. lvc.modalPresentationStyle = UIModalPresentationFullScreen;
  116. [fatherViewController presentViewController:lvc animated:YES completion:nil];
  117. }];
  118. }
  119. }
  120. - (IBAction)backToViewController:(UIButton *)sender{
  121. // TODO
  122. [self dismissViewControllerAnimated:YES completion:nil];
  123. }
  124. - (IBAction)backAction:(UIButton *)sender{
  125. // TODO
  126. [self dismissViewControllerAnimated:YES completion:nil];
  127. }
  128. @end