利用CIDetector来人脸识别

利用CIDetector来人脸识别,第1张

概述利用CIDetector来人脸识别

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

利用CIDetector来人脸识别 添加图片: UIImage* image = [UIImage imagenamed:@"face.jpg"]; UIImageVIEw *testimage = [[UIImageVIEw alloc] initWithImage: image]; [testimage settransform:CGAffinetransformMakeScale(1,-1)]; [[[UIApplication sharedApplication] delegate].window settransform:      CGAffinetransformMakeScale(1,-1)];  [testimage setFrame:CGRectMake(, ,testimage.image.size.wIDth,                                    testimage.image.size.height)]; [self.vIEw addSubvIEw:testimage]; 识别图片: CIImage* ciimage = [CIImage imageWithCGImage:image.CGImage]; NSDictionary* opts = [NSDictionary dictionaryWithObject:                           CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]; CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace                                               context:nil options:opts]; NSArray* features = [detector featuresInImage:ciimage]; 标出脸部,眼睛和嘴: for (CIFaceFeature *faceFeature in features){ } // 标出脸部 CGfloat faceWIDth = faceFeature.bounds.size.wIDth; UIVIEw* faceVIEw = [[UIVIEw alloc] initWithFrame:faceFeature.bounds]; faceVIEw.layer.borderWIDth = 1; faceVIEw.layer.bordercolor = [[UIcolor redcolor] CGcolor]; [self.vIEw addSubvIEw:faceVIEw]; // 标出左眼 if(faceFeature.hasleftEyeposition) {       UIVIEw* leftEyeVIEw = [[UIVIEw alloc] initWithFrame:                                    CGRectMake(faceFeature.leftEyeposition.x-faceWIDth*0.15,
                                              faceFeature.leftEyeposition.y-faceWIDth*0.15,faceWIDth*0.3,faceWIDth*0.3)];      [leftEyeVIEw setBackgroundcolor:[[UIcolor bluecolor] colorWithAlphaComponent:0.3]];      [leftEyeVIEw setCenter:faceFeature.leftEyeposition];      leftEyeVIEw.layer.cornerRadius = faceWIDth*0.15;      [self.vIEw  addSubvIEw:leftEyeVIEw]; } // 标出右眼 if(faceFeature.hasRightEyeposition) {        UIVIEw* leftEye = [[UIVIEw alloc] initWithFrame:                                CGRectMake(faceFeature.rightEyeposition.x-faceWIDth*0.15,                                           faceFeature.rightEyeposition.y-faceWIDth*0.15,faceWIDth*0.3)];        [leftEye setBackgroundcolor:[[UIcolor bluecolor] colorWithAlphaComponent:0.3]];        [leftEye setCenter:faceFeature.rightEyeposition];        leftEye.layer.cornerRadius = faceWIDth*0.15;        [self.vIEw  addSubvIEw:leftEye]; } // 标出嘴部 if(faceFeature.hasMouthposition) {     UIVIEw* mouth = [[UIVIEw alloc] initWithFrame:                              CGRectMake(faceFeature.mouthposition.x-faceWIDth*0.2,
                                        faceFeature.mouthposition.y-faceWIDth*0.2,faceWIDth*0.4,faceWIDth*0.4)];      [mouth setBackgroundcolor:[[UIcolor greencolor] colorWithAlphaComponent:0.3]];       [mouth setCenter:faceFeature.mouthposition];       mouth.layer.cornerRadius = faceWIDth*0.2;       [self.vIEw  addSubvIEw:mouth];  }
code

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的利用CIDetector来人脸识别全部内容,希望文章能够帮你解决利用CIDetector来人脸识别所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1106308.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存