ios人脸识别
来源:互联网 发布:网络视频下载器哪个好 编辑:程序博客网 时间:2024/05/16 12:16
- (void)viewDidLoad
{
[superviewDidLoad];
UIImage *image = [UIImageimageNamed:@"faces1.png"];
_inputImageView.image = image;
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
}
- (void)dealloc {
[_inputImageView release];
[_outputImageView release];
[_button release];
[super dealloc];
}
- (IBAction)detect:(id)sender {
CIContext *context = [CIContextcontextWithOptions:nil];
UIImage *imageInput = [_inputImageViewimage];
CIImage *image = [CIImageimageWithCGImage:imageInput.CGImage];
//设置识别参数
NSDictionary *param = [NSDictionarydictionaryWithObject:CIDetectorAccuracyHigh
forKey:CIDetectorAccuracy];
//声明一个CIDetector,并设定识别类型
CIDetector* faceDetector = [CIDetectordetectorOfType:CIDetectorTypeFace
context:context options:param];
//取得识别结果
NSArray *detectResult = [faceDetector featuresInImage:image];
UIView *resultView = [[UIViewalloc] initWithFrame:_inputImageView.frame];
[self.view addSubview:resultView];
for(CIFaceFeature* faceFeaturein detectResult) {
//脸部
UIView* faceView = [[UIViewalloc] initWithFrame:faceFeature.bounds];
faceView.layer.borderWidth =1;
faceView.layer.borderColor = [UIColororangeColor].CGColor;
[resultView addSubview:faceView];
[faceView release];
//左眼
if (faceFeature.hasLeftEyePosition) {
UIView* leftEyeView = [[UIViewalloc] initWithFrame:CGRectMake(0,0, 5, 5)];
[leftEyeView setCenter:faceFeature.leftEyePosition];
leftEyeView.layer.borderWidth =1;
leftEyeView.layer.borderColor = [UIColorredColor].CGColor;
[resultView addSubview:leftEyeView];
[leftEyeView release];
}
//右眼
if (faceFeature.hasRightEyePosition) {
UIView* rightEyeView = [[UIViewalloc] initWithFrame:CGRectMake(0,0, 5, 5)];
[rightEyeView setCenter:faceFeature.rightEyePosition];
rightEyeView.layer.borderWidth =1;
rightEyeView.layer.borderColor = [UIColorredColor].CGColor;
[resultView addSubview:rightEyeView];
[rightEyeView release];
}
//嘴巴
if (faceFeature.hasMouthPosition) {
UIView* mouthView = [[UIViewalloc] initWithFrame:CGRectMake(0,0, 10, 5)];
[mouthView setCenter:faceFeature.mouthPosition];
mouthView.layer.borderWidth =1;
mouthView.layer.borderColor = [UIColorredColor].CGColor;
[resultView addSubview:mouthView];
[mouthView release];
}
}
[resultView setTransform:CGAffineTransformMakeScale(1, -1)];
[resultView release];
if ([detectResult count] >0)
{
CIImage *faceImage = [image imageByCroppingToRect:[[detectResult objectAtIndex:0]bounds]];
UIImage *face = [UIImageimageWithCGImage:[context createCGImage:faceImagefromRect:faceImage.extent]];
self.outputImageView.image = face;
[self.buttonsetTitle:[NSString stringWithFormat:@"识别人脸数 %i",
[detectResult count]]forState:UIControlStateNormal];
}
}
@end
- ios人脸识别
- ios人脸识别
- iOS 人脸识别
- IOS人脸识别
- ios 人脸识别
- IOS人脸识别和二维码识别
- iOS实现人脸识别
- ios 人脸识别 资源
- iOS人脸识别技术
- iOS人脸识别技术
- iOS人脸识别(检测)
- 人脸识别 iOS开发
- iOS 人脸识别功能
- iOS 人脸识别(检测)
- iOS人脸识别(检测)
- iOS 照片人脸识别
- iOS 人脸识别Demo
- ios 人脸识别有关资源
- 还原数据库失败,尝试 'RestoreContainer::ValidateTargetForCreation' 时,操作系统返回了错误 '5(拒绝访问。)'
- Android开发之onClick事件的两种主要形式
- java基础学习笔记——网络编程
- #33 C. Wonderful Randomized Sum ( 思维 )
- 8-20 Android学习ing
- ios人脸识别
- IOS中的block和retain cycle (经典)
- dup and dup2的剖析
- 网站大文件(譬如:视频)上传方案及解决方式
- android屏蔽系统锁屏的办法
- AFNetworking的使用
- 7款很棒的 HTML5 视频播放器
- CentOS防火墙开放端口
- Linux下查找Webshell挂马文件记录