MGFaceModelArray.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // MGFaceModelArray.m
  3. // LandMask
  4. //
  5. // Created by 张英堂 on 16/8/17.
  6. // Copyright © 2016年 megvii. All rights reserved.
  7. //
  8. #import "MGFaceModelArray.h"
  9. @implementation MGFaceModelArray
  10. - (instancetype)init
  11. {
  12. self = [super init];
  13. if (self) {
  14. self.timeUsed = 0;
  15. self.detectRect = CGRectZero;
  16. }
  17. return self;
  18. }
  19. - (void)addModel:(MGFaceInfo *)model{
  20. [self.faceArray addObject:model];
  21. }
  22. - (MGFaceInfo *)modelWithIndex:(NSUInteger)index{
  23. MGFaceInfo *model = [self.faceArray objectAtIndex:index];
  24. return model;
  25. }
  26. -(NSMutableArray<MGFaceInfo *> *)faceArray{
  27. if (!_faceArray) {
  28. _faceArray = [NSMutableArray arrayWithCapacity:5];
  29. }
  30. return _faceArray;
  31. }
  32. -(NSUInteger)count{
  33. return self.faceArray.count;
  34. }
  35. - (NSString *)getDebugString{
  36. NSMutableString *tempString = [NSMutableString string];
  37. [tempString appendFormat:@"%s:%.2f ms", "关键点" ,self.timeUsed];
  38. [tempString appendFormat:@"\n%s:%.2f ms", "3D角度" ,self.AttributeTimeUsed];
  39. NSMutableString *conficeString = [NSMutableString string];
  40. if (self.count >= 1 ) {
  41. MGFaceInfo *model = [self modelWithIndex:0];
  42. [conficeString appendFormat:@"\n%s:%.2f", "质量", model.confidence];
  43. if (self.self.getFaceInfo) {
  44. [conficeString appendFormat:@"\n嘴巴:%zi", model.mouseStatus];
  45. [conficeString appendFormat:@"\n年龄:%.2f", model.age];
  46. [conficeString appendFormat:@"\n性别:%@", model.gender == 0 ? @"女":@"男"];
  47. }
  48. }
  49. [tempString appendString:conficeString];
  50. return tempString;
  51. }
  52. @end