findaface 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f5419db2c9bb3da0a696bbe7208131b6e54949e
4
- data.tar.gz: dc135c13a976842acf4304b8a4819a5ddaa5de57
3
+ metadata.gz: 09569130164ec8180f6c898dc045d26c98696114
4
+ data.tar.gz: 5f286cd6676782c964308633cc322158e1df3ab1
5
5
  SHA512:
6
- metadata.gz: 6699a6fde264ec6ca2bfb9ab843980354b3e7dcaaf3ccfdd825710825508dea894c64f998e906e410a16adc1e7be6a86fff94231b24ec3fbd4a9ff6f4d1b6f3a
7
- data.tar.gz: 81eca8a1ec2e65d6e1d6f518d2ce73709cc9fc72ac874e082b40056041657962e1c7f3a1517406a3a716249e19c8d6d8cf919605aecfe09cf264aa0910bdf658
6
+ metadata.gz: 0b6f26b1ba2d546196106a36a7f6ca3f727404e38a5f599baf6805f23b0de3d34f7517c4343132ed4b3329fcb205f64e2299065e12b0835e501bd49266913824
7
+ data.tar.gz: 81f60e0155dcc46af521e34a0dd386967feeace95627c49969bf61262c648a4cc227e85f54f28d7e817eb14f99447645f63c856e617f8a8a56d8ba34b33a4e55
data/.gitignore CHANGED
@@ -23,3 +23,4 @@ mkmf.log
23
23
 
24
24
  spec/test_photos
25
25
  ext/findaface/findaface
26
+ .DS_Store
data/README.md CHANGED
@@ -1,26 +1,53 @@
1
1
  # Findaface
2
2
 
3
3
  When given a path to a picture, this gem attempts to determins whether it contains
4
- a single face and thus might be appropriate for a profile image, ID Card etc.
4
+ faces and thus might be appropriate for a profile image. It is looking for faces bigger than 80 pixels squared.
5
5
 
6
- It is a modified then gemified version of George Ogata's [find-face](https://github.com/howaboutwe/find-face).
6
+ It is a modified then gemified version of George Ogata's [find-face](https://github.com/howaboutwe/find-face). If you want a CLI that indicates where the biggest face in an image is, then use the original.
7
7
 
8
- If you want a CLI that indicates where the biggest face in an image is, then use [find-face](https://github.com/howaboutwe/find-face).
9
- If you want a ruby gem that indicates whether an image contains a single face, use this.
8
+ This gem simply compiles an executable to detect a face then calls it externally, so you won't have to include the humongous OpenCV library into your Ruby process, which can cause memory leak / bloat or even crash. This is what [Paperclip](https://github.com/thoughtbot/paperclip) does for ImageMagick. We also support [posix-spawn](https://github.com/rtomayko/posix-spawn) to mitigate the overhead of fork-exec.
10
9
 
11
10
  ## Installation
12
11
 
13
- Add this line to your application's Gemfile:
12
+ There are two steps:
13
+
14
+ 1. Install OpenCV
15
+ 2. Install Findaface
16
+
17
+ ### Install OpenCV
18
+
19
+ For Mac:
14
20
 
15
- gem 'findaface'
21
+ ```sh
22
+ brew tap homebrew/science
23
+ brew install opencv
24
+ ```
25
+
26
+ For Linux (Debian/Ubuntu):
16
27
 
17
- And then execute:
28
+ ```sh
29
+ apt-get install libopencv-dev
30
+ ```
18
31
 
19
- $ bundle
32
+ Linux servers don't have a camera, so you might want to fake the device to suppress the warning:
33
+
34
+ ```sh
35
+ touch /dev/raw1394
36
+ ```
37
+
38
+ ### Install Findaface
39
+
40
+ Add this line to your application's Gemfile:
41
+
42
+ ```ruby
43
+ gem 'findaface'
44
+ ```
20
45
 
21
46
  Or install it yourself as:
22
47
 
23
- $ gem install findaface
48
+ ```sh
49
+ $ gem install findaface
50
+ ```
24
51
 
25
52
  ## Usage
26
53
 
@@ -71,11 +71,12 @@ int main(int argc, const char** argv)
71
71
 
72
72
  // This parameter will affect the quality of the detected faces. Higher value results in less
73
73
  // detections but with higher quality. 3~6 is a good value for it.
74
- int fussyness = 5;
75
- cascade.detectMultiScale(small_image, faces, 1.05, fussyness, 0, Size(50, 50));
74
+ int fussyness = 2;
75
+ cascade.detectMultiScale(small_image, faces, 1.05, fussyness, 0, Size(80, 80));
76
76
 
77
77
  std::cout << faces.size() << "\tface(s) found\n";
78
- if(faces.size() == 1) {
78
+
79
+ if(faces.size() >= 1) {
79
80
  return 0;
80
81
  } else {
81
82
  return 1;
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Andrew Nagi"]
10
10
  spec.email = ["andrew.nagi@gmail.com"]
11
11
  spec.summary = %q{Finds a face in an image.}
12
- spec.description = %q{This gem attempts to discern whether an image contains a clear picture of a single face. Depends on OpenCV.}
12
+ spec.description = %q{This gem attempts to discern whether an image contains any faces. Depends on OpenCV.}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -4,7 +4,7 @@ require 'posix/spawn'
4
4
  module Findaface
5
5
  LIB_PATH = File.dirname(File.expand_path(__FILE__))
6
6
  EXECUTABLE = File.join(LIB_PATH, '../ext/findaface/findaface')
7
- DEFAULT_CASCADE = File.join(LIB_PATH, 'haarcascades/haarcascade_frontalface_alt.xml')
7
+ DEFAULT_CASCADE = File.join(LIB_PATH, 'haarcascades/haarcascade_frontalface_alt2.xml')
8
8
 
9
9
  def self.has_face?(path)
10
10
  raise "#{path} file does not exist" unless File.exists?(path)
@@ -1,3 +1,3 @@
1
1
  module Findaface
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -14,12 +14,6 @@ describe Findaface, "has_face?" do
14
14
  end
15
15
  end
16
16
 
17
- it "returns false for group photos" do
18
- Dir['spec/test_photos/many_faces/*'].each do |path|
19
- Findaface.has_face?(path).should be_false
20
- end
21
- end
22
-
23
17
  it "returns false for photos with small faces" do
24
18
  Dir['spec/test_photos/small_faces/*'].each do |path|
25
19
  Findaface.has_face?(path).should be_false if path == 'spec/test_photos/small_faces/small.jpg'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: findaface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nagi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-02 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: posix-spawn
@@ -122,8 +122,8 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description: This gem attempts to discern whether an image contains a clear picture
126
- of a single face. Depends on OpenCV.
125
+ description: This gem attempts to discern whether an image contains any faces. Depends
126
+ on OpenCV.
127
127
  email:
128
128
  - andrew.nagi@gmail.com
129
129
  executables: []
@@ -168,10 +168,8 @@ files:
168
168
  - spec/findaface_spec.rb
169
169
  - spec/test_photos/has_face/.gitkeep
170
170
  - spec/test_photos/has_face/face.jpg
171
- - spec/test_photos/many_faces/family.jpg
172
171
  - spec/test_photos/no_face/.gitkeep
173
172
  - spec/test_photos/no_face/fruit.jpg
174
- - spec/test_photos/no_face/garden.jpg
175
173
  - spec/test_photos/small_faces/beach.jpg
176
174
  homepage: ''
177
175
  licenses:
@@ -201,9 +199,7 @@ test_files:
201
199
  - spec/findaface_spec.rb
202
200
  - spec/test_photos/has_face/.gitkeep
203
201
  - spec/test_photos/has_face/face.jpg
204
- - spec/test_photos/many_faces/family.jpg
205
202
  - spec/test_photos/no_face/.gitkeep
206
203
  - spec/test_photos/no_face/fruit.jpg
207
- - spec/test_photos/no_face/garden.jpg
208
204
  - spec/test_photos/small_faces/beach.jpg
209
205
  has_rdoc: