使用CoreImage進行人臉識別

b4c2 9年前發布 | 3K 次閱讀 Objective-C 神經網絡 NeuroSolutions

    - (BOOL)checkImageHasFace  
    {  
        BOOL hasFace = NO;  
        CIImage *begingImage = [[CIImage alloc] initWithImage:_postImage];  
        //創建CIDetector對象,options使用NSDictionary設置采用高品質還是低品質,這里使用低品質。  
        CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyLow forKey:CIDetectorAccuracy]];  
        //返回數組中包含圖片臉部特征信息  
        NSArray *faceFeatures = [detector featuresInImage:begingImage];  
        for (CIFaceFeature *faceFeature in faceFeatures) {  
            //左眼位置、右眼位置和嘴的位置  
            if (faceFeature.hasLeftEyePosition&&faceFeature.hasRightEyePosition&&faceFeature.hasMouthPosition) {  
                hasFace = YES;  
            }  
        }  
        return hasFace;  
    }  

 本文由用戶 b4c2 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!