BDFaceSuccessViewController.m 6.6 KB

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