#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *aImage = [UIImage imageNamed:@"证件照.jpg"];
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, aImage.size.width, aImage.size.height)];
imageView.center = self.view.center;
imageView.layer.borderWidth = 1.0;
imageView.layer.masksToBounds = YES;
//自适应图片宽高比例
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.image = aImage;
[self.view addSubview:imageView];
CIImage* image = [CIImage imageWithCGImage:aImage.CGImage];
NSDictionary *opts = [NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh
forKey:CIDetectorAccuracy];
CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:nil
options:opts];
//得到面部数据
NSArray* features = [detector featuresInImage:image];
for (CIFaceFeature *f in features)
{
CGRect aRect = f.bounds;
aRect.origin.y = imageView.bounds.size.height - aRect.size.height - aRect.origin.y;//self.bounds.size
//给
ios开发之人脸识别(给眼睛打上马赛克)
最新推荐文章于 2024-04-16 19:13:42 发布