ropencv 0.0.13 → 0.0.14
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 +4 -4
- data/ext/helper.rb +4 -4
- data/ext/opencv.txt +13 -1
- data/ext/rbind.rb +8 -0
- data/lib/ropencv/ropencv_ruby.rb +52 -18
- data/ropencv.gemspec +3 -3
- data/test/test_mat.rb +25 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed24be2b4f9b19d2ab4170ad578b3d78d36958e4
|
4
|
+
data.tar.gz: 4d4520ac61ca76f16bf3a7961f6240f2c6cf9f10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47aea3c934fe8500236d0ad798dad58d6abaeafe1fe6c0e9fdf47635da080b6549df5ca777ed99a6b68c959c7a64d91db889c17c04a1091487189fe074e88cb9
|
7
|
+
data.tar.gz: b1e32dda67c171d45095c114b0550c0ebdd0c7bb46577636673be39edd95d98c965fbe208df74efa2fb32bcc5b3b4151bd492189e103c1220773d0162232e90b
|
data/ext/helper.rb
CHANGED
@@ -15,7 +15,7 @@ class OpenCVPtr < Rbind::RTemplateClass
|
|
15
15
|
klass.add_operation Rbind::ROperation.new("release",type("void"))
|
16
16
|
klass.add_operation Rbind::ROperation.new("delete_obj",type("void"))
|
17
17
|
klass.add_operation Rbind::ROperation.new("empty",type("bool"))
|
18
|
-
klass.add_attribute Rbind::RAttribute.new("obj",ptr_type.to_ptr)
|
18
|
+
klass.add_attribute Rbind::RAttribute.new("obj",ptr_type.to_ptr.to_ownership(false))
|
19
19
|
klass
|
20
20
|
end
|
21
21
|
|
@@ -44,7 +44,7 @@ class OpenCVPtr2 < Rbind::RTemplateClass
|
|
44
44
|
klass.add_operation Rbind::ROperation.new("release",type("void"))
|
45
45
|
klass.add_operation Rbind::ROperation.new("reset",type("void"),Rbind::RParameter.new("p",ptr_type.to_ptr))
|
46
46
|
klass.add_operation Rbind::ROperation.new("swap",type("void"),Rbind::RParameter.new("other",klass))
|
47
|
-
klass.add_operation Rbind::ROperation.new("get",ptr_type.to_ptr)
|
47
|
+
klass.add_operation Rbind::ROperation.new("get",ptr_type.to_ptr.to_ownership(false))
|
48
48
|
klass.add_operation Rbind::ROperation.new("empty",type("bool"))
|
49
49
|
klass
|
50
50
|
end
|
@@ -99,7 +99,7 @@ def find_opencv
|
|
99
99
|
"opencv2/core/core.hpp", "opencv2/flann/miniflann.hpp",
|
100
100
|
"opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/types_c.h",
|
101
101
|
"opencv2/imgproc/imgproc.hpp", "opencv2/photo/photo_c.h",
|
102
|
-
"opencv2/photo/photo.hpp", "opencv2/video/video.hpp",
|
102
|
+
"opencv2/photo/photo.hpp", "opencv2/video/video.hpp","opencv2/video/tracking.hpp",
|
103
103
|
"opencv2/features2d/features2d.hpp", "opencv2/objdetect/objdetect.hpp",
|
104
104
|
"opencv2/calib3d/calib3d.hpp", "opencv2/ml/ml.hpp",
|
105
105
|
"opencv2/highgui/highgui_c.h", "opencv2/highgui/highgui.hpp",
|
@@ -115,7 +115,7 @@ def find_opencv
|
|
115
115
|
"opencv2/nonfree/features2d.hpp", "opencv2/objdetect.hpp",
|
116
116
|
"opencv2/photo.hpp", "opencv2/softcascade.hpp",
|
117
117
|
"opencv2/stitching.hpp", "opencv2/superres.hpp",
|
118
|
-
"opencv2/video.hpp", "opencv2/legacy.hpp",
|
118
|
+
"opencv2/video.hpp", "opencv2/legacy.hpp","opencv2/video/tracking.hpp",
|
119
119
|
"opencv2/videostab.hpp"]
|
120
120
|
else
|
121
121
|
raise "OpenCV version #{opencv_version} is not supported"
|
data/ext/opencv.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
const cv.CV_LKFLOW_PYR_A_READY 1
|
2
|
+
const cv.CV_LKFLOW_PYR_B_READY 2
|
3
|
+
const cv.CV_LKFLOW_INITIAL_GUESSES 4
|
4
|
+
const cv.CV_LKFLOW_GET_MIN_EIGENVALS 8
|
1
5
|
const cv.INT_MAX 2147483647
|
2
6
|
const cv.CV_8U 0
|
3
7
|
const cv.CV_8S 1
|
@@ -274,7 +278,6 @@ cv.Rect.size Size
|
|
274
278
|
cv.Rect.area int
|
275
279
|
cv.Rect.contains bool
|
276
280
|
Point point
|
277
|
-
class CvTermCriteria
|
278
281
|
class CvDTreeNode
|
279
282
|
class CvSlice
|
280
283
|
class cvflann.flann_algorithm_t
|
@@ -291,6 +294,15 @@ cv.RotatedRect.RotatedRect
|
|
291
294
|
cv.RotatedRect.boundingRect Rect
|
292
295
|
class cv.FileNode
|
293
296
|
class cv.TermCriteria
|
297
|
+
cv.TermCriteria.TermCriteria
|
298
|
+
int type /RW
|
299
|
+
int maxCount /RW
|
300
|
+
double epsilon /RW
|
301
|
+
cv.TermCriteria.TermCriteria
|
302
|
+
int type
|
303
|
+
int maxCount
|
304
|
+
double epsilon
|
305
|
+
class CvTermCriteria
|
294
306
|
class cv.flann::IndexParams
|
295
307
|
class cv.flann::SearchParams
|
296
308
|
class cv.FeatureDetector
|
data/ext/rbind.rb
CHANGED
@@ -48,6 +48,14 @@ elsif opencv_version >= "3.0.0"
|
|
48
48
|
rbind.cv.AlignMTB.process[1].parameter(1).remove_const!
|
49
49
|
end
|
50
50
|
|
51
|
+
rbind.cv.calcOpticalFlowSF[0].parameter(0).remove_const!
|
52
|
+
rbind.cv.calcOpticalFlowSF[0].parameter(1).remove_const!
|
53
|
+
rbind.cv.calcOpticalFlowSF[0].parameter(2).remove_const!
|
54
|
+
|
55
|
+
rbind.cv.calcOpticalFlowSF[1].parameter(0).remove_const!
|
56
|
+
rbind.cv.calcOpticalFlowSF[1].parameter(1).remove_const!
|
57
|
+
rbind.cv.calcOpticalFlowSF[1].parameter(2).remove_const!
|
58
|
+
|
51
59
|
rbind.cv.CascadeClassifier.detectMultiScale[1].parameter(2).remove_const!
|
52
60
|
rbind.cv.CascadeClassifier.detectMultiScale[1].parameter(3).remove_const!
|
53
61
|
|
data/lib/ropencv/ropencv_ruby.rb
CHANGED
@@ -25,13 +25,13 @@ module OpenCV
|
|
25
25
|
if obj.is_a?(Vector::Std_Vector_Cv_Point2f)
|
26
26
|
t = Vector::Cv_Mat.new
|
27
27
|
obj.each do |e|
|
28
|
-
t <<
|
28
|
+
t << Cv::Mat.new(e.size,2,Cv::CV_32FC1,e.data,Cv::Mat::AUTO_STEP)
|
29
29
|
end
|
30
30
|
t.__obj_ptr__
|
31
31
|
elsif obj.is_a?(Vector::Std_Vector_Cv_Point)
|
32
32
|
t = Vector::Cv_Mat.new
|
33
33
|
obj.each do |e|
|
34
|
-
t <<
|
34
|
+
t << Cv::Mat.new(e.size,2,Cv::CV_32SC1,e.data,Cv::Mat::AUTO_STEP)
|
35
35
|
end
|
36
36
|
t.__obj_ptr__
|
37
37
|
else
|
@@ -44,6 +44,10 @@ module OpenCV
|
|
44
44
|
include Std
|
45
45
|
|
46
46
|
module Cv
|
47
|
+
# reflect some typedefs
|
48
|
+
GoodFeatureToTrackDetector = GFTTDetector if defined? GFTTDetector
|
49
|
+
StarFeatureDetector = StarDetector if defined? StarDetector
|
50
|
+
|
47
51
|
def self.min_max_loc(src,min_loc = Point.new,max_loc = Point.new,mask = Mat.new)
|
48
52
|
p = FFI::MemoryPointer.new(:double,2)
|
49
53
|
Rbind::cv_min_max_loc(src, p[0], p[1], min_loc, max_loc, mask)
|
@@ -258,7 +262,7 @@ module OpenCV
|
|
258
262
|
def to_mat
|
259
263
|
raise RuntimeError, "FileNode is empty" if empty?
|
260
264
|
raise RuntimeError, "FileNode is not storing a Mat" unless isMap
|
261
|
-
val =
|
265
|
+
val = Cv::Mat.new
|
262
266
|
read_mat(val)
|
263
267
|
val
|
264
268
|
end
|
@@ -290,7 +294,7 @@ module OpenCV
|
|
290
294
|
def to_string
|
291
295
|
raise RuntimeError, "FileNode is empty" if empty?
|
292
296
|
raise RuntimeError, "FileNode is not storing a string" unless isString
|
293
|
-
str =
|
297
|
+
str = Cv::String.new
|
294
298
|
read_string(str)
|
295
299
|
str
|
296
300
|
end
|
@@ -321,25 +325,33 @@ module OpenCV
|
|
321
325
|
|
322
326
|
def self.to_native(obj,context)
|
323
327
|
if obj.is_a?(Std::Vector::Cv_Point)
|
324
|
-
|
328
|
+
Cv::Mat.new(obj.size,1,Cv::CV_32SC2,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
325
329
|
elsif obj.is_a?(Std::Vector::Cv_Point2f)
|
326
|
-
|
330
|
+
Cv::Mat.new(obj.size,1,Cv::CV_32FC2,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
327
331
|
elsif obj.is_a?(Std::Vector::Cv_Point3f)
|
328
|
-
|
332
|
+
Cv::Mat.new(obj.size,1,Cv::CV_32FC3,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
329
333
|
elsif obj.is_a?(Std::Vector::Fixnum)
|
330
|
-
|
334
|
+
Cv::Mat.new(obj.size,1,Cv::CV_32SC1,obj.data,Cv::Mat::AUTO_STEP).__obj_ptr__
|
331
335
|
elsif obj.is_a?(Array)
|
332
336
|
h,w,e= if obj.first.is_a? Array
|
333
|
-
|
337
|
+
if obj.find {|array| array.find(Float)}
|
338
|
+
[obj.size,obj.first.size,obj.first.first.to_f]
|
339
|
+
else
|
340
|
+
[obj.size,obj.first.size,obj.first.first]
|
341
|
+
end
|
334
342
|
else
|
335
|
-
|
343
|
+
if obj.find(Float)
|
344
|
+
[obj.size,1,obj.first.to_f]
|
345
|
+
else
|
346
|
+
[obj.size,1,obj.first]
|
347
|
+
end
|
336
348
|
end
|
337
349
|
setter,step,type = if e.is_a? Fixnum
|
338
350
|
[:put_array_of_int32,4*w,CV_32SC1]
|
339
351
|
elsif e.is_a? Float
|
340
352
|
[:put_array_of_float64,8*w,CV_64FC1]
|
341
353
|
else
|
342
|
-
raise ArgumentError,"cannot connvert array of #{e.class} to
|
354
|
+
raise ArgumentError,"cannot connvert array of #{e.class} to Cv::Mat"
|
343
355
|
end
|
344
356
|
mat = Mat.new(h,w,type)
|
345
357
|
ptr = mat.data
|
@@ -359,10 +371,11 @@ module OpenCV
|
|
359
371
|
end
|
360
372
|
|
361
373
|
def -@
|
362
|
-
|
374
|
+
Cv::Mat.zeros(rows,cols,type)-self
|
363
375
|
end
|
364
376
|
|
365
|
-
def at(i,j=nil)
|
377
|
+
def at(i,j=nil,k=0)
|
378
|
+
raise ArgumentError,"channel #{k} out of bound" if k >= channels
|
366
379
|
i,j = if j == nil
|
367
380
|
if i.is_a?(Cv::Point)
|
368
381
|
[i.y,i.x]
|
@@ -377,6 +390,7 @@ module OpenCV
|
|
377
390
|
if i >= rows || i < 0 || j >= cols || j <0
|
378
391
|
raise ArgumentError,"out of bound #{i}/#{j} #{rows}/#{cols}"
|
379
392
|
end
|
393
|
+
j = j*channels+k
|
380
394
|
case type & 7
|
381
395
|
when CV_8U
|
382
396
|
data.get_uint8(i*step+j)
|
@@ -422,7 +436,14 @@ module OpenCV
|
|
422
436
|
end
|
423
437
|
end
|
424
438
|
|
425
|
-
def set(i,j,val=nil)
|
439
|
+
def set(i,j,k=nil,val=nil)
|
440
|
+
k,val = if val == nil
|
441
|
+
[val,k]
|
442
|
+
else
|
443
|
+
[k,val]
|
444
|
+
end
|
445
|
+
k ||= 0
|
446
|
+
raise ArgumentError,"channel #{k} out of bound" if k >= channels
|
426
447
|
i,j,val = if val == nil
|
427
448
|
if i.is_a?(Cv::Point)
|
428
449
|
[i.y,i.x,j]
|
@@ -437,6 +458,7 @@ module OpenCV
|
|
437
458
|
if i >= rows || i < 0 || j >= cols || j <0
|
438
459
|
raise ArgumentError,"out of bound #{i}/#{j}"
|
439
460
|
end
|
461
|
+
j = j*channels+k
|
440
462
|
case type & 7
|
441
463
|
when CV_8U
|
442
464
|
data.put_uint8(i*step+j,val)
|
@@ -455,12 +477,12 @@ module OpenCV
|
|
455
477
|
end
|
456
478
|
end
|
457
479
|
|
458
|
-
def [](i,j=nil)
|
459
|
-
at(i,j)
|
480
|
+
def [](i,j=nil,k=0)
|
481
|
+
at(i,j,k)
|
460
482
|
end
|
461
483
|
|
462
|
-
def []=(i,j,val=nil)
|
463
|
-
set(i,j,val)
|
484
|
+
def []=(i,j,k=nil,val=nil)
|
485
|
+
set(i,j,k,val)
|
464
486
|
end
|
465
487
|
|
466
488
|
def -(val)
|
@@ -573,6 +595,18 @@ module OpenCV
|
|
573
595
|
end
|
574
596
|
end
|
575
597
|
|
598
|
+
# returns a string compatible to matlab's MAT-file
|
599
|
+
def to_MAT(variable_name)
|
600
|
+
<<eos
|
601
|
+
# Created by ropencv, #{Time.now}
|
602
|
+
# name: #{variable_name}
|
603
|
+
# type: matrix
|
604
|
+
# rows: #{rows}
|
605
|
+
# columns: #{cols}
|
606
|
+
#{to_a.map{|row|row.join(" ")}.join("\n")}
|
607
|
+
eos
|
608
|
+
end
|
609
|
+
|
576
610
|
def to_a
|
577
611
|
h,w,c,s,ptr = [rows,cols,channels,step,data]
|
578
612
|
getter = case type & 7
|
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.
|
4
|
-
s.date = '
|
3
|
+
s.version = '0.0.14'
|
4
|
+
s.date = '2014-02-16'
|
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.
|
14
|
+
s.add_runtime_dependency "rbind", ">= 0.0.24"
|
15
15
|
s.add_runtime_dependency "ffi", "~> 1.9.0"
|
16
16
|
s.extensions = ['ext/extconf.rb']
|
17
17
|
s.license = 'BSD'
|
data/test/test_mat.rb
CHANGED
@@ -127,6 +127,17 @@ describe Cv::Mat do
|
|
127
127
|
mat = cv::Mat.new([1,2,3],[3,3,3],[5,6,7])
|
128
128
|
assert_equal 6, mat[2,1]
|
129
129
|
end
|
130
|
+
|
131
|
+
it "can access different channels" do
|
132
|
+
mats = std::Vector.new(cv::Mat)
|
133
|
+
mats.push_back(cv::Mat::zeros(10,10,cv::CV_8UC1))
|
134
|
+
mats.push_back(cv::Mat::ones(10,10,cv::CV_8UC1))
|
135
|
+
mat = cv::Mat.new
|
136
|
+
cv::merge(mats,mat)
|
137
|
+
|
138
|
+
assert_equal 0, mat[9,9]
|
139
|
+
assert_equal 1, mat[8,8,1]
|
140
|
+
end
|
130
141
|
end
|
131
142
|
|
132
143
|
describe "[]=" do
|
@@ -136,5 +147,19 @@ describe Cv::Mat do
|
|
136
147
|
mat[1,2] = 4
|
137
148
|
assert_equal [[1,2,3],[3,3,4],[5,6,7]], mat.to_a
|
138
149
|
end
|
150
|
+
|
151
|
+
it "can change different channels" do
|
152
|
+
mats = std::Vector.new(cv::Mat)
|
153
|
+
mat = cv::Mat::zeros(10,10,cv::CV_32FC3)
|
154
|
+
|
155
|
+
mat[9,9,0] = 123
|
156
|
+
mat[9,9,1] = 130
|
157
|
+
mat[9,9,2] = 140
|
158
|
+
|
159
|
+
cv::split(mat,mats)
|
160
|
+
assert_equal 123.0, mats[0][9,9]
|
161
|
+
assert_equal 130.0, mats[1][9,9]
|
162
|
+
assert_equal 140.0, mats[2][9,9]
|
163
|
+
end
|
139
164
|
end
|
140
165
|
end
|
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.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Duda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-16 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.
|
19
|
+
version: 0.0.24
|
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.
|
26
|
+
version: 0.0.24
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ffi
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|