Get PHAssets based on "Face" metadata - ios

Using Photos in Mac users are able to tag people in photos. This data is then synced to the cloud where they can preform face searches in Photos on iOS. The type of metadata seems to be "Face". Is it possible to get all the assets associated with one of these faces? I'd like to grab all the images with a certain person in it. You are able to do it in the Photos search in iOS so my hope is that it is also open to other developers.
Does anyone have any ideas?
Thanks in advance.

Apple released an SDK for accessing Apple Photos called Photo Kit. In the documentation, you will find API access to the photos application and photos cloud. However, if you are looking for an HTTP API I do not believe one has been announced publicly.
If you only need access to is data on Photos MacOS app I would recommend digging through the SQLite photos.db located in the photos library database directory.
/Users/[yourUserName]/Pictures/Photos Library.photoslibrary/database/photos.db
I am working on a project this weekend that requires similar face data and will document my progress. Here is a sample SQLite query you can use to get all faces, photos, and corresponding person:
SELECT *, RKFace.modelId AS fId
FROM RKFace
JOIN RKMaster ON RKMaster.modelId = RKFace.imageModelId
LEFT JOIN RKFaceGroup ON RKFaceGroup.modelId = RKFace.faceGroupId
LEFT JOIN RKFaceCrop ON RKFaceCrop.faceId = RKFace.imageModelId
LEFT JOIN RKFacePrint ON RKFacePrint.faceId = RKFace.imageModelId
LEFT JOIN RKPerson ON RKPerson.modelId = RKFace.personId;
I hope this helps. :-)

There is no API for that kind of stuff on iOS at the moment.

Related

Is it possible to search for objects in Photos?

do you know if it's possible to use the Photos Framework to search for specific photo categories (auto-generated by Apple's ML) in iOS 10?
For example, I'd like to get all the photos with a car in them.
I haven't found any reference regarding this in Apple developer documentation. I have a feeling that this Photos app inbuilt feature we see in iOS10, hasn't been made public facing yet.
I did find this article covering the different categories someone found out: Photos ML categories
Hopefully, in WWDC this June we will have more access.
Kind regards,
Mukund

Can I access the pictures of the app user?

I am building a game related with the picture of the client from his album.
I need him to authorize access his album, but can I use his pictures?
For example, imagine a game of finding errors. I use one of his pictures in my app, change 7 objects, and ask him to find the changes.
Is it possible?
The user will be able to give you access to their pictures. But in terms of identifying objects in the picture and making changes to them, you will have to code in some pretty advanced image processing functionality.

Is there a way to distinguish between the user photo stream and a shared one?

I’m trying to show Photo Streams using ALAssetsLibrary, but I haven’t find a way to know if a given ALAssetsGroup is the user photo stream (the one named “My Photo Stream”) or a shared one (arbitrary named by the user). Neither I have find how to know if the user created the shared photo stream or it was shared with him/her.
The only “clues” I have been able to find is that “My Photo Stream” is always sorted by date, but other streams might also be. The editable property is always NO for the streams I have tested with (in Photos.app you can edit shared photo streams, but not “My Photo Stream”, which is automatically managed). valueForProperty: doesn’t provided that many keys, and no key seems to provide much information (the URL looks like any other assets library URL).
I will not want to use the name (“My Photo Stream”) because our international users might have very different names, and Apple might have change it at any moment.
I also have noticed that it is always the first photo stream to be returned when enumerating the ALAssetsGroup from a library, but I haven’t found any documented evidence of this (it seems that the groups are returned in the order they were added). I have tested disabling and enabling the user photo stream from the Preferences and it keeps appearing the first… but only if it is enabled.
Other idea I haven’t tested is using + disableSharedPhotoStreamsSupport after I have enumerated the groups once, and then enumerate again, since the only photo stream left will be the user’s. But there is no + enableSharedPhotoStreamsSupport, so I will lose all the possible notification for those shared streams “forever”.
Does someone have some insight? Have someone managed to properly use the shared photo streams?

iOS Image search on the web

I am developing the functionality of letting the user search the internet for images through any query.
There are services/APIs like Google's (I read that it is deprecated), Yahoo and Bing etc. I want to know, is there any FREE services/APIs/frameworks/libraries for iOS to search for images against any query?
We can fetch the thumbnails against the results URL and populate a grid-view to show the thumbnails. Then download the actual image in the App once the user clicks on a particular image. Is there any such service that is free?
Thanks
you can use flickr, in the Ray Wenderlich site you have a good tutorial of how to use it. About the services you mentions I don't know if the has a public (free) API

How to filter spotlight tracks in soundcloud API

I'm currently working on an iOS app using the Soundcloud API, and it's working great so far. Something that I haven't been able to figure out, however, is how to construct an URL in order to get only the tracks pinned as spotlight tracks from a certain user.
For example, let's say I'm using the following URL:
http://api.soundcloud.com/users/username/tracks.json?client_id=mySecretId
I've carefully gone through the API documentation at developers.soundcloud.com/docs/api/, but it feels like there's a subresource I'm missing.
I'm aware that I can use the created_at filter to show the most recently added tracks, but if I'm understanding the platform correctly, a spotlight track does not necessarily have to be one of the most recently added?
I would be ever so grateful for feedback on this subject!
Cheers
/Anders
Spotlight is not available via public API, sorry.

Resources