我可以使用以下方法识别如下图所示的脸部特征:
-(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 check 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)]; }
现在我想在上传到数据库之前添加点来定位眼睛,鼻子等的参考.稍后,可以将这些图像与基于这些度量点位置的现有图像进行比较,如下所示
我已经提到This Link但是无法实现这个..如果有人知道这个请建议我
谢谢
解决方法 我担心这不是直截了当的.查看文档CIDetector不包括其他面部标志的检测器.您需要在一组手动注释的图像上训练自己的图像.有几个开源项目可以做到这一点.一个非常好的(准确和快速)是dlib: http://blog.dlib.net/2014/08/real-time-face-pose-estimation.html 总结以上是内存溢出为你收集整理的ios – 如何在面上的两个点集之间添加度量,以将其用于数字图像中的对象检测以进行面部识别全部内容,希望文章能够帮你解决ios – 如何在面上的两个点集之间添加度量,以将其用于数字图像中的对象检测以进行面部识别所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)