ropencv 0.0.12 → 0.0.13

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2e6aa5a66cdc073f75cbcef5ecdf2754dec1b9c
4
- data.tar.gz: 78f996037687e4e836aee3f2ca2f540f79ece752
3
+ metadata.gz: dd8ab218b838274f85686f33fbac6b91abd46097
4
+ data.tar.gz: 7eb519e53bb782f17665dc6f4fc3a90c558cb2f2
5
5
  SHA512:
6
- metadata.gz: b94532ed19232a2bd9a3758cfa13293f999fb94139b51c0b9ee5dbd742c07d82c06516c5465d4439c7d51bb920a82b791dccf9e0232bb5812d1e47b01fa32987
7
- data.tar.gz: fd2e2023995003ccfbcd35edfc59c373d2f58dcd998828ab26ac7f21fe79d00f544167c87bb199390e774aad4a9279970ba96be9896f478e1e712e0d7fa93456
6
+ metadata.gz: 5cf14edc726ab2dd119bcc804e81f3bafb43538083394afa74d75b7fd7015a988cf08ae1218e995d961416209875806c313a7e66fbd4f6999c637501c57ec046
7
+ data.tar.gz: f11e563f715217ad25fb7576107f7af949db69cdef3d7b95260eaefe1c123f8ae0bffd26fe4c49aff62028ff448db7e2c9a84b4d5153fbdd8b88a99a3d6fd144
@@ -0,0 +1,26 @@
1
+ require 'ropencv'
2
+ require 'pp'
3
+
4
+ include OpenCV
5
+
6
+ #writing
7
+ fs = cv::FileStorage.new("test.yml",cv::FileStorage::WRITE)
8
+ fs << "mat" << cv::Mat.ones(10,10,cv::CV_32FC1)
9
+ fs << "int" << 10
10
+ fs << "seq" << "[" << 10 << 2 << "]"
11
+ fs << "map1" << "{" <<"element1" << 2 << "}"
12
+ fs.release
13
+
14
+ # reading
15
+ fs = cv::FileStorage.new("test.yml",cv::FileStorage::READ)
16
+ fs.each do |e|
17
+ puts "got node #{e.name}"
18
+ end
19
+
20
+ pp "seq: #{fs["seq"].to_array_of_int}"
21
+ pp "mat: #{fs["mat"].to_mat}"
22
+ pp "int: #{fs["int"].to_int}"
23
+ pp "map.element1: #{fs["map1"]["element1"].to_int}"
24
+ pp "map.element1: #{fs.map1.element1.to_int}"
25
+
26
+ fs.release
@@ -0,0 +1,18 @@
1
+ require 'ropencv'
2
+ require 'pp'
3
+
4
+ include OpenCV
5
+
6
+ points1 = std::Vector.new(cv::Point2f)
7
+ points2 = std::Vector.new(cv::Point2f)
8
+
9
+ points1.push_back(cv::Point2f.new(1,1))
10
+ points1.push_back(cv::Point2f.new(3,1))
11
+ points1.push_back(cv::Point2f.new(4,2))
12
+ points1.push_back(cv::Point2f.new(10,1))
13
+
14
+ points1.each do |pt|
15
+ points2.push_back(pt*0.2)
16
+ end
17
+
18
+ pp cv::find_homography(points1,points2)
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.6.1"
97
+ headers = if opencv_version >= "2.4.4" && opencv_version < "2.4.7.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",
@@ -106,7 +106,7 @@ def find_opencv
106
106
  "opencv2/contrib/contrib.hpp", "opencv2/nonfree/nonfree.hpp",
107
107
  "opencv2/nonfree/features2d.hpp"]
108
108
  elsif opencv_version >= "2.4.9"
