Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function search(&$api, $uids)
- 02 {
- 03 //obtain list of photos to search in
- 04 $photoUrls = getPhotoUrls();
- 05 $urls = array();
- 06 $count = 0;
- 07 foreach ($photoUrls as $photoUrl)
- 08 {
- 09 //max photos per recognition call is 30, so break photos to groups if needed
- 10 $urls[] = $photoUrl;
- 11 $count++;
- 12 if (($count % 30) == 0 || $count == count($photoUrls))
- 13 {
- 14 $response = $api->faces_recognize($urls, $uids);
- 15 foreach ($response->photos as $photo)
- 16 {
- 17 //skip empty tags and errors
- 18 if (empty($photo->tags))
- 19 continue;
- 20 $url = $photo->url;
- 21 //echo all found tags
- 22 foreach ($photo->tags as $tag)
- 23 {
- 24 if (!empty($tag->uids))
- 25 {
- 26 //only interested in highest score for this tag
- 27 $uid = $tag->uids[0]->uid;
- 28 $conf = $tag->uids[0]->confidence;
- 29 //only print if confidence is higher than recommended threshold
- 30 if ($conf >= $tag->threshold)
- 31 echo "$uid was found in url $url ($conf % confidence)n";
- 32 }
- 33 }
- 34 }
- 35 $urls = array();
- 36 }
- 37 }
- 38 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement