facer 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/facer.rb +1 -1
  2. data/lib/facer/faces.rb +32 -8
  3. metadata +4 -4
@@ -23,5 +23,5 @@ require "facer/faces.rb"
23
23
  # Copyright:: Copyright (c) 2011 Giano
24
24
  # License:: Distributes under the same terms as Ruby
25
25
  module Facer
26
- VERSION = "0.0.6"
26
+ VERSION = "0.0.7"
27
27
  end
@@ -72,14 +72,16 @@ module Facer
72
72
 
73
73
  # Associace many images to a user. I assume every images contains a single face
74
74
  def associate_multi(images,user,namespace, force_train = false, detector = :Normal)
75
- success=true
75
+ out=[]
76
76
  images.each do |image|
77
- success &= associate(image,user,namespace,false,detector)
77
+ resp=associate(image,user,namespace,false,detector) || {"tid" => nil, "infos" => nil}
78
+ resp["image"]=image
79
+ out += resp
78
80
  end
79
- if(success && force_train)
80
- return train(user,namespace)
81
+ if(force_train)
82
+ train(user,namespace)
81
83
  end
82
- return success
84
+ return out
83
85
  end
84
86
 
85
87
  # Associace a face image to a user. I assume the image contains a single face
@@ -92,13 +94,35 @@ module Facer
92
94
  ret=@linker.call("tags","save",{"tids" => tid, "uid" => "#{user}@#{namespace}"})
93
95
  if(ret["status"].to_sym == :success)
94
96
  if(force_train)
95
- return train(user,namespace)
97
+ train(user,namespace)
96
98
  end
97
- return true
99
+ return {"tid" => ret["saved_tags"][0]["tid"], "infos" => tag}
98
100
  end
99
101
  end
100
102
  end
101
- return false
103
+ return nil
104
+ end
105
+
106
+ def deassociate(tid,user,namespace, force_train = false)
107
+ ret=@linker.call("tags","remove",{"tids" => tid})
108
+ if(ret["status"].to_sym == :success)
109
+ if(force_train)
110
+ train(user,namespace)
111
+ end
112
+ return true
113
+ end
114
+ return false
115
+ end
116
+
117
+ def deassociate_multi(tids,user,namespace, force_train = false)
118
+ out=[]
119
+ tids.each do |tid|
120
+ out += {"tid" => tid, "success" => deassociate(tid,user,namespace,false,detector)}
121
+ end
122
+ if(force_train)
123
+ train(user,namespace)
124
+ end
125
+ return out
102
126
  end
103
127
 
104
128
  private
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stefano Valicchia
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-11 00:00:00 +01:00
18
+ date: 2011-01-16 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency