获取iOS照片库中包含人脸的所有照片阵列

获取iOS照片库中包含人脸的所有照片阵列,ios,objective-c,core-image,alassetslibrary,photo-gallery,Ios,Objective C,Core Image,Alassetslibrary,Photo Gallery,我试图浏览iOS设备照片库中的每张照片,包括相机卷、相册等 从那里,我想使用核心图像检查照片中是否有人脸,如果有,将其添加到名为detectedFaceArray的数组中 我知道我必须使用AlassetLibrary枚举所有组,然后是照片库中的照片,但我不知道如何在每张照片上实现核心图像。我正在使用的代码就是这个问题中询问的代码: 或 我甚至不确定这是否是正确的代码使用,所以任何帮助将不胜感激。我已经阅读了库和核心图像文档,但仍然不知道如何才能做到这一点 有什么建议吗?谢谢大家! 我完全不知道

我试图浏览iOS设备照片库中的每张照片,包括相机卷、相册等

从那里,我想使用核心图像检查照片中是否有人脸,如果有,将其添加到名为detectedFaceArray的数组中

我知道我必须使用AlassetLibrary枚举所有组,然后是照片库中的照片,但我不知道如何在每张照片上实现核心图像。我正在使用的代码就是这个问题中询问的代码:

我甚至不确定这是否是正确的代码使用,所以任何帮助将不胜感激。我已经阅读了和核心图像文档,但仍然不知道如何才能做到这一点


有什么建议吗?谢谢大家!

我完全不知道如何从图像中检测人脸。但是你可以阅读并下载OpenCV来为那些仍然在寻找问题答案的人做这件事。我使用这段代码来枚举资产并保存上面有面的资产

[self.library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
                [group setAssetsFilter:[ALAssetsFilter allPhotos]];
                [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
                    if(result && self.galleryAssets.count <= 20) {
                       CIImage *ciImage = [CIImage imageWithCGImage:result.thumbnail];
                        NSNumber *orientation = [NSNumber numberWithInt:[[UIImage imageWithCIImage:ciImage] imageOrientation]+1];
                        NSDictionary *fOptions = [NSDictionary dictionaryWithObject:orientation forKey: CIDetectorImageOrientation];
                        NSArray *features = [detector featuresInImage:ciImage options:fOptions];

                        if(features.count != 0) {
                            [self.galleryAssets addObject:result];
                        }
                        *stop = NO;
                    } else {
                        *stop = YES; return;
                    }
                }];

                dispatch_async(dispatch_get_main_queue(), ^{
                    if(self.galleryAssets.count == 0) {
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Photos" message:@"You have no photos in your gallery." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                        [alert show];
                    } 
                });
            } failureBlock:nil];
[self.library enumerateGroupsWithTypes:alassetgroupsavedphotos usingBlock:^(alassetgroup*group,BOOL*stop){
[group SetAssetFilter:[AlasSetFilter allPhotos]];
[组enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset*结果、NSU整数索引、布尔*停止){

如果(result&&self.galleryAssets.count)我知道如何使用核心映像来完成它,我只是不知道将代码放在哪里来完成它…?感谢链接though@falky你有没有想过?我需要做点什么similar@michael不,我没有道歉
[self.library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
                [group setAssetsFilter:[ALAssetsFilter allPhotos]];
                [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
                    if(result && self.galleryAssets.count <= 20) {
                       CIImage *ciImage = [CIImage imageWithCGImage:result.thumbnail];
                        NSNumber *orientation = [NSNumber numberWithInt:[[UIImage imageWithCIImage:ciImage] imageOrientation]+1];
                        NSDictionary *fOptions = [NSDictionary dictionaryWithObject:orientation forKey: CIDetectorImageOrientation];
                        NSArray *features = [detector featuresInImage:ciImage options:fOptions];

                        if(features.count != 0) {
                            [self.galleryAssets addObject:result];
                        }
                        *stop = NO;
                    } else {
                        *stop = YES; return;
                    }
                }];

                dispatch_async(dispatch_get_main_queue(), ^{
                    if(self.galleryAssets.count == 0) {
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Photos" message:@"You have no photos in your gallery." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                        [alert show];
                    } 
                });
            } failureBlock:nil];