カメラロール、アルバムなど、iOS デバイスのフォト ライブラリにあるすべての写真を調べようとしています。
そこから、コア イメージを使用して写真に顔が含まれているかどうかを確認し、含まれている場合は、detectedFaceArray という配列に追加します。
ALAssetsLibraryを使用してすべてのグループを列挙し、フォト ギャラリーの写真を列挙する必要があることは理解していますが、各写真にコア イメージを実装する方法がわかりません。私が使用しているコードは、この質問で尋ねられているコードです:
また
-(void)getAllPictures
{
self.galleryImages=[[NSMutableArray alloc] init];
mutableArray =[[NSMutableArray alloc]init];
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
library = [[ALAssetsLibrary alloc] init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result != nil)
{
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto])
{
[assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];
NSURL *url= (NSURL*) [[result defaultRepresentation]url];
[library assetForURL:url
resultBlock:^(ALAsset *asset) {
[mutableArray addObject:asset];
if ([mutableArray count]==count)
{
self.galleryImages=[[NSMutableArray alloc] initWithArray:mutableArray];
}
}
failureBlock:^(NSError *error){ NSLog(@"operation was not successfull!"); } ];
}
}
};
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil) {
[group enumerateAssetsUsingBlock:assetEnumerator];
[assetGroups addObject:group];
count=[group numberOfAssets];
}
};
assetGroups = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes: ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {NSLog(@"There is an error");}];
}
これが使用する正しいコードであるかどうかさえわからないので、助けていただければ幸いです。ALAssetsLibraryと Core Image Documentationを読みましたが、どうすればよいかわかりません。
助言がありますか?ありがとうございました!