similie 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/ext/extconf.rb +18 -7
  2. data/ext/similie.c +8 -2
  3. metadata +2 -2
@@ -10,17 +10,25 @@ def lib_paths lib, defaults
10
10
  path.size > 0 ? path : defaults.map {|name| "-L#{name}"}.join(' ')
11
11
  end
12
12
 
13
- def lib_names lib, defaults
13
+ def lib_flags lib, defaults
14
14
  path = %x{pkg-config #{lib} --libs-only-l 2>/dev/null}.strip
15
- path.size > 0 ? path : defaults.map {|name| "-l#{name}"}.join(' ')
15
+ path.size > 0 ? path.split(/\s+/).select {|name| %r{core|highgui}.match(name)}.join(' ')
16
+ : defaults.map {|name| "-l#{name}"}.join(' ')
16
17
  end
17
18
 
18
- $CFLAGS = inc_paths('opencv', %w(/usr/include/opencv)) + ' -Wall'
19
- $LDFLAGS = lib_names('opencv', %w(highgui cxcore))
19
+ def lib_name re
20
+ $LDFLAGS.scan(re).flatten.first
21
+ end
22
+
23
+ $CFLAGS = inc_paths 'opencv', %w(/usr/include/opencv)
24
+ $LDFLAGS = lib_flags 'opencv', %w(highgui cxcore)
20
25
 
21
- headers = [ 'stdio.h', 'stdlib.h', 'string.h', 'opencv/cxcore.h', 'opencv/highgui.h' ]
22
- lib_1 = [ 'cxcore', 'cvInitFont', headers ]
23
- lib_2 = [ 'highgui', 'cvEncodeImage', headers ]
26
+ cxcore = lib_name(%r{-l(\w*core)}) or raise 'unable to find opencv cxcore'
27
+ highgui = lib_name(%r{-l(\w*highgui)}) or raise 'unable to find opencv highgui'
28
+
29
+ headers = %w(stdio.h stdlib.h string.h opencv/cxcore.h opencv/highgui.h)
30
+ lib_1 = [cxcore, 'cvInitFont', headers]
31
+ lib_2 = [highgui, 'cvEncodeImage', headers]
24
32
 
25
33
  if have_header('opencv/cxcore.h') && have_library(*lib_1) && have_library(*lib_2)
26
34
  create_makefile 'similie'
@@ -31,6 +39,9 @@ else
31
39
  On debian based systems you can install it from apt as,
32
40
  sudo apt-get install libcv-dev libhighgui-dev
33
41
 
42
+ On macos try,
43
+ brew install opencv
44
+
34
45
  Refer to http://opencv.willowgarage.com/wiki/InstallGuide for other platforms or operating systems.
35
46
  }
36
47
 
@@ -25,15 +25,21 @@
25
25
  #define CSTRING(v) RSTRING_PTR(TO_S(v))
26
26
 
27
27
  #undef SIZET2NUM
28
+ #undef NUM2SIZET
29
+
28
30
  #ifdef HAVE_LONG_LONG
29
31
  #define SIZET2NUM(x) ULL2NUM(x)
32
+ #define NUM2SIZET(x) NUM2ULL(x)
30
33
  #else
31
34
  #define SIZET2NUM(x) ULONG2NUM(x)
35
+ #define NUM2SIZET(x) NUM2ULONG(x)
32
36
  #endif
33
37
 
38
+
39
+
34
40
  #define DCT_SIZE 32
35
41
 
36
- #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
42
+ #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
37
43
  #define popcount __builtin_popcountll
38
44
  #else
39
45
  // http://en.wikipedia.org/wiki/Hamming_weight
@@ -132,7 +138,7 @@ VALUE rb_image_initialize(VALUE self, VALUE file) {
132
138
  VALUE rb_image_distance(VALUE self, VALUE other) {
133
139
  VALUE hash1 = rb_image_fingerprint(self);
134
140
  VALUE hash2 = rb_image_fingerprint(other);
135
- int dist = popcount(NUM2ULONG(hash1) ^ NUM2ULONG(hash2));
141
+ int dist = popcount(NUM2SIZET(hash1) ^ NUM2SIZET(hash2));
136
142
  return INT2NUM(dist);
137
143
  }
138
144
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bharanee Rathna