2013-04-02 1 views

답변

1
for (CIFaceFeature *ff in features) { 

    // find the correct position for the square layer within the previewLayer 

    // the feature box originates in the bottom left of the video frame. 

    // (Bottom right if mirroring is turned on) 

    CGRect faceRect = [ff bounds]; 



    // flip preview width and height 

    CGFloat temp = faceRect.size.width; 

    faceRect.size.width = faceRect.size.height; 

    faceRect.size.height = temp; 

    temp = faceRect.origin.x; 

    faceRect.origin.x = faceRect.origin.y; 

    faceRect.origin.y = temp; 

    // scale coordinates so they fit in the preview box, which may be scaled 

    CGFloat widthScaleBy = previewBox.size.width/clap.size.height; 

    CGFloat heightScaleBy = previewBox.size.height/clap.size.width; 

    faceRect.size.width *= widthScaleBy; 

    faceRect.size.height *= heightScaleBy; 

    faceRect.origin.x *= widthScaleBy; 

    faceRect.origin.y *= heightScaleBy; 



    if (isMirrored) 

     faceRect = CGRectOffset(faceRect, previewBox.origin.x + previewBox.size.width - faceRect.size.width - (faceRect.origin.x * 2), previewBox.origin.y); 

    else 

     faceRect = CGRectOffset(faceRect, previewBox.origin.x, previewBox.origin.y); 

당신은 얼굴 RECT를 얻을 수 있지만 유는이 유는 나중에 각 위치

-(void)markFaces:(CIImage *)image 
{ 
    // draw a CI image with the previously loaded face detection picture 
    @autoreleasepool { 
     CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace 
                context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracy forKey:CIDetectorAccuracyHigh]]; 

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

     NSLog(@"The Address Of CIImage In: %p %s",image,__FUNCTION__); 
     NSLog(@"Array Count %d",[features count]); 


     NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; 


     if([features count]==0) 
     { 
      //No image is present 
     } 
     else 
     { 
      for(CIFaceFeature* faceFeature in features) 
      { 

       if(faceFeature.hasMouthPosition) 
       { 
        // Your code based on the mouth position 
       } 


       if (faceFeature.hasLeftEyePosition) { 
       // Write your code Note: points are mirrored point so u need to take care of that 

       } 
       if (faceFeature.hasRightEyePosition) { 
       // Write your code Note: points are mirrored point so u need to take care of that 

       } 

       } 
} 
} 
+0

답장을 보내 주셔서 감사합니다. 나는 시험을주고 당신에게 알릴 것이다! – 3DNewbie

+0

@ 3DNewbie 항상 환영합니다 – Spynet

+0

눈을 감지했습니다. 하지만 내 문제는 눈 위에 오버레이 이미지를 만드는 것입니다. 그것을 만드는 방법? 즉 원 또는 사각형이 Instaed되어 있습니다. 눈 위에 오버레이 이미지가 필요합니다. – 3DNewbie

0

애플에서 iOS 5를 얻을하는 데 도움이 될 것입니다

이미지의 눈을 미세 필요 내부적으로이 기능을 제공합니다.

같은 관련이 애플 문서를 참조하십시오 : 당신은 필요에 따라이 예에서

http://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/CoreImaging/ci_detect_faces/ci_detect_faces.html

, 그들은, 같은 일을하는 - 얼굴과 눈을 감지.

희망이 있으면 도움이 될 것입니다.

* 또한 link1link2을 확인하면 감지 된 영역에 대한 이미지 오버레이가 포함됩니다. 나는 이것이 당신이 찾고있는 것이라고 생각합니다.

+0

입니다. 내 의도는 눈 위치에 오버레이 이미지를 배치하는 것입니다. 그것을하는 방법? 즉 원 또는 사각형이 Instaed되어 있습니다. 눈 위에 오버레이 이미지가 필요합니다. – 3DNewbie

+0

다른 두 개의 링크에서 이미지를 배치하는 위치를 찾을 수 있습니다. – Mrunal

+0

아니요 다른 두 개의 링크가 이미지 위에 원을 그리며 눈 위에 원 이미지를 배치하지 않습니다. 날 안내해 주실 래요! – 3DNewbie