109
- ["opencv2/core.hpp", "opencv2/core/types.hpp",
109
+ ["opencv2/core.hpp", "opencv2/core/types.hpp","opencv2/core/persistence.hpp",
110
110
  "opencv2/core/utility.hpp", "opencv2/core/base.hpp",
111
111
  "opencv2/contrib.hpp", "opencv2/calib3d.hpp",
112
112
  "opencv2/features2d.hpp", "opencv2/flann.hpp",
data/ext/opencv.txt CHANGED
@@ -122,8 +122,12 @@ cv.Point.cross double
122
122
  Point pt
123
123
  cv.Point.inside bool
124
124
  Rect rect
125
- cv.Point.operator+ void
125
+ cv.Point.operator+ Point
126
126
  Point pt
127
+ cv.Point.operator- Point
128
+ Point pt
129
+ cv.Point.operator* Point
130
+ int val
127
131
  cv.Point.operator== bool
128
132
  Point pt
129
133
  cv.Point.operator!= bool
@@ -143,8 +147,12 @@ cv.Point2f.dot double
143
147
  Point2f pt
144
148
  cv.Point2f.cross double
145
149
  Point2f pt
146
- cv.Point2f.operator+ void
150
+ cv.Point2f.operator+ Point2f
147
151
  Point2f pt
152
+ cv.Point2f.operator- Point2f
153
+ Point2f pt
154
+ cv.Point2f.operator* Point2f
155
+ float val
148
156
  cv.Point2f.operator== bool
149
157
  Point2f pt
150
158
  cv.Point2f.operator!= bool
@@ -156,8 +164,12 @@ cv.Point2d.Point2d
156
164
  cv.Point2d.Point2d
157
165
  double x
158
166
  double y
159
- cv.Point2d.operator+ void
167
+ cv.Point2d.operator+ Point2d
168
+ Point2d pt
169
+ cv.Point2d.operator- Point2d
160
170
  Point2d pt
171
+ cv.Point2d.operator* Point2d
172
+ double val
161
173
  cv.Point2d.Point2d
162
174
  Point2d pt
163
175
  cv.Point2d.dot double
@@ -187,8 +199,12 @@ cv.Point3f.ddot double
187
199
  Point3f pt
188
200
  cv.Point3f.cross Point3f
189
201
  Point3f pt
190
- cv.Point3f.operator+ void
202
+ cv.Point3f.operator+ Point3f
203
+ Point3f pt
204
+ cv.Point3f.operator- Point3f
191
205
  Point3f pt
206
+ cv.Point3f.operator* Point3f
207
+ float val
192
208
  cv.Point3f.operator== bool
193
209
  Point3f pt
194
210
  cv.Point3f.operator!= bool
@@ -210,8 +226,12 @@ cv.Point3d.ddot double
210
226
  Point3d pt
211
227
  cv.Point3d.cross Point3d
212
228
  Point3d pt
213
- cv.Point3d.operator+ void
229
+ cv.Point3d.operator+ Point3d
230
+ Point3d pt
231
+ cv.Point3d.operator- Point3d
214
232
  Point3d pt
233
+ cv.Point3d.operator* Point3d
234
+ double val
215
235
  cv.Point3d.operator== bool
216
236
  Point3d pt
217
237
  cv.Point3d.operator!= bool
@@ -449,4 +469,153 @@ cv.RNG.fill void
449
469
  bool saturateRange false
450
470
  cv.RNG.gaussian double
451
471
  double sigma
472
+ class cv.FileStorage
473
+ cv.write void =write_scalar_int
474
+ FileStorage fs /IO
475
+ int val
476
+ cv.write void =write_scalar_float
477
+ FileStorage fs /IO
478
+ float val
479
+ cv.write void =write_scalar_double
480
+ FileStorage fs /IO
481
+ double val
482
+ cv.write void =write_scalar_string
483
+ FileStorage fs /IO
484
+ String val
485
+ cv.write void =write_int
486
+ FileStorage fs /IO
487
+ String name
488
+ int val
489
+ cv.write void =write_float
490
+ FileStorage fs /IO
491
+ String name
492
+ float val
493
+ cv.write void =write_double
494
+ FileStorage fs /IO
495
+ String name
496
+ double val
497
+ cv.write void =write_string
498
+ FileStorage fs /IO
499
+ String name
500
+ String val
501
+ cv.write void =write_mat
502
+ FileStorage fs /IO
503
+ String name
504
+ Mat val
505
+ cv.write void =write_point
506
+ FileStorage fs /IO
507
+ String name
508
+ Point val
509
+ cv.write void =write_point2f
510
+ FileStorage fs /IO
511
+ String name
512
+ Point2f val
513
+ cv.write void =write_point3f
514
+ FileStorage fs /IO
515
+ String name
516
+ Point3f val
517
+ cv.write void =write_point2d
518
+ FileStorage fs /IO
519
+ String name
520
+ Point2d val
521
+ cv.write void =write_point3d
522
+ FileStorage fs /IO
523
+ String name
524
+ Point3d val
525
+ cv.write void =write_rect
526
+ FileStorage fs /IO
527
+ String name
528
+ Rect val
529
+ cv.write void =write_range
530
+ FileStorage fs /IO
531
+ String name
532
+ Range val
533
+ cv.write void =write_scalar
534
+ FileStorage fs /IO
535
+ String name
536
+ Scalar val
537
+ cv.write void =write_size
538
+ FileStorage fs /IO
539
+ String name
540
+ Size val
541
+ cv.write void =write_vec2f
542
+ FileStorage fs /IO
543
+ String name
544
+ Vec2f val
545
+ cv.write void =write_vec3f
546
+ FileStorage fs /IO
547
+ String name
548
+ Vec3f val
549
+ cv.write void =write_vec2d
550
+ FileStorage fs /IO
551
+ String name
552
+ Vec2d val
553
+ cv.write void =write_vec3d
554
+ FileStorage fs /IO
555
+ String name
556
+ Vec3d val
557
+ cv.read void =read_int
558
+ FileNode fn /IO
559
+ int val /O
560
+ int default_val
561
+ cv.read void =read_float
562
+ FileNode fn /IO
563
+ float val /O
564
+ float default_val
565
+ cv.read void =read_double
566
+ FileNode fn /IO
567
+ double val /O
568
+ double default_val
569
+ cv.read void =read_string
570
+ FileNode fn /IO
571
+ String val /O
572
+ String default_val
573
+ cv.read void =read_mat
574
+ FileNode fn /IO
575
+ Mat val /O
576
+ Mat default_val
577
+ cv.FileStorage.operator<< FileStorage =write_int /O
578
+ int val
579
+ cv.FileStorage.operator<< FileStorage =write_float /O
580
+ float val
581
+ cv.FileStorage.operator<< FileStorage =write_double /O
582
+ double val
583
+ cv.FileStorage.operator<< FileStorage =write_string /O
584
+ String val
585
+ cv.FileStorage.operator<< FileStorage =write_size /O
586
+ Size val
587
+ cv.FileStorage.operator<< FileStorage =write_point /O
588
+ Point val
589
+ cv.FileStorage.operator<< FileStorage =write_point2f /O
590
+ Point2f val
591
+ cv.FileStorage.operator<< FileStorage =write_point3f /O
592
+ Point3f val
593
+ cv.FileStorage.operator<< FileStorage =write_point2d /O
594
+ Point2d val
595
+ cv.FileStorage.operator<< FileStorage =write_point3d /O
596
+ Point3d val
597
+ cv.FileStorage.operator<< FileStorage =write_rect /O
598
+ Rect val
599
+ cv.FileStorage.operator<< FileStorage =write_mat /O
600
+ Mat val
601
+ class cv.FileNodeIterator
602
+ cv.FileNode.operator>> void =read_int
603
+ int val /IO
604
+ cv.FileNode.operator>> void =read_float
605
+ float val /IO
606
+ cv.FileNode.operator>> void =read_double
607
+ double val /IO
608
+ cv.FileNode.operator>> void =read_string
609
+ String val /IO
610
+ cv.FileNode.operator>> void =read_mat
611
+ Mat val /IO
612
+ cv.FileNode.begin FileNodeIterator
613
+ cv.FileNode.end FileNodeIterator
614
+ cv.FileNodeIterator.operator++ FileNodeIterator
615
+ cv.FileNodeIterator.operator-- FileNodeIterator
616
+ cv.FileNodeIterator.operator* FileNode =to_node
617
+ cv.FileNodeIterator.operator== bool
618
+ FileNodeIterator other
619
+ cv.FileNodeIterator.operator!= bool
620
+ FileNodeIterator other
452
621
 
@@ -10,6 +10,14 @@ module OpenCV
10
10
  end
11
11
  end
12
12
 
13
+ def self.std
14
+ Std
15
+ end
16
+
17
+ def self.cv
18
+ Cv
19
+ end
20
+
13
21
  module Std
14
22
  class Vector
15
23
  class Cv_Mat
@@ -36,6 +44,12 @@ module OpenCV
36
44
  include Std
37
45
 
38
46
  module Cv
47
+ def self.min_max_loc(src,min_loc = Point.new,max_loc = Point.new,mask = Mat.new)
48
+ p = FFI::MemoryPointer.new(:double,2)
49
+ Rbind::cv_min_max_loc(src, p[0], p[1], min_loc, max_loc, mask)
50
+ [p[0].read_double,p[1].read_double]
51
+ end
52
+
39
53
  class Size
40
54
  def *(val)
41
55
  Size.new(width*val,height*val)
@@ -169,7 +183,129 @@ module OpenCV
169
183
 
170
184
  class Scalar; include Vecxd; SIZE=4;end
171
185
 
186
+ class FileStorage
187
+ include Enumerable
188
+
189
+ def each(&block)
190
+ if block_given?
191
+ root.each(&block)
192
+ else
193
+ to_enum(:each)
194
+ end
195
+ end
196
+
197
+ def <<(val)
198
+ if val.is_a?(Fixnum)
199
+ write_int(val)
200
+ elsif val.is_a?(Float)
201
+ write_double(val)
202
+ else
203
+ name = val.class.name.split("::").last.downcase
204
+ send("write_#{name}",val)
205
+ end
206
+ end
207
+
208
+ def method_missing(m,*args)
209
+ if args.empty?
210
+ self[m.to_s]
211
+ else
212
+ super
213
+ end
214
+ end
215
+ end
216
+
217
+ class FileNode
218
+ include Enumerable
219
+ alias :empty? :empty
220
+ alias :int? :isInt
221
+ alias :real? :isReal
222
+ alias :string? :isString
223
+ alias :map? :isMap
224
+ alias :seq? :isSeq
225
+
226
+ def each(&block)
227
+ if block_given?
228
+ iter = self.begin()
229
+ while(iter != self.end())
230
+ yield(iter.to_node)
231
+ iter.plusplus_operator
232
+ end
233
+ else
234
+ to_enum(:each)
235
+ end
236
+ end
237
+
238
+ def to_array_of_int
239
+ raise RuntimeError, "FileNode is not the root node of a sequence" unless seq?
240
+ map(&:to_int)
241
+ end
242
+
243
+ def to_array_of_float
244
+ raise RuntimeError, "FileNode is not the root node of a sequence" unless seq?
245
+ map(&:to_float)
246
+ end
247
+
248
+ def to_array_of_double
249
+ raise RuntimeError, "FileNode is not the root node of a sequence" unless seq?
250
+ map(&:to_double)
251
+ end
252
+
253
+ def to_array_of_string
254
+ raise RuntimeError, "FileNode is not the root node of a sequence" unless seq?
255
+ map(&:to_string)
256
+ end
257
+
258
+ def to_mat
259
+ raise RuntimeError, "FileNode is empty" if empty?
260
+ raise RuntimeError, "FileNode is not storing a Mat" unless isMap
261
+ val = cv::Mat.new
262
+ read_mat(val)
263
+ val
264
+ end
265
+
266
+ def to_float
267
+ raise RuntimeError, "FileNode is empty" if empty?
268
+ raise RuntimeError, "FileNode is not storing a float" unless isReal
269
+ p = FFI::MemoryPointer.new(:float,1)
270
+ read_float(p)
271
+ p.get_float32 0
272
+ end
273
+
274
+ def to_double
275
+ raise RuntimeError, "FileNode is empty" if empty?
276
+ raise RuntimeError, "FileNode is not storing a double" unless isReal
277
+ p = FFI::MemoryPointer.new(:uchar,8)
278
+ read_double(p)
279
+ p.get_float64 0
280
+ end
281
+
282
+ def to_int
283
+ raise RuntimeError, "FileNode is empty" if empty?
284
+ raise RuntimeError, "FileNode is not storing a double" unless isInt
285
+ p = FFI::MemoryPointer.new(:int,1)
286
+ read_int(p)
287
+ p.get_int32 0
288
+ end
289
+
290
+ def to_string
291
+ raise RuntimeError, "FileNode is empty" if empty?
292
+ raise RuntimeError, "FileNode is not storing a string" unless isString
293
+ str = cv::String.new
294
+ read_string(str)
295
+ str
296
+ end
297
+
298
+ def method_missing(m,*args)
299
+ if args.empty? && map?
300
+ self[m.to_s]
301
+ else
302
+ super
303
+ end
304
+ end
305
+ end
306
+
172
307
  class Mat
308
+ include Enumerable
173
309
  class << self
174
310
  alias :rbind_new :new
175
311
 
@@ -185,11 +321,13 @@ module OpenCV
185
321
 
186
322
  def self.to_native(obj,context)
187
323
  if obj.is_a?(Std::Vector::Cv_Point)
188
- cv::Mat.new(obj.size,2,cv::CV_32SC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
324
+ cv::Mat.new(obj.size,1,cv::CV_32SC2,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
189
325
  elsif obj.is_a?(Std::Vector::Cv_Point2f)
190
- cv::Mat.new(obj.size,2,cv::CV_32FC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
326
+ cv::Mat.new(obj.size,1,cv::CV_32FC2,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
191
327
  elsif obj.is_a?(Std::Vector::Cv_Point3f)
192
- cv::Mat.new(obj.size,3,cv::CV_32FC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
328
+ cv::Mat.new(obj.size,1,cv::CV_32FC3,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
329
+ elsif obj.is_a?(Std::Vector::Fixnum)
330
+ cv::Mat.new(obj.size,1,cv::CV_32SC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
193
331
  elsif obj.is_a?(Array)
194
332
  h,w,e= if obj.first.is_a? Array
195
333
  [obj.size,obj.first.size,obj.first.first]
@@ -381,6 +519,18 @@ module OpenCV
381
519
  pp.text str
382
520
  end
383
521
 
522
+ def each
523
+ if block_given?
524
+ 0.upto(rows-1) do |row|
525
+ 0.upto(cols-1) do |col|
526
+ yield at(row,col)
527
+ end
528
+ end
529
+ else
530
+ to_enum(:each)
531
+ end
532
+ end
533
+
384
534
  def each_row_with_index(&block)
385
535
  if block_given?
386
536
  r = rows
data/ropencv.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ropencv'
3
- s.version = '0.0.12'
4
- s.date = '2013-10-29'
3
+ s.version = '0.0.13'
4
+ s.date = '2013-12-12'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Alexander Duda']
7
7
  s.email = ['Alexander.Duda@dfki.de']
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.files = `git ls-files`.split("\n") + ["lib/ropencv/ropencv_types.rb","lib/ropencv/ropencv_ruby.rb"]
12
12
  s.require_path = 'lib'
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
- s.add_runtime_dependency "rbind", ">= 0.0.22"
14
+ s.add_runtime_dependency "rbind", ">= 0.0.23"
15
15
  s.add_runtime_dependency "ffi", "~> 1.9.0"
16
16
  s.extensions = ['ext/extconf.rb']
17
17
  s.license = 'BSD'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ropencv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Duda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-29 00:00:00.000000000 Z
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbind
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.22
19
+ version: 0.0.23
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.22
26
+ version: 0.0.23
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ffi
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,8 @@ files:
52
52
  - CMakeLists.txt
53
53
  - License.txt
54
54
  - README.md
55
+ - examples/file_storage.rb
56
+ - examples/find_homography.rb
55
57
  - examples/find_keypoints.rb
56
58
  - examples/hough_circles.rb
57
59
  - examples/logo.png
@@ -109,3 +111,4 @@ signing_key:
109
111
  specification_version: 4
110
112
  summary: Ruby bindings for opencv 2.4.4 and higher
111
113
  test_files: []
114
+ has_rdoc: