ropencv 0.0.7 → 0.0.8
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/.gitignore +12 -4
- data/.yardopts +5 -2
- data/README.md +8 -16
- data/examples/find_keypoints.rb +1 -1
- data/ext/helper.rb +106 -0
- data/ext/opencv.txt +26 -131
- data/ext/opencv.yml +20100 -0
- data/ext/rbind.rb +48 -75
- data/ext/src/CMakeLists.txt +6 -7
- data/ext/src/cmake/FindGem.cmake +2 -2
- data/lib/{ruby/ropencv.rb → ropencv.rb} +0 -0
- data/lib/{ruby/ropencv → ropencv}/ropencv_ruby.rb +109 -57
- data/ropencv.gemspec +6 -7
- data/test/suite.rb +5 -0
- data/test/test_mat.rb +67 -0
- data/test/test_scalar.rb +34 -0
- data/test/test_triangulate_points.rb +34 -0
- data/test/test_vec.rb +150 -0
- data/test/test_vector.rb +68 -0
- metadata +16 -11
- data/examples/affine3d.rb +0 -17
- data/examples/scalar.rb +0 -10
- data/ext/specializing.rb +0 -50
data/ropencv.gemspec
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'ropencv'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.date = '2013-
|
3
|
+
s.version = '0.0.8'
|
4
|
+
s.date = '2013-08-13'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.authors = ['Alexander Duda']
|
7
7
|
s.email = ['Alexander.Duda@dfki.de']
|
8
8
|
s.homepage = 'http://github.com/D-Alex/ropencv'
|
9
9
|
s.summary = 'Automated ffi-bindings for opencv 2.4.4 and higher'
|
10
|
-
s.description = '
|
11
|
-
'all marked OpenCV C++ methods the OpenCV hdr parser is used to parse the OpenCV '\
|
10
|
+
s.description = 'For wrapping all marked OpenCV C++ methods the OpenCV hdr parser is used to parse the OpenCV '\
|
12
11
|
'header files. From there rbind generates a C interface and ruby classes. The '\
|
13
12
|
'ruby classes are using the C interface via ffi to give the user the same object '\
|
14
13
|
'oriented experience on the ruby side like he has on the c++ side.'
|
15
|
-
s.files = `git ls-files`.split("\n") + ["lib/
|
16
|
-
s.require_path = 'lib
|
14
|
+
s.files = `git ls-files`.split("\n") + ["lib/ropencv/ropencv_types.rb","lib/ropencv/ropencv_ruby.rb"]
|
15
|
+
s.require_path = 'lib'
|
17
16
|
s.required_rubygems_version = ">= 1.3.6"
|
18
|
-
s.add_runtime_dependency "rbind", "~> 0.0.
|
17
|
+
s.add_runtime_dependency "rbind", "~> 0.0.17"
|
19
18
|
s.add_runtime_dependency "ffi", "~> 1.9.0"
|
20
19
|
s.extensions = ['ext/extconf.rb']
|
21
20
|
end
|
data/test/suite.rb
ADDED
data/test/test_mat.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'ropencv'
|
3
|
+
require 'pp'
|
4
|
+
include OpenCV
|
5
|
+
|
6
|
+
MiniTest::Unit.autorun
|
7
|
+
describe Cv::Mat do
|
8
|
+
before do
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "initialize" do
|
15
|
+
it "can be created with the right type and size" do
|
16
|
+
mat = cv::Mat.new(3,4,cv::CV_64FC1)
|
17
|
+
assert mat
|
18
|
+
assert_equal 3, mat.rows
|
19
|
+
assert_equal 4, mat.cols
|
20
|
+
assert_equal cv::CV_64FC1, mat.type
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can be created from a ruby array" do
|
24
|
+
mat = cv::Mat.new([1,2,3])
|
25
|
+
assert mat
|
26
|
+
assert_equal [1,2,3], mat.t.to_a.flatten
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can be created from multiple ruby arrays" do
|
30
|
+
mat = cv::Mat.new([1,2,3],[3,3,3],[5,6,7])
|
31
|
+
assert_equal [[1,2,3],[3,3,3],[5,6,7]], mat.to_a
|
32
|
+
|
33
|
+
mat = cv::Mat.new([[1,2,3],[3,3,3],[5,6,7]])
|
34
|
+
assert_equal [[1,2,3],[3,3,3],[5,6,7]], mat.to_a
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can be created from std::vector" do
|
38
|
+
vec = Std::Vector.new(cv::Point)
|
39
|
+
vec << cv::Point.new(2,3)
|
40
|
+
vec << cv::Point.new(4,5)
|
41
|
+
mat = cv::Mat.new(vec)
|
42
|
+
assert_equal [[2,3],[4,5]], mat.to_a
|
43
|
+
|
44
|
+
vec = Std::Vector.new(cv::Point2f)
|
45
|
+
vec << cv::Point2f.new(2,3)
|
46
|
+
vec << cv::Point2f.new(4,5)
|
47
|
+
mat = cv::Mat.new(vec)
|
48
|
+
assert_equal [[2,3],[4,5]], mat.to_a
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "[]" do
|
53
|
+
it "can return a specific value" do
|
54
|
+
mat = cv::Mat.new([1,2,3],[3,3,3],[5,6,7])
|
55
|
+
assert_equal 6, mat[2,1]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "[]=" do
|
60
|
+
it "can cange a specific value" do
|
61
|
+
mat = cv::Mat.new([1,2,3],[3,3,3],[5,6,7])
|
62
|
+
assert_equal [[1,2,3],[3,3,3],[5,6,7]], mat.to_a
|
63
|
+
mat[1,2] = 4
|
64
|
+
assert_equal [[1,2,3],[3,3,4],[5,6,7]], mat.to_a
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/test/test_scalar.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'ropencv'
|
3
|
+
require 'pp'
|
4
|
+
include OpenCV
|
5
|
+
|
6
|
+
MiniTest::Unit.autorun
|
7
|
+
describe Cv::Scalar do
|
8
|
+
describe "initialize" do
|
9
|
+
it "can be created from 4 values" do
|
10
|
+
scalar = cv::Scalar.new(1,2,3,4)
|
11
|
+
assert_equal [1,2,3,4], scalar.to_a
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "[]" do
|
16
|
+
it "must access a certain field" do
|
17
|
+
scalar = cv::Scalar.new(1,2,3,4)
|
18
|
+
assert_equal 1, scalar[0]
|
19
|
+
assert_equal 2, scalar[1]
|
20
|
+
assert_equal 3, scalar[2]
|
21
|
+
assert_equal 4, scalar[3]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "[]=" do
|
26
|
+
it "must seta certain field" do
|
27
|
+
scalar = cv::Scalar.new(1,2,3,4)
|
28
|
+
assert_equal 2, scalar[1]
|
29
|
+
|
30
|
+
scalar[1] = 222
|
31
|
+
assert_equal 222, scalar[1]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'ropencv'
|
3
|
+
require 'pp'
|
4
|
+
include OpenCV
|
5
|
+
|
6
|
+
|
7
|
+
MiniTest::Unit.autorun
|
8
|
+
describe Cv do
|
9
|
+
describe "triangulate_points" do
|
10
|
+
it "must triangulate the given points" do
|
11
|
+
|
12
|
+
# generate camera matrix
|
13
|
+
p1 = cv::Mat.eye(3,4,cv::CV_32FC1)
|
14
|
+
p2 = cv::Mat.eye(3,4,cv::CV_32FC1)
|
15
|
+
p2[0,3] = 0.1
|
16
|
+
|
17
|
+
# generate 2 points
|
18
|
+
points1 = Vector.new(cv::Point2f)
|
19
|
+
points2 = Vector.new(cv::Point2f)
|
20
|
+
|
21
|
+
points1 << cv::Point2f.new(0.5,0.1)
|
22
|
+
points2 << cv::Point2f.new(0.7,0.1)
|
23
|
+
|
24
|
+
points1 << cv::Point2f.new(0.4,0.1)
|
25
|
+
points2 << cv::Point2f.new(0.2,0.1)
|
26
|
+
|
27
|
+
points3d = cv::Mat.new
|
28
|
+
cv::triangulate_points(p1,p2,cv::Mat.new(points1).t,cv::Mat.new(points2).t,points3d)
|
29
|
+
|
30
|
+
assert_equal 4, points3d.rows
|
31
|
+
assert_equal 2, points3d.cols
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/test/test_vec.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'ropencv'
|
3
|
+
require 'pp'
|
4
|
+
include OpenCV
|
5
|
+
|
6
|
+
MiniTest::Unit.autorun
|
7
|
+
|
8
|
+
describe Cv::Vec2d do
|
9
|
+
describe "initialize" do
|
10
|
+
it "can be created from 2 values" do
|
11
|
+
vec = cv::Vec2d.new(12,2)
|
12
|
+
assert_equal [12,2], vec.to_a
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "[]" do
|
17
|
+
it "must access a given field" do
|
18
|
+
vec = cv::Vec2d.new(12,2)
|
19
|
+
assert_equal 2, vec[1]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "[]=" do
|
24
|
+
it "must set a given field" do
|
25
|
+
vec = cv::Vec2d.new(12,2)
|
26
|
+
vec[0] = 0
|
27
|
+
assert_equal 0, vec[0]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe Cv::Vec2f do
|
33
|
+
describe "initialize" do
|
34
|
+
it "can be created from 2 values" do
|
35
|
+
vec = cv::Vec2f.new(12,2)
|
36
|
+
assert_equal [12,2], vec.to_a
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "[]" do
|
41
|
+
it "must access a given field" do
|
42
|
+
vec = cv::Vec2f.new(12,2)
|
43
|
+
assert_equal 2, vec[1]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "[]=" do
|
48
|
+
it "must set a given field" do
|
49
|
+
vec = cv::Vec2f.new(12,2)
|
50
|
+
vec[0] = 0
|
51
|
+
assert_equal 0, vec[0]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe Cv::Vec2i do
|
57
|
+
describe "initialize" do
|
58
|
+
it "can be created from 2 values" do
|
59
|
+
vec = cv::Vec2i.new(12,2)
|
60
|
+
assert_equal [12,2], vec.to_a
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "[]" do
|
65
|
+
it "must access a given field" do
|
66
|
+
vec = cv::Vec2i.new(12,2)
|
67
|
+
assert_equal 2, vec[1]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "[]=" do
|
72
|
+
it "must set a given field" do
|
73
|
+
vec = cv::Vec2i.new(12,2)
|
74
|
+
vec[0] = 0
|
75
|
+
assert_equal 0, vec[0]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe Cv::Vec3d do
|
81
|
+
describe "initialize" do
|
82
|
+
it "can be created from 3 values" do
|
83
|
+
vec = cv::Vec3d.new(12,2,3)
|
84
|
+
assert_equal [12,2,3], vec.to_a
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe Cv::Vec3f do
|
90
|
+
describe "initialize" do
|
91
|
+
it "can be created from 3 values" do
|
92
|
+
vec = cv::Vec3f.new(12,2,3)
|
93
|
+
assert_equal [12,2,3], vec.to_a
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe Cv::Vec3i do
|
99
|
+
describe "initialize" do
|
100
|
+
it "can be created from 3 values" do
|
101
|
+
vec = cv::Vec3i.new(12,2,3)
|
102
|
+
assert_equal [12,2,3], vec.to_a
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe Cv::Vec4d do
|
108
|
+
describe "initialize" do
|
109
|
+
it "can be created from 4 values" do
|
110
|
+
vec = cv::Vec4d.new(12,2,3,4)
|
111
|
+
assert_equal [12,2,3,4], vec.to_a
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe Cv::Vec4f do
|
117
|
+
describe "initialize" do
|
118
|
+
it "can be created from 4 values" do
|
119
|
+
vec = cv::Vec4f.new(12,2,3,4)
|
120
|
+
assert_equal [12,2,3,4], vec.to_a
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe Cv::Vec4i do
|
126
|
+
describe "initialize" do
|
127
|
+
it "can be created from 4 values" do
|
128
|
+
vec = cv::Vec4i.new(12,2,3,4)
|
129
|
+
assert_equal [12,2,3,4], vec.to_a
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe Cv::Vec6d do
|
135
|
+
describe "initialize" do
|
136
|
+
it "can be created from 6 values" do
|
137
|
+
vec = cv::Vec6d.new(12,2,3,4,5,6)
|
138
|
+
assert_equal [12,2,3,4,5,6], vec.to_a
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe Cv::Vec6i do
|
144
|
+
describe "initialize" do
|
145
|
+
it "can be created from 6 values" do
|
146
|
+
vec = cv::Vec6i.new(12,2,3,4,5,6)
|
147
|
+
assert_equal [12,2,3,4,5,6], vec.to_a
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/test/test_vector.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'ropencv'
|
3
|
+
require 'pp'
|
4
|
+
include OpenCV
|
5
|
+
|
6
|
+
MiniTest::Unit.autorun
|
7
|
+
describe Std::Vector::Cv_Point do
|
8
|
+
describe "initialize" do
|
9
|
+
it "can be created without arguments" do
|
10
|
+
vec = Std::Vector::Cv_Point.new
|
11
|
+
assert vec
|
12
|
+
vec = Std::Vector.new(Cv::Point)
|
13
|
+
assert vec
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can be created with an element as argument" do
|
17
|
+
vec = Std::Vector.new(Cv::Point.new)
|
18
|
+
assert vec
|
19
|
+
end
|
20
|
+
|
21
|
+
it "can be created with elements as argument" do
|
22
|
+
vec = Std::Vector.new(Cv::Point.new,Cv::Point.new)
|
23
|
+
assert vec
|
24
|
+
assert_equal 2, vec.size
|
25
|
+
vec = Std::Vector.new([Cv::Point.new,Cv::Point.new])
|
26
|
+
assert vec
|
27
|
+
assert_equal 2, vec.size
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "at" do
|
32
|
+
it "must return a certain element" do
|
33
|
+
vec = Std::Vector.new(Cv::Point.new(0,0),Cv::Point.new(1,2))
|
34
|
+
assert_equal cv::Point.new(1,2), vec.at(1)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "must raise RangeError when out of range " do
|
38
|
+
vec = Std::Vector.new(Cv::Point.new(0,0),Cv::Point.new(1,2))
|
39
|
+
assert_raises RangeError do
|
40
|
+
vec.at(-1)
|
41
|
+
end
|
42
|
+
assert_raises RangeError do
|
43
|
+
vec.at(2)
|
44
|
+
end
|
45
|
+
vec.clear
|
46
|
+
assert_raises RangeError do
|
47
|
+
vec.at(0)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "[]" do
|
53
|
+
it "must return a certain element" do
|
54
|
+
vec = Std::Vector.new(Cv::Point.new(0,0),Cv::Point.new(1,2))
|
55
|
+
assert_equal cv::Point.new(1,2), vec.at(1)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "must raise RangeError when out of range " do
|
59
|
+
vec = Std::Vector.new(Cv::Point.new(0,0),Cv::Point.new(1,2))
|
60
|
+
assert_raises RangeError do
|
61
|
+
vec[-1]
|
62
|
+
end
|
63
|
+
assert_raises RangeError do
|
64
|
+
vec[2]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ropencv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Alexander Duda
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-08-13 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rbind
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.
|
23
|
+
version: 0.0.17
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 1.9.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
|
-
description:
|
37
|
+
description: For wrapping all marked OpenCV C++ methods the OpenCV hdr parser is used to parse the OpenCV header files. From there rbind generates a C interface and ruby classes. The ruby classes are using the C interface via ffi to give the user the same object oriented experience on the ruby side like he has on the c++ side.
|
38
38
|
email:
|
39
39
|
- Alexander.Duda@dfki.de
|
40
40
|
executables: []
|
@@ -48,27 +48,32 @@ files:
|
|
48
48
|
- .yardopts
|
49
49
|
- CMakeLists.txt
|
50
50
|
- README.md
|
51
|
-
- examples/affine3d.rb
|
52
51
|
- examples/find_keypoints.rb
|
53
52
|
- examples/logo.png
|
54
|
-
- examples/scalar.rb
|
55
53
|
- ext/CMakeLists.txt
|
56
54
|
- ext/extconf.rb
|
55
|
+
- ext/helper.rb
|
57
56
|
- ext/opencv.txt
|
57
|
+
- ext/opencv.yml
|
58
58
|
- ext/parser_out.txt
|
59
59
|
- ext/post_opencv244.txt
|
60
60
|
- ext/post_opencv249.txt
|
61
61
|
- ext/pre_opencv244.txt
|
62
62
|
- ext/rbind.rb
|
63
|
-
- ext/specializing.rb
|
64
63
|
- ext/src/CMakeLists.txt
|
65
64
|
- ext/src/cmake/FindGem.cmake
|
66
65
|
- ext/src/cmake/FindRuby.cmake
|
67
66
|
- ext/src/rbind.pc.in
|
68
|
-
- lib/
|
69
|
-
- lib/
|
67
|
+
- lib/ropencv.rb
|
68
|
+
- lib/ropencv/ropencv_ruby.rb
|
70
69
|
- ropencv.gemspec
|
71
|
-
-
|
70
|
+
- test/suite.rb
|
71
|
+
- test/test_mat.rb
|
72
|
+
- test/test_scalar.rb
|
73
|
+
- test/test_triangulate_points.rb
|
74
|
+
- test/test_vec.rb
|
75
|
+
- test/test_vector.rb
|
76
|
+
- lib/ropencv/ropencv_types.rb
|
72
77
|
homepage: http://github.com/D-Alex/ropencv
|
73
78
|
licenses: []
|
74
79
|
|
@@ -76,7 +81,7 @@ post_install_message:
|
|
76
81
|
rdoc_options: []
|
77
82
|
|
78
83
|
require_paths:
|
79
|
-
- lib
|
84
|
+
- lib
|
80
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
86
|
none: false
|
82
87
|
requirements:
|