Advertisement
Guest User

Untitled

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