ropencv 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/examples/data/haarcascade_frontalface_alt.xml.gz +0 -0
- data/examples/data/jolie.jpeg +0 -0
- data/examples/{logo.png → data/logo.png} +0 -0
- data/examples/data/sample.jpg +0 -0
- data/examples/{tsukuba_l.png → data/tsukuba_l.png} +0 -0
- data/examples/{tsukuba_r.png → data/tsukuba_r.png} +0 -0
- data/examples/find_keypoints.rb +1 -1
- data/examples/harr_cascade.rb +37 -0
- data/examples/hog_descriptor.rb +28 -0
- data/examples/hough_circles.rb +3 -3
- data/examples/match_keypoints.rb +3 -3
- data/ext/helper.rb +1 -1
- data/lib/ropencv/ropencv_ruby.rb +24 -13
- data/ropencv.gemspec +2 -2
- metadata +23 -12
- checksums.yaml +0 -7
Binary file
|
Binary file
|
File without changes
|
Binary file
|
File without changes
|
File without changes
|
data/examples/find_keypoints.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
require 'ropencv'
|
3
|
+
include OpenCV
|
4
|
+
|
5
|
+
#depends on openCV installation so copied into the directory for easier access
|
6
|
+
face_cascade_name = File.join(Dir.getwd,'data',"haarcascade_frontalface_alt.xml")
|
7
|
+
image_name = File.join(Dir.getwd,'data',"jolie.jpeg")
|
8
|
+
|
9
|
+
|
10
|
+
# unpack file
|
11
|
+
if !File.exist?(face_cascade_name)
|
12
|
+
Zlib::GzipReader.open("#{face_cascade_name}.gz") do |gz|
|
13
|
+
f = File.open(face_cascade_name,"w")
|
14
|
+
f.write gz.read
|
15
|
+
f.close
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
frame_gray = cv::Mat.new
|
20
|
+
face_cascade = cv::CascadeClassifier.new
|
21
|
+
puts face_cascade.load(face_cascade_name) ? ' loaded' : 'not loaded'
|
22
|
+
|
23
|
+
frame = cv::imread(image_name)
|
24
|
+
faces = Std::Vector.new(cv::Rect)
|
25
|
+
|
26
|
+
cv::cvt_color(frame,frame_gray, cv::COLOR_BGR2GRAY)
|
27
|
+
cv::equalizeHist( frame_gray, frame_gray );
|
28
|
+
|
29
|
+
face_cascade.detect_multi_scale( frame_gray, faces, 1.1, 2, );
|
30
|
+
puts faces.size
|
31
|
+
|
32
|
+
faces.each do |face|
|
33
|
+
center = cv::Point.new(face.x + face.width*0.5, face.y + face.height*0.5)
|
34
|
+
cv::ellipse( frame, center, cv::Size.new( face.width*0.5, face.height*0.5), 0, 0, 360, cv::Scalar.new( 255, 0, 255 ), 4, 8, 0 );
|
35
|
+
end
|
36
|
+
cv::imshow("key_points",frame)
|
37
|
+
cv::wait_key(-1)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ropencv'
|
2
|
+
include OpenCV
|
3
|
+
|
4
|
+
image_name = File.join(Dir.getwd,'data',"sample.jpg")
|
5
|
+
frame = cv::imread(image_name)
|
6
|
+
|
7
|
+
detector = cv::HOGDescriptor.new
|
8
|
+
people_detector_vec = cv::HOGDescriptor.get_default_people_detector
|
9
|
+
default_people_detector_mat = cv::Mat.new(people_detector_vec.size, 1, cv::CV_32FC1, people_detector_vec.data, cv::Mat::AUTO_STEP)
|
10
|
+
detector.setsvm_detector(default_people_detector_mat)
|
11
|
+
founds = Std::Vector.new(cv::Rect)
|
12
|
+
founds_filtered = Std::Vector.new(cv::Rect)
|
13
|
+
window = Std::Vector::Double.new()
|
14
|
+
|
15
|
+
detector.detect_multi_scale(frame, founds, window)
|
16
|
+
|
17
|
+
founds.each do |found|
|
18
|
+
|
19
|
+
r = cv::Rect.new(found)
|
20
|
+
r.x += (r.width*0.1).to_i
|
21
|
+
r.width = (r.width*0.8).to_i
|
22
|
+
r.y += (r.height*0.07).to_i
|
23
|
+
r.height = (r.height*0.8).to_i
|
24
|
+
cv::rectangle(frame, r.tl, r.br, cv::Scalar.new(0,255,0), 3)
|
25
|
+
|
26
|
+
end
|
27
|
+
cv::imshow("hog_descriptor",frame)
|
28
|
+
cv::wait_key(-1)
|
data/examples/hough_circles.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'ropencv'
|
2
2
|
include OpenCV
|
3
3
|
|
4
|
-
img = cv::imread("logo.png")
|
4
|
+
img = cv::imread(File.join("data","logo.png"))
|
5
5
|
gray = cv::Mat.new
|
6
|
-
cv::cvtColor(img,gray,
|
6
|
+
cv::cvtColor(img,gray,cv::COLOR_BGR2GRAY)
|
7
7
|
|
8
8
|
circles = cv::Mat.new
|
9
|
-
cv::HoughCircles(gray, circles,
|
9
|
+
cv::HoughCircles(gray, circles, cv::HOUGH_GRADIENT, 1, gray.rows/10, 10, 20 );
|
10
10
|
circles = circles.reshape(1,circles.cols)
|
11
11
|
|
12
12
|
circles.each_row do |circle|
|
data/examples/match_keypoints.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'ropencv'
|
2
2
|
include OpenCV
|
3
3
|
|
4
|
-
img1 = cv::imread('tsukuba_l.png',CV_LOAD_IMAGE_GRAYSCALE)
|
5
|
-
img2 = cv::imread('tsukuba_r.png',CV_LOAD_IMAGE_GRAYSCALE)
|
4
|
+
img1 = cv::imread(File.join('data','tsukuba_l.png'),CV_LOAD_IMAGE_GRAYSCALE)
|
5
|
+
img2 = cv::imread(File.join('data','tsukuba_r.png'),CV_LOAD_IMAGE_GRAYSCALE)
|
6
6
|
if (img1.empty() || img2.empty())
|
7
7
|
puts("Can't read one of the images\n")
|
8
8
|
return -1
|
@@ -28,6 +28,6 @@ matcher.match(descriptors1, descriptors2, matches)
|
|
28
28
|
|
29
29
|
# drawing the results
|
30
30
|
img_matches=cv::Mat.new(3, 4, cv::CV_64FC1)
|
31
|
-
cv::
|
31
|
+
cv::draw_matches(img1, keypoints1, img2, keypoints2, matches, img_matches)
|
32
32
|
cv::imshow("matches", img_matches)
|
33
33
|
cv::waitKey(0)
|
data/ext/helper.rb
CHANGED
@@ -94,7 +94,7 @@ def find_opencv
|
|
94
94
|
opencv_version = out.read.chomp
|
95
95
|
|
96
96
|
##add opencv headers
|
97
|
-
headers = if opencv_version >= "2.4.4" && opencv_version < "2.4.
|
97
|
+
headers = if opencv_version >= "2.4.4" && opencv_version < "2.4.9.0"
|
98
98
|
["opencv2/core/core_c.h", "opencv2/core/types_c.h",
|
99
99
|
"opencv2/core/core.hpp", "opencv2/flann/miniflann.hpp",
|
100
100
|
"opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/types_c.h",
|
data/lib/ropencv/ropencv_ruby.rb
CHANGED
@@ -310,6 +310,9 @@ module OpenCV
|
|
310
310
|
|
311
311
|
class Mat
|
312
312
|
include Enumerable
|
313
|
+
DISPLAYED_ROWS_MAX = 100
|
314
|
+
DISPLAYED_COLS_MAX = 100
|
315
|
+
|
313
316
|
class << self
|
314
317
|
alias :rbind_new :new
|
315
318
|
|
@@ -332,6 +335,10 @@ module OpenCV
|
|
332
335
|
Cv::Mat.new(obj.size,1,Cv::CV_32FC3,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
333
336
|
elsif obj.is_a?(Std::Vector::Fixnum)
|
334
337
|
Cv::Mat.new(obj.size,1,Cv::CV_32SC1,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
338
|
+
elsif obj.is_a?(Std::Vector::Float)
|
339
|
+
Cv::Mat.new(obj.size,1,Cv::CV_32FC1,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
340
|
+
elsif obj.is_a?(Std::Vector::Double)
|
341
|
+
Cv::Mat.new(obj.size,1,Cv::CV_64FC1,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
335
342
|
elsif obj.is_a?(Array)
|
336
343
|
h,w,e= if obj.first.is_a? Array
|
337
344
|
if obj.find {|array| array.find(Float)}
|
@@ -526,19 +533,23 @@ module OpenCV
|
|
526
533
|
end
|
527
534
|
|
528
535
|
def pretty_print(pp)
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
str =
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
536
|
+
if(rows <= DISPLAYED_ROWS_MAX && cols <= DISPLAYED_COLS_MAX)
|
537
|
+
format = case type & 7
|
538
|
+
when CV_8U
|
539
|
+
'%3.u'
|
540
|
+
else
|
541
|
+
'%6.3f'
|
542
|
+
end
|
543
|
+
str = to_a.map do |r|
|
544
|
+
str = r.map do |e|
|
545
|
+
sprintf(format,e)
|
546
|
+
end.join(" ")
|
547
|
+
"|#{str}|"
|
548
|
+
end.join("\n")
|
549
|
+
pp.text str
|
550
|
+
else
|
551
|
+
pp.text self.to_s
|
552
|
+
end
|
542
553
|
end
|
543
554
|
|
544
555
|
def each
|
data/ropencv.gemspec
CHANGED
metadata
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ropencv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Alexander Duda
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rbind
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: 0.0.24
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.0.24
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: ffi
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -52,14 +57,19 @@ files:
|
|
52
57
|
- CMakeLists.txt
|
53
58
|
- License.txt
|
54
59
|
- README.md
|
60
|
+
- examples/data/haarcascade_frontalface_alt.xml.gz
|
61
|
+
- examples/data/jolie.jpeg
|
62
|
+
- examples/data/logo.png
|
63
|
+
- examples/data/sample.jpg
|
64
|
+
- examples/data/tsukuba_l.png
|
65
|
+
- examples/data/tsukuba_r.png
|
55
66
|
- examples/file_storage.rb
|
56
67
|
- examples/find_homography.rb
|
57
68
|
- examples/find_keypoints.rb
|
69
|
+
- examples/harr_cascade.rb
|
70
|
+
- examples/hog_descriptor.rb
|
58
71
|
- examples/hough_circles.rb
|
59
|
-
- examples/logo.png
|
60
72
|
- examples/match_keypoints.rb
|
61
|
-
- examples/tsukuba_l.png
|
62
|
-
- examples/tsukuba_r.png
|
63
73
|
- ext/CMakeLists.txt
|
64
74
|
- ext/extconf.rb
|
65
75
|
- ext/helper.rb
|
@@ -89,26 +99,27 @@ files:
|
|
89
99
|
homepage: http://www.ropencv.aduda.eu
|
90
100
|
licenses:
|
91
101
|
- BSD
|
92
|
-
metadata: {}
|
93
102
|
post_install_message:
|
94
103
|
rdoc_options: []
|
95
104
|
require_paths:
|
96
105
|
- lib
|
97
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
98
108
|
requirements:
|
99
|
-
- - '>='
|
109
|
+
- - ! '>='
|
100
110
|
- !ruby/object:Gem::Version
|
101
111
|
version: '0'
|
102
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
103
114
|
requirements:
|
104
|
-
- - '>='
|
115
|
+
- - ! '>='
|
105
116
|
- !ruby/object:Gem::Version
|
106
117
|
version: 1.3.6
|
107
118
|
requirements: []
|
108
119
|
rubyforge_project:
|
109
|
-
rubygems_version:
|
120
|
+
rubygems_version: 1.8.23
|
110
121
|
signing_key:
|
111
|
-
specification_version:
|
122
|
+
specification_version: 3
|
112
123
|
summary: Ruby bindings for opencv 2.4.4 and higher
|
113
124
|
test_files: []
|
114
125
|
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: ed24be2b4f9b19d2ab4170ad578b3d78d36958e4
|
4
|
-
data.tar.gz: 4d4520ac61ca76f16bf3a7961f6240f2c6cf9f10
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 47aea3c934fe8500236d0ad798dad58d6abaeafe1fe6c0e9fdf47635da080b6549df5ca777ed99a6b68c959c7a64d91db889c17c04a1091487189fe074e88cb9
|
7
|
-
data.tar.gz: b1e32dda67c171d45095c114b0550c0ebdd0c7bb46577636673be39edd95d98c965fbe208df74efa2fb32bcc5b3b4151bd492189e103c1220773d0162232e90b
|