ropencv 0.0.1

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.
@@ -0,0 +1,13 @@
1
+ cv.drawMatches void
2
+ Mat img1
3
+ vector_KeyPoint keypoints1
4
+ Mat img2
5
+ vector_KeyPoint keypoints2
6
+ vector_DMatch matches1to2
7
+ Mat outImg /O
8
+ Scalar matchColor Scalar::all(-1)
9
+ Scalar singlePointColor Scalar::all(-1)
10
+ vector_char matchesMask std::vector<char>()
11
+ int flags DrawMatchesFlags::DEFAULT
12
+ cv.morphologyDefaultBorderValue Scalar
13
+
@@ -0,0 +1,19 @@
1
+ cv.findEssentialMat Mat
2
+ Mat points1
3
+ Mat points2
4
+ double focal 1.0
5
+ Point2d pp Point2d(0, 0)
6
+ int method RANSAC
7
+ double prob 0.999
8
+ double threshold 1.0
9
+ Mat mask Mat()/O; /O
10
+ cv.recoverPose int
11
+ Mat E
12
+ Mat points1
13
+ Mat points2
14
+ Mat R /O; /O
15
+ Mat t /O; /O
16
+ double focal 1.0
17
+ Point2d pp Point2d(0, 0)
18
+ Mat mask Mat()/IO; /IO
19
+
@@ -0,0 +1,48 @@
1
+ const cv.CV_MAX_DIM 32
2
+ const cv.IPL_BORDER_CONSTANT 0
3
+ const cv.IPL_BORDER_REPLICATE 1
4
+ const cv.IPL_BORDER_REFLECT 2
5
+ const cv.IPL_BORDER_WRAP 3
6
+ const cv.IPL_BORDER_REFLECT_101 4
7
+ const cv.IPL_BORDER_TRANSPARENT 5
8
+ const cv.CV_LMEDS 4
9
+ const cv.CV_RANSAC 8
10
+ const cv.CV_ITERATIVE 0
11
+ const cv.CV_EPNP 1
12
+ const cv.CV_P3P 2
13
+ const cv.CV_CALIB_USE_INTRINSIC_GUESS 0x00001
14
+ const cv.CV_CALIB_FIX_ASPECT_RATIO 0x00002
15
+ const cv.CV_CALIB_FIX_PRINCIPAL_POINT 0x00004
16
+ const cv.CV_CALIB_ZERO_TANGENT_DIST 0x00008
17
+ const cv.CV_CALIB_FIX_FOCAL_LENGTH 0x00010
18
+ const cv.CV_CALIB_FIX_K1 0x00020
19
+ const cv.CV_CALIB_FIX_K2 0x00040
20
+ const cv.CV_CALIB_FIX_K3 0x00080
21
+ const cv.CV_CALIB_FIX_K4 0x00800
22
+ const cv.CV_CALIB_FIX_K5 0x01000
23
+ const cv.CV_CALIB_FIX_K6 0x02000
24
+ const cv.CV_CALIB_RATIONAL_MODEL 0x04000
25
+ const cv.CV_CALIB_THIN_PRISM_MODEL 0x08000
26
+ const cv.CV_CALIB_FIX_S1_S2_S3_S4 0x10000
27
+ const cv.CV_CALIB_FIX_INTRINSIC 0x00100
28
+ const cv.CV_CALIB_SAME_FOCAL_LENGTH 0x00200
29
+ const cv.CV_CALIB_ZERO_DISPARITY 0x00400
30
+ const cv.CV_FM_7POINT 1
31
+ const cv.CV_FM_8POINT 2
32
+ const cv.CV_FM_LMEDS 4
33
+ const cv.CV_FM_RANSAC 8
34
+ const cv.CV_AFM_4POINT 16
35
+ const cv.CV_AFM_LMEDS 32
36
+ const cv.CV_AFM_RANSAC 64
37
+ const cv.CV_WINDOW_NORMAL 0x00000000
38
+ const cv.CV_WINDOW_AUTOSIZE 0x00000001
39
+ const cv.CV_WINDOW_OPENGL 0x00001000
40
+ const cv.CV_WINDOW_FULLSCREEN 1
41
+ const cv.CV_WINDOW_FREERATIO 0x00000100
42
+ const cv.CV_WINDOW_KEEPRATIO 0x00000000
43
+ const cv.CV_WND_PROP_FULLSCREEN 0
44
+ const cv.CV_WND_PROP_AUTOSIZE 1
45
+ const cv.CV_WND_PROP_ASPECT_RATIO 2
46
+ const cv.CV_WND_PROP_OPENGL 3
47
+ const cv.InputArray.KINDSHIFT 16
48
+
data/ext/rbind.pc.in ADDED
@@ -0,0 +1,11 @@
1
+ prefix=@CMAKE_INSTALL_PREFIX@
2
+ exec_prefix=@CMAKE_INSTALL_PREFIX@
3
+ libdir=${prefix}/lib
4
+ includedir=${prefix}/include
5
+
6
+ Name: @PROJECT_NAME@
7
+ Description: @PROJECT_DESCRIPTION@
8
+ Version: @PROJECT_VERSION@
9
+ Requires: opencv
10
+ Libs: -L${libdir} -l@PROJECT_NAME@
11
+ Cflags: -I${includedir}
@@ -0,0 +1,11 @@
1
+ prefix=/usr/local
2
+ exec_prefix=/usr/local
3
+ libdir=${prefix}/lib
4
+ includedir=${prefix}/include
5
+
6
+ Name: rbind_opencv
7
+ Description:
8
+ Version:
9
+ Requires: opencv
10
+ Libs: -L${libdir} -lrbind_opencv
11
+ Cflags: -I${includedir}
@@ -0,0 +1,30 @@
1
+ include(FindPkgConfig)
2
+ pkg_check_modules(OPENCV REQUIRED opencv)
3
+ add_definitions(${OPENCV_CFLAGS})
4
+ include_directories(${OPENCV_INCLUDE_DIRS})
5
+ link_directories(${OPENCV_LIBRARY_DIRS})
6
+
7
+ SET(RBIND_SRC
8
+ "${CMAKE_CURRENT_SOURCE_DIR}/types.cc"
9
+ "${CMAKE_CURRENT_SOURCE_DIR}/operations.cc"
10
+ "${CMAKE_CURRENT_SOURCE_DIR}/conversions.cc")
11
+ add_custom_command(OUTPUT ${RBIND_SRC}
12
+ COMMAND ruby "${CMAKE_CURRENT_SOURCE_DIR}/../generate.rb")
13
+
14
+ ADD_LIBRARY(rbind_opencv SHARED ${RBIND_SRC})
15
+ TARGET_LINK_LIBRARIES(rbind_opencv ${OPENCV_LIBS} ${OPENCV_LDFLAGS} )
16
+
17
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rbind.pc.in ${CMAKE_CURRENT_BINARY_DIR}/rbind_opencv.pc @ONLY)
18
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/rbind_opencv.pc DESTINATION lib/pkgconfig)
19
+
20
+ install(TARGETS rbind_opencv LIBRARY DESTINATION lib)
21
+ install(FILES types.h operations.h conversions.hpp DESTINATION include/${PROJECT_NAME}/${DIR})
22
+
23
+ if (EXISTS ${PROJECT_SOURCE_DIR}/extern.rbind)
24
+ install(FILES ${PROJECT_SOURCE_DIR}/extern.rbind DESTINATION include/${PROJECT_NAME}/${DIR})
25
+ endif()
26
+
27
+ if (EXISTS ${PROJECT_SOURCE_DIR}/config.rbind)
28
+ install(FILES ${PROJECT_SOURCE_DIR}/config.rbind DESTINATION include/${PROJECT_NAME}/${DIR})
29
+ endif()
30
+
@@ -0,0 +1,50 @@
1
+
2
+ # specialize some types
3
+ module Rbind
4
+ class RPtr < RStruct
5
+ def initialize(name,root,type)
6
+ super(name)
7
+ add_operation ROperation.new(self.name,nil,RParameter.new("other",self))
8
+ add_operation ROperation.new("addref",root.type("void"))
9
+ add_operation ROperation.new("release",root.type("void"))
10
+ add_operation ROperation.new("delete_obj",root.type("void"))
11
+ add_operation ROperation.new("empty",root.type("bool"))
12
+ add_attribute RAttribute.new("obj",type.to_ptr)
13
+ end
14
+ def specialize_ruby
15
+ " def method_missing(m,*args)\n"\
16
+ " raise \"Ptr #{self} is empty. Cannot call \#{m} on it!\" if empty\n"\
17
+ " obj.method(m).call(*args)\n"\
18
+ " end\n"
19
+ end
20
+ end
21
+
22
+ class RVector < RStruct
23
+ def specialize_ruby
24
+ %Q$ include Enumerable
25
+ def each(&block)
26
+ if block
27
+ s = size
28
+ 0.upto(s-1) do |i|
29
+ yield self[i]
30
+ end
31
+ else
32
+ Enumerator.new(self)
33
+ end
34
+ end
35
+ def <<(val)
36
+ push_back(val)
37
+ end
38
+ Kernel.eval %Q{module ::OpenCV
39
+ module Vector
40
+ class #{GeneratorRuby.normalize_type_name(@vector_type.name)}
41
+ def self.new
42
+ ::#{GeneratorRuby.normalize_type_name(self.name)}.new
43
+ end
44
+ end
45
+ end
46
+ end}$
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,247 @@
1
+ module OpenCV
2
+ def self.included(obj)
3
+ obj.class_eval do
4
+ def cv
5
+ Cv
6
+ end
7
+ end
8
+ end
9
+
10
+ module Cv
11
+ class String
12
+ def self.to_native(obj,context)
13
+ if obj.is_a? ::String
14
+ str = obj.to_str
15
+ OpenCV::Cv::String.new(str,str.length).__obj_ptr__
16
+ else
17
+ rbind_to_native(obj,context)
18
+ end
19
+ end
20
+ def to_s
21
+ c_str
22
+ end
23
+ end
24
+
25
+ class Scalar
26
+ def []=(i,value=nil)
27
+ raise "out of bound #{value}" if value < 0 || value > 3
28
+ val.put_float64(i*8,value)
29
+ value
30
+ end
31
+ end
32
+
33
+ class Mat
34
+ def self.to_native(obj,context)
35
+ if obj.is_a?(VectorPoint2f)
36
+ cv::Mat.new(obj.size,2,cv::CV_32FC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
37
+ elsif obj.is_a?(VectorPoint3f)
38
+ cv::Mat.new(obj.size,3,cv::CV_32FC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
39
+ elsif obj.is_a?(Array)
40
+ h,w,e= if obj.first.is_a? Array
41
+ [obj.size,obj.first.size,obj.first.first]
42
+ else
43
+ [obj.size,1,obj.first]
44
+ end
45
+ setter,step,type = if e.is_a? Fixnum
46
+ [:put_array_of_uint8,w,CV_8UC1]
47
+ elsif e.is_a? Float
48
+ [:put_array_of_float64,8*w,CV_64FC1]
49
+ else
50
+ raise "cannot connvert arrays of #{e.class} to array"
51
+ end
52
+ mat = Mat.new(h,w,type)
53
+ ptr = mat.data
54
+ setter = ptr.method(setter)
55
+ if h == 1 || w == 1
56
+ setter.call(0,obj)
57
+ else
58
+ obj.each_with_index do |row,i|
59
+ raise "number of row elements must be equal for each row" if row.size != w
60
+ setter.call(i*step,row)
61
+ end
62
+ end
63
+ mat.__obj_ptr__
64
+ else
65
+ rbind_to_native(obj,context)
66
+ end
67
+ end
68
+
69
+ def -@
70
+ cv::Mat.zeros(rows,cols,type)-self
71
+ end
72
+
73
+ def at(i,j=nil)
74
+ i,j = if j == nil
75
+ if i.is_a?(Cv::Point)
76
+ [i.y,i.x]
77
+ elsif rows == 1
78
+ [0,i]
79
+ else
80
+ [i,0]
81
+ end
82
+ else
83
+ [i,j]
84
+ end
85
+ if i >= rows || i < 0 || j >= cols || j <0
86
+ raise ArgumentError,"out of bound #{i}/#{j}"
87
+ end
88
+ case type & 7
89
+ when CV_8U
90
+ data.get_uint8(i*step+j)
91
+ when CV_32F
92
+ data.get_float32(i*step+j*4)
93
+ when CV_64F
94
+ data.get_float64(i*step+j*8)
95
+ else
96
+ raise "cannot connvert #{self.class} to ruby"
97
+ end
98
+ end
99
+
100
+ def coerce(other)
101
+ case other
102
+ when Float
103
+ [other,to_f]
104
+ when Fixnum
105
+ [other,to_i]
106
+ else
107
+ raise TypeError, "#{self.class} can't be coerced into #{other.class}"
108
+ end
109
+ end
110
+
111
+ def to_f
112
+ if rows == 1 && cols == 1
113
+ at(0,0).to_f
114
+ else
115
+ raise "Matrix #{self} has more than one element"
116
+ end
117
+ end
118
+
119
+ def to_i
120
+ if rows == 1 && cols == 1
121
+ at(0,0).to_i
122
+ else
123
+ raise "Matrix #{self} has more than one element"
124
+ end
125
+ end
126
+
127
+ def set(i,j,val=nil)
128
+ i,j,val = if val == nil
129
+ if i.is_a?(Cv::Point)
130
+ [i.y,i.x,j]
131
+ elsif rows == 1
132
+ [0,i,j]
133
+ else
134
+ [i,0,j]
135
+ end
136
+ else
137
+ [i,j,val]
138
+ end
139
+ if i >= rows || i < 0 || j >= cols || j <0
140
+ raise ArgumentError,"out of bound #{i}/#{j}"
141
+ end
142
+ case type & 7
143
+ when CV_8U
144
+ data.put_uint8(i*step+j,val)
145
+ when CV_32F
146
+ data.put_float32(i*step+j*4,val)
147
+ when CV_64F
148
+ data.put_float64(i*step+j*8,val)
149
+ else
150
+ raise "cannot connvert #{self.class} to ruby"
151
+ end
152
+ end
153
+
154
+ def [](i,j=nil)
155
+ at(i,j)
156
+ end
157
+
158
+ def []=(i,j,val=nil)
159
+ set(i,j,val)
160
+ end
161
+
162
+ def -(val)
163
+ if val.is_a? Float
164
+ Rbind::cv_mat_operator_minus2( self, val)
165
+ elsif val.is_a? Fixnum
166
+ Rbind::cv_mat_operator_minus3( self, val)
167
+ else
168
+ Rbind::cv_mat_operator_minus( self, val)
169
+ end
170
+ end
171
+
172
+ def +(val)
173
+ if val.is_a? Float
174
+ Rbind::cv_mat_operator_plus2( self, val)
175
+ elsif val.is_a? Fixnum
176
+ Rbind::cv_mat_operator_plus3( self, val)
177
+ else
178
+ Rbind::cv_mat_operator_plus( self, val)
179
+ end
180
+ end
181
+
182
+ def /(val)
183
+ if val.is_a? Float
184
+ Rbind::cv_mat_operator_div2( self, val)
185
+ elsif val.is_a? Fixnum
186
+ Rbind::cv_mat_operator_div3( self, val)
187
+ else
188
+ Rbind::cv_mat_operator_div( self, val)
189
+ end
190
+ end
191
+
192
+ def *(val)
193
+ if val.is_a? Float
194
+ Rbind::cv_mat_operator_mult2( self, val)
195
+ elsif val.is_a? Fixnum
196
+ Rbind::cv_mat_operator_mult3( self, val)
197
+ else
198
+ Rbind::cv_mat_operator_mult( self, val)
199
+ end
200
+ end
201
+
202
+ def pretty_print(pp)
203
+ format = case type & 7
204
+ when CV_8U
205
+ '%3.u'
206
+ else
207
+ '%6.3f'
208
+ end
209
+ a = if cols == 1 || rows == 1
210
+ [to_a]
211
+ else
212
+ to_a
213
+ end
214
+ str = a.map do |r|
215
+ str = r.map do |e|
216
+ sprintf(format,e)
217
+ end.join(" ")
218
+ "|#{str}|"
219
+ end.join("\n")
220
+ pp.text str
221
+ end
222
+
223
+ def to_a
224
+ h,w,c,s,ptr = [rows,cols,channels,step,data]
225
+ getter = case type & 7
226
+ when CV_8U
227
+ ptr.method(:get_array_of_uint8)
228
+ when CV_32F
229
+ ptr.method(:get_array_of_float32)
230
+ when CV_64F
231
+ ptr.method(:get_array_of_float64)
232
+ else
233
+ raise "cannot connvert #{self.class} to array"
234
+ end
235
+ if w == 1 || h == 1
236
+ getter.call(0,total)
237
+ else
238
+ result = []
239
+ 0.upto(h-1) do |i|
240
+ result << getter.call(s*i,w*c)
241
+ end
242
+ result
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
data/lib/ropencv.rb ADDED
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__),'ropencv','ropencv')
2
+ require File.join(File.dirname(__FILE__),'ropencv','ropencv_ruby')
data/ropencv.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'ropencv'
3
+ s.version = '0.0.1'
4
+ s.date = '2013-06-30'
5
+ s.platform = Gem::Platform::RUBY
6
+ s.authors = ['Alexander Duda']
7
+ s.email = ['Alexander.Duda@dfki.de']
8
+ s.homepage = 'http://github.com/'
9
+ s.summary = 'Automated ffi-bindings for opencv 2.4.4 and 2.4.9'
10
+ s.description = ''
11
+ s.files = `git ls-files`.split("\n")
12
+ s.require_path = 'lib'
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.add_runtime_dependency "rbind", "~> 0.0.8"
15
+ s.add_runtime_dependency "ffi", "~> 1.9.0"
16
+ s.extensions = ['ext/extconf.rb']
17
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ropencv
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Alexander Duda
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2013-06-30 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rbind
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.8
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: ffi
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.9.0
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ description: ""
38
+ email:
39
+ - Alexander.Duda@dfki.de
40
+ executables: []
41
+
42
+ extensions:
43
+ - ext/extconf.rb
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - .gitignore
48
+ - CMakeLists.txt
49
+ - README.md
50
+ - examples/logo.png
51
+ - examples/test.rb
52
+ - ext/CMakeLists.txt
53
+ - ext/extconf.rb
54
+ - ext/opencv.txt
55
+ - ext/parser_out.txt
56
+ - ext/post_opencv244.txt
57
+ - ext/post_opencv249.txt
58
+ - ext/pre_opencv244.txt
59
+ - ext/rbind.pc.in
60
+ - ext/rbind_opencv.pc
61
+ - ext/ropencv/CMakeLists.txt
62
+ - ext/specializing.rb
63
+ - lib/ropencv.rb
64
+ - lib/ropencv/ropencv_ruby.rb
65
+ - ropencv.gemspec
66
+ homepage: http://github.com/
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.6
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.23
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Automated ffi-bindings for opencv 2.4.4 and 2.4.9
93
+ test_files: []
94
+