HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 如何在面上的两个点集之间添加度量,以将其用于数字图像中的对象检测以进行面部识别大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在面上的两个点集之间添加度量以将其用于数字图像中的对象检测,我们将其限制为二维,如下所示

我可以使用以下方法识别如下图所示的脸部特征:

-(void)markFaces:(UIImageView *)facePicture
 {
     // draw a CI image with the prevIoUsly loaded face detection picture
     CIImage* image = [CIImage imageWithCGImage:facePicture.image.CGImage];

     // create a face detector - since speed is not an issue we'll use a high accuracy
     // detector
     CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                          context:nil options:     [NSDictionary DictionaryWithObject:CIDetectOraccuracyHigh forKey:CIDetectOraccuracy]];

     // create an array containing all the detected faces from the detector
     NSArray* features = [detector featuresInImage:image];

     // we'll iterate through every detected face.  CIFaceFeature provides us
     // with the width for the entire face,and the coordinates of each eye
     // and the mouth if Detected.  Also provided are BOOL's for the eye's and
     // mouth so we can @R_607_10943@k if they already exist.
     for(CIFaceFeature* faceFeature in features)
     {
         // get the width of the face
         CGFloat faceWidth = faceFeature.bounds.size.width;

         // create a UIView using the bounds of the face
         UIView* faceView = [[UIView alloc] initWithFrame:faceFeature.bounds];

         // add a border around the newly created UIView
         faceView.layer.borderWidth = 1;
         faceView.layer.borderColor = [[UIColor redColor] CGColor];

         // add the new view to create a Box around the face
    [self.view addSubview:faceView];

         if(faceFeature.hasLeftEyePosition)
         {
             // create a UIView with a size based on the width of the face
             UIView* leftEyeView = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.leftEyePosition.x-faceWidth*0.15,faceFeature.leftEyePosition.y-faceWidth*0.15,faceWidth*0.3,faceWidth*0.3)];
             // change the BACkground color of the eye view
             [leftEyeView setBACkgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]];
             // set the position of the leftEyeView based on the face
             [leftEyeView setCenter:faceFeature.leftEyePosition];

           // round the corners
             leftEyeView.layer.cornerRadius = faceWidth*0.15;
             // add the view to the window
             [self.view addSubview:leftEyeView];
         }

         if(faceFeature.hasRightEyePosition)
         {
             // create a UIView with a size based on the width of the face
             UIView* leftEye = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.rightEyePosition.x-faceWidth*0.15,faceFeature.rightEyePosition.y-faceWidth*0.15,faceWidth*0.3)];
             // change the BACkground color of the eye view
             [leftEye setBACkgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]];
             // set the position of the rightEyeView based on the face
             [leftEye setCenter:faceFeature.rightEyePosition];
             // round the corners
             leftEye.layer.cornerRadius = faceWidth*0.15;
             // add the new view to the window
             [self.view addSubview:leftEye];
         }     

         if(faceFeature.hasMouthPosition)
         {
             // create a UIView with a size based on the width of the face
             UIView* mouth = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.mouthPosition.x-faceWidth*0.2,faceFeature.mouthPosition.y-faceWidth*0.2,faceWidth*0.4,faceWidth*0.4)];
             // change the BACkground color for the mouth to green
             [mouth setBACkgroundColor:[[UIColor greenColor] colorWithAlphaComponent:0.3]];

             // set the position of the mouthView based on the face
             [mouth setCenter:faceFeature.mouthPosition];

              // round the corners
             mouth.layer.cornerRadius = faceWidth*0.2;

             // add the new view to the window
             [self.view addSubview:mouth];
              }
          }
      }

      -(void)faceDetector
      {
          // Load the picture for face detection
          //UIImageView* image = [[UIImageView alloc] initWithImage:[UIImage imagenamed:@"facedetectionpic.jpg"]];
          UIImageView* image = [[UIImageView alloc] initWithImage:[UIImage imagenamed:@"timthumb.png"]];
          // Draw the face detection image
          [self.view addSubview:image];

          // Execute the method used to markFaces in BACkground
          [self performSELEctorInBACkground:@SELEctor(markFaces:) withObject:image];

          // flip image on y-axis to match coordinate system used by core image
          [image setTransform:CGAffineTransformMakeScale(1,-1)];

          // flip the entire window to make everything right side up
          [self.view setTransform:CGAffineTransformMakeScale(1,-1)];


      }

现在我想在上传数据库之前添加点来定位眼睛,鼻子等的参.稍后,可以将这些图像与基于这些度量点位置的现有图像进行比较,如下所示

ios – 如何在面上的两个点集之间添加度量,以将其用于数字图像中的对象检测以进行面部识别

ios – 如何在面上的两个点集之间添加度量,以将其用于数字图像中的对象检测以进行面部识别

我已经提到This Link但是无法实现这个..如果有人知道这个请建议我

谢谢

解决方法

我担心这不是直截了当的.查看文档CIDetector不包括其他面部标志的检测器.您需要在一组手动注释的图像上训练自己的图像.有几个开源项目可以做到这一点.一个非常好的(准确和快速)是dlib: http://blog.dlib.net/2014/08/real-time-face-pose-estimation.html

大佬总结

以上是大佬教程为你收集整理的ios – 如何在面上的两个点集之间添加度量,以将其用于数字图像中的对象检测以进行面部识别全部内容,希望文章能够帮你解决ios – 如何在面上的两个点集之间添加度量,以将其用于数字图像中的对象检测以进行面部识别所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。