2014 snapchat source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.4 KiB

  1. //
  2. // SCManagedCaptureFaceDetectionAdjustingPOIResource.h
  3. // Snapchat
  4. //
  5. // Created by Jiyang Zhu on 3/7/18.
  6. // Copyright © 2018 Snapchat, Inc. All rights reserved.
  7. //
  8. // This class is used to keep several properties for face detection and focus/exposure. It provides methods to help
  9. // FaceDetectionAutoFocusHandler and FaceDetectionAutoExposureHandler to deal with the point of interest setting events
  10. // from user taps, subject area changes, and face detection, by updating itself and return the actual point of
  11. // interest.
  12. #import <CoreGraphics/CoreGraphics.h>
  13. #import <Foundation/Foundation.h>
  14. typedef NS_ENUM(NSInteger, SCManagedCaptureFaceDetectionAdjustingPOIMode) {
  15. SCManagedCaptureFaceDetectionAdjustingPOIModeNone = 0,
  16. SCManagedCaptureFaceDetectionAdjustingPOIModeFixedOnPointWithFace,
  17. SCManagedCaptureFaceDetectionAdjustingPOIModeFixedOnPointWithoutFace,
  18. };
  19. @interface SCManagedCaptureFaceDetectionAdjustingPOIResource : NSObject
  20. @property (nonatomic, assign) CGPoint pointOfInterest;
  21. @property (nonatomic, strong) NSDictionary<NSNumber *, NSValue *> *faceBoundsByFaceID;
  22. @property (nonatomic, assign) SCManagedCaptureFaceDetectionAdjustingPOIMode adjustingPOIMode;
  23. @property (nonatomic, assign) BOOL shouldTargetOnFaceAutomatically;
  24. @property (nonatomic, strong) NSNumber *targetingFaceID;
  25. @property (nonatomic, assign) CGRect targetingFaceBounds;
  26. - (instancetype)initWithDefaultPointOfInterest:(CGPoint)pointOfInterest
  27. shouldTargetOnFaceAutomatically:(BOOL)shouldTargetOnFaceAutomatically;
  28. - (void)reset;
  29. /**
  30. Update SCManagedCaptureFaceDetectionAdjustingPOIResource when a new POI adjustment comes. It will find the face that
  31. the proposedPoint belongs to, return the center of the face, if the adjustingPOIMode and fromUser meets the
  32. requirements.
  33. @param proposedPoint
  34. The point of interest that upper level wants to set.
  35. @param fromUser
  36. Whether the setting is from user's tap or not.
  37. @return
  38. The actual point of interest that should be applied.
  39. */
  40. - (CGPoint)updateWithNewProposedPointOfInterest:(CGPoint)proposedPoint fromUser:(BOOL)fromUser;
  41. /**
  42. Update SCManagedCaptureFaceDetectionAdjustingPOIResource when new detected face bounds comes.
  43. @param faceBoundsByFaceID
  44. A dictionary. Key: FaceID as NSNumber. Value: FaceBounds as CGRect.
  45. @return
  46. The actual point of interest that should be applied.
  47. */
  48. - (CGPoint)updateWithNewDetectedFaceBounds:(NSDictionary<NSNumber *, NSValue *> *)faceBoundsByFaceID;
  49. @end