pub struct CIFaceFeature { /* private fields */ }CIFeature only.Expand description
Information about a face detected in a still or video image.
Note: In macOS 10.13, iOS 11, and tvOS 11 or later, the Vision framework replaces this class for identifying and analyzing image features. See
VNDetectFaceRectanglesRequest. See <doc ://com.apple.documentation/documentation/vision/vndetectfacerectanglesrequest>)
The properties of a CIFaceFeature object provide information about the face’s eyes and mouth.
A face object in a video can also have properties that track its location over time, tracking ID and frame count.
See also Apple’s documentation
Implementations§
Source§impl CIFaceFeature
impl CIFaceFeature
Sourcepub unsafe fn bounds(&self) -> CGRect
Available on crate feature objc2-core-foundation only.
pub unsafe fn bounds(&self) -> CGRect
objc2-core-foundation only.A rectangle indicating the position and extent of the face feature in image coordinates.
Sourcepub unsafe fn hasLeftEyePosition(&self) -> bool
pub unsafe fn hasLeftEyePosition(&self) -> bool
A Boolean value that indicates whether the detector found the face’s left eye.
Sourcepub unsafe fn leftEyePosition(&self) -> CGPoint
Available on crate feature objc2-core-foundation only.
pub unsafe fn leftEyePosition(&self) -> CGPoint
objc2-core-foundation only.The image coordinate of the center of the left eye.
Note: The left eye is on the left side of the face from the observer’s perspective. It is not the left eye from the subject’s perspective.
Sourcepub unsafe fn hasRightEyePosition(&self) -> bool
pub unsafe fn hasRightEyePosition(&self) -> bool
A Boolean value that indicates whether the detector found the face’s right eye.
Sourcepub unsafe fn rightEyePosition(&self) -> CGPoint
Available on crate feature objc2-core-foundation only.
pub unsafe fn rightEyePosition(&self) -> CGPoint
objc2-core-foundation only.The image coordinate of the center of the right eye.
Note: The right eye is on the right side of the face from the observer’s perspective. It is not the right eye from the subject’s perspective.
Sourcepub unsafe fn hasMouthPosition(&self) -> bool
pub unsafe fn hasMouthPosition(&self) -> bool
A Boolean value that indicates whether the detector found the face’s mouth.
Sourcepub unsafe fn mouthPosition(&self) -> CGPoint
Available on crate feature objc2-core-foundation only.
pub unsafe fn mouthPosition(&self) -> CGPoint
objc2-core-foundation only.The image coordinate of the center of the mouth.
Sourcepub unsafe fn hasTrackingID(&self) -> bool
pub unsafe fn hasTrackingID(&self) -> bool
A Boolean value that indicates whether the face object has a tracking ID.
Sourcepub unsafe fn trackingID(&self) -> c_int
pub unsafe fn trackingID(&self) -> c_int
The tracking identifier of the face object.
Core Image provides a tracking identifier for faces it detects in a video stream, which you can use to identify when a CIFaceFeature objects detected in one video frame is the same face detected in a previous video frame.
This identifier persists only as long as a face is in the frame and is not associated with a specific face. In other words, if a face moves out of the video frame and comes back into the frame later, another ID is assigned. (Core Image detects faces, but does not recognize specific faces.)
Sourcepub unsafe fn hasTrackingFrameCount(&self) -> bool
pub unsafe fn hasTrackingFrameCount(&self) -> bool
A Boolean value that indicates the face object has a tracking frame count.
Sourcepub unsafe fn trackingFrameCount(&self) -> c_int
pub unsafe fn trackingFrameCount(&self) -> c_int
The tracking frame count of the face.
Sourcepub unsafe fn hasFaceAngle(&self) -> bool
pub unsafe fn hasFaceAngle(&self) -> bool
A Boolean value that indicates whether information about face rotation is available.
Sourcepub unsafe fn faceAngle(&self) -> c_float
pub unsafe fn faceAngle(&self) -> c_float
The rotation of the face.
Rotation is measured counterclockwise in degrees, with zero indicating that a line drawn between the eyes is horizontal relative to the image orientation.
Sourcepub unsafe fn hasSmile(&self) -> bool
pub unsafe fn hasSmile(&self) -> bool
A Boolean value that indicates whether a smile is detected in the face.
To detect smiles, /CIDetector/featuresInImage:options: needs to be called with the CIDetectorSmile option set to true.
Sourcepub unsafe fn leftEyeClosed(&self) -> bool
pub unsafe fn leftEyeClosed(&self) -> bool
A Boolean value that indicates whether a closed left eye is detected in the face.
To detect closed eyes, /CIDetector/featuresInImage:options: needs to be called with the CIDetectorEyeBlink option set to true.
Sourcepub unsafe fn rightEyeClosed(&self) -> bool
pub unsafe fn rightEyeClosed(&self) -> bool
A Boolean value that indicates whether a closed right eye is detected in the face.
To detect closed eyes, /CIDetector/featuresInImage:options: needs to be called with the CIDetectorEyeBlink option set to true.
Methods from Deref<Target = CIFeature>§
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for CIFaceFeature
impl AsRef<AnyObject> for CIFaceFeature
Source§impl AsRef<CIFaceFeature> for CIFaceFeature
impl AsRef<CIFaceFeature> for CIFaceFeature
Source§impl AsRef<CIFeature> for CIFaceFeature
impl AsRef<CIFeature> for CIFaceFeature
Source§impl AsRef<NSObject> for CIFaceFeature
impl AsRef<NSObject> for CIFaceFeature
Source§impl Borrow<AnyObject> for CIFaceFeature
impl Borrow<AnyObject> for CIFaceFeature
Source§impl Borrow<CIFeature> for CIFaceFeature
impl Borrow<CIFeature> for CIFaceFeature
Source§impl Borrow<NSObject> for CIFaceFeature
impl Borrow<NSObject> for CIFaceFeature
Source§impl ClassType for CIFaceFeature
impl ClassType for CIFaceFeature
Source§const NAME: &'static str = "CIFaceFeature"
const NAME: &'static str = "CIFaceFeature"
Source§type ThreadKind = <<CIFaceFeature as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<CIFaceFeature as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for CIFaceFeature
impl Debug for CIFaceFeature
Source§impl Deref for CIFaceFeature
impl Deref for CIFaceFeature
Source§impl Hash for CIFaceFeature
impl Hash for CIFaceFeature
Source§impl Message for CIFaceFeature
impl Message for CIFaceFeature
Source§impl NSObjectProtocol for CIFaceFeature
impl NSObjectProtocol for CIFaceFeature
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref