Created
March 2, 2012 08:10
-
-
Save yankov/1956708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'redis' | |
require 'face' | |
# fb user_id of the user that needs to be find on match.com | |
FB_UID = '[email protected]' | |
# show all profiles whith the given confidence of recognition | |
ACCURACY = 30 | |
redis = Redis.new | |
pictures = redis.hgetall("people") | |
# recognize user | |
client = Face.get_client(:api_key => FACECOM_APIKEY, :api_secret => FACECOM_APISECRET) | |
# note in fb_user you pass here YOUR fb user id, not an id of the user your are looking for | |
client.facebook_credentials = {:fb_user => YOUR_FB_USER_ID, :fb_oauth_token =>YOUR_FB_OAUTH_TOKEN} | |
#train pictures | |
response = client.faces_train(:uids => [FB_UID] ) | |
pictures.keys.each_slice(20) do |pictures_chunk| | |
response = client.faces_recognize(:urls => pictures_chunk, :uids => [FB_UID]) | |
response["photos"].each do |photo| | |
photo["tags"].each{|tag| | |
next if tag.nil? || tag['uids'].empty? | |
p "Profile found, #{pictures[photo['url']]}, confidence #{tag['uids'][0]['confidence']}" if tag['uids'][0]['confidence'].to_i > ACCURACY | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment