问题
Apple's Photo app has facial recognition capabilities. I would like to know if an API exists to access the associated data for photos which have been classified by the app.
(tagged with API, not sure which tags.)
Thanks!
回答1:
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. :-)
来源:https://stackoverflow.com/questions/42869608/how-to-access-people-album-used-in-apples-photos-app