opencv-ffi 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.
- data/.gitignore +7 -0
- data/Gemfile +15 -0
- data/README.md +126 -0
- data/Rakefile +52 -0
- data/docs/DocsIndex.md +1 -0
- data/docs/examples/load_image.rb +25 -0
- data/ext/Rakefile +13 -0
- data/ext/aishack-sift/.gitignore +4 -0
- data/ext/aishack-sift/Descriptor.h +34 -0
- data/ext/aishack-sift/KeyPoint.h +38 -0
- data/ext/aishack-sift/README +20 -0
- data/ext/aishack-sift/SIFT.cpp +1036 -0
- data/ext/aishack-sift/SIFT.h +84 -0
- data/ext/aishack-sift/example/.gitignore +2 -0
- data/ext/aishack-sift/example/Makefile +24 -0
- data/ext/aishack-sift/example/MySIFT.cpp +29 -0
- data/ext/aishack-sift/mkrf_conf.rb +13 -0
- data/ext/aishack-sift/siftlib.cpp +85 -0
- data/ext/eigen/.gitignore +4 -0
- data/ext/eigen/eigen_polynomial.cpp +41 -0
- data/ext/eigen/eigen_svd.cpp +100 -0
- data/ext/eigen/mkrf_conf.rb +14 -0
- data/ext/mkrf-monkey.rb +85 -0
- data/ext/mkrf-rakehelper-monkey.rb +52 -0
- data/ext/mkrf_conf.rb +3 -0
- data/ext/opencv-ffi/.gitignore +4 -0
- data/ext/opencv-ffi/matcher_helper.cpp +56 -0
- data/ext/opencv-ffi/mkrf_conf.rb +12 -0
- data/ext/opencv-ffi/vector_math.cpp +39 -0
- data/ext/opensurf/.gitignore +4 -0
- data/ext/opensurf/README +38 -0
- data/ext/opensurf/fasthessian.cpp +376 -0
- data/ext/opensurf/fasthessian.h +108 -0
- data/ext/opensurf/integral.cpp +58 -0
- data/ext/opensurf/integral.h +55 -0
- data/ext/opensurf/ipoint.cpp +108 -0
- data/ext/opensurf/ipoint.h +76 -0
- data/ext/opensurf/kmeans.h +172 -0
- data/ext/opensurf/mkrf_conf.rb +10 -0
- data/ext/opensurf/responselayer.h +92 -0
- data/ext/opensurf/surf.cpp +317 -0
- data/ext/opensurf/surf.h +66 -0
- data/ext/opensurf/surflib.cpp +98 -0
- data/ext/opensurf/surflib.h +96 -0
- data/ext/opensurf/utils.cpp +357 -0
- data/ext/opensurf/utils.h +63 -0
- data/lib/.gitignore +1 -0
- data/lib/opencv-ffi-ext/eigen.rb +84 -0
- data/lib/opencv-ffi-ext/features2d.rb +4 -0
- data/lib/opencv-ffi-ext/matcher_helper.rb +24 -0
- data/lib/opencv-ffi-ext/opensurf.rb +217 -0
- data/lib/opencv-ffi-ext/sift.rb +118 -0
- data/lib/opencv-ffi-ext/vector_math.rb +115 -0
- data/lib/opencv-ffi-wrappers.rb +7 -0
- data/lib/opencv-ffi-wrappers/core.rb +24 -0
- data/lib/opencv-ffi-wrappers/core/iplimage.rb +50 -0
- data/lib/opencv-ffi-wrappers/core/mat.rb +268 -0
- data/lib/opencv-ffi-wrappers/core/misc_draw.rb +44 -0
- data/lib/opencv-ffi-wrappers/core/point.rb +286 -0
- data/lib/opencv-ffi-wrappers/core/rect.rb +40 -0
- data/lib/opencv-ffi-wrappers/core/scalar.rb +104 -0
- data/lib/opencv-ffi-wrappers/core/size.rb +88 -0
- data/lib/opencv-ffi-wrappers/enumerable.rb +10 -0
- data/lib/opencv-ffi-wrappers/features2d.rb +17 -0
- data/lib/opencv-ffi-wrappers/features2d/image_patch.rb +322 -0
- data/lib/opencv-ffi-wrappers/features2d/star.rb +111 -0
- data/lib/opencv-ffi-wrappers/features2d/surf.rb +115 -0
- data/lib/opencv-ffi-wrappers/highgui.rb +10 -0
- data/lib/opencv-ffi-wrappers/imgproc.rb +4 -0
- data/lib/opencv-ffi-wrappers/imgproc/features.rb +35 -0
- data/lib/opencv-ffi-wrappers/imgproc/geometric.rb +39 -0
- data/lib/opencv-ffi-wrappers/matcher.rb +297 -0
- data/lib/opencv-ffi-wrappers/matrix.rb +37 -0
- data/lib/opencv-ffi-wrappers/misc.rb +41 -0
- data/lib/opencv-ffi-wrappers/misc/params.rb +34 -0
- data/lib/opencv-ffi-wrappers/sequence.rb +37 -0
- data/lib/opencv-ffi-wrappers/vectors.rb +38 -0
- data/lib/opencv-ffi.rb +12 -0
- data/lib/opencv-ffi/calib3d.rb +26 -0
- data/lib/opencv-ffi/core.rb +15 -0
- data/lib/opencv-ffi/core/draw.rb +68 -0
- data/lib/opencv-ffi/core/dynamic.rb +13 -0
- data/lib/opencv-ffi/core/library.rb +5 -0
- data/lib/opencv-ffi/core/operations.rb +122 -0
- data/lib/opencv-ffi/core/point.rb +22 -0
- data/lib/opencv-ffi/core/types.rb +172 -0
- data/lib/opencv-ffi/cvffi.rb +8 -0
- data/lib/opencv-ffi/features2d.rb +7 -0
- data/lib/opencv-ffi/features2d/library.rb +6 -0
- data/lib/opencv-ffi/features2d/star.rb +30 -0
- data/lib/opencv-ffi/features2d/surf.rb +38 -0
- data/lib/opencv-ffi/highgui.rb +31 -0
- data/lib/opencv-ffi/imgproc.rb +9 -0
- data/lib/opencv-ffi/imgproc/features.rb +37 -0
- data/lib/opencv-ffi/imgproc/geometric.rb +42 -0
- data/lib/opencv-ffi/imgproc/library.rb +6 -0
- data/lib/opencv-ffi/imgproc/misc.rb +39 -0
- data/lib/opencv-ffi/version.rb +3 -0
- data/opencv-ffi.gemspec +26 -0
- data/test/core/test_draw.rb +46 -0
- data/test/core/test_operations.rb +135 -0
- data/test/core/test_size.rb +14 -0
- data/test/core/test_text.rb +52 -0
- data/test/ext/test_eigen.rb +105 -0
- data/test/ext/test_opensurf.rb +35 -0
- data/test/ext/test_sift.rb +26 -0
- data/test/ext/test_vector_math.rb +85 -0
- data/test/features2d/test_surf.rb +63 -0
- data/test/imgproc/test_goodfeatures.rb +18 -0
- data/test/setup.rb +65 -0
- data/test/test_calib3d.rb +38 -0
- data/test/test_core.rb +26 -0
- data/test/test_ext.rb +8 -0
- data/test/test_features2d.rb +9 -0
- data/test/test_files/images/IMG_7088.JPG +0 -0
- data/test/test_files/images/IMG_7088_small.JPG +0 -0
- data/test/test_files/images/IMG_7089.JPG +0 -0
- data/test/test_highgui.rb +26 -0
- data/test/test_imgproc.rb +35 -0
- data/test/test_wrappers.rb +8 -0
- data/test/wrappers/core/test_draw.rb +41 -0
- data/test/wrappers/core/test_mat.rb +40 -0
- data/test/wrappers/core/test_operations.rb +35 -0
- data/test/wrappers/core/test_types.rb +235 -0
- data/test/wrappers/features2d/test_image_patch.rb +108 -0
- data/test/wrappers/test_imgproc.rb +87 -0
- data/test/wrappers/test_matcher.rb +96 -0
- data/test/wrappers/test_star.rb +28 -0
- data/test/wrappers/test_surf.rb +36 -0
- metadata +234 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
class Matrix
|
|
3
|
+
|
|
4
|
+
def to_Matrix
|
|
5
|
+
self
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Painful but that's OK...
|
|
9
|
+
def to_CvMat( opts = {} )
|
|
10
|
+
type = opts[:type] || :CV_32F
|
|
11
|
+
a = CVFFI::cvCreateMat( row_size, column_size, type )
|
|
12
|
+
each_with_index { |e,i,j|
|
|
13
|
+
a.set_f( i, j, e )
|
|
14
|
+
}
|
|
15
|
+
a
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Vector
|
|
21
|
+
|
|
22
|
+
def to_Vector
|
|
23
|
+
self
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_CvMat( opts = {} )
|
|
27
|
+
type = opts[:type] || :CV_32F
|
|
28
|
+
a = CVFFI::cvCreateMat( size, 1, type )
|
|
29
|
+
size.times { |i|
|
|
30
|
+
CVFFI::cvSetReal1D( a, i, element(i))
|
|
31
|
+
}
|
|
32
|
+
a
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'opencv-ffi/core/types'
|
|
2
|
+
|
|
3
|
+
module CVFFI
|
|
4
|
+
|
|
5
|
+
def self.print_matrix(m, opts={})
|
|
6
|
+
opts ||= {}
|
|
7
|
+
opts = { :caption=>opts } if opts.is_a? String
|
|
8
|
+
puts opts[:caption] if opts[:caption]
|
|
9
|
+
|
|
10
|
+
# Lots of potential to make this better...
|
|
11
|
+
f = '%'
|
|
12
|
+
case opts[:format]
|
|
13
|
+
when :e, :exp, :exponential
|
|
14
|
+
f += '- 10.5e'
|
|
15
|
+
else
|
|
16
|
+
f += '- 10.5f'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
nChannels = CVFFI::matChannels(m)
|
|
20
|
+
# puts "#{nChannels} channel data"
|
|
21
|
+
|
|
22
|
+
m.height.times { |i|
|
|
23
|
+
m.width.times {|j|
|
|
24
|
+
scalar = CVFFI::cvGet2D( m, i, j )
|
|
25
|
+
case nChannels
|
|
26
|
+
when 1
|
|
27
|
+
printf "#{f} ", scalar.w
|
|
28
|
+
when 2
|
|
29
|
+
printf "[#{f} #{f}] ", scalar.w, scalar.x
|
|
30
|
+
when 3
|
|
31
|
+
printf "[#{f} #{f} #{f}] ", scalar.w, scalar.x, scalar.y
|
|
32
|
+
when 4
|
|
33
|
+
printf "[#{f} #{f} #{f} #{f}] ", scalar.w, scalar.x, scalar.y, scalar.z
|
|
34
|
+
end
|
|
35
|
+
}
|
|
36
|
+
puts
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
require 'opencv-ffi'
|
|
3
|
+
|
|
4
|
+
module CVFFI
|
|
5
|
+
|
|
6
|
+
class Params
|
|
7
|
+
|
|
8
|
+
def self.defaults; @defaults ||= {}; end
|
|
9
|
+
def defaults; self.class.defaults; end
|
|
10
|
+
|
|
11
|
+
def self.param( *args )
|
|
12
|
+
while args.length > 0
|
|
13
|
+
default,name = [args.pop, args.pop]
|
|
14
|
+
defaults[ name ] = default
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attr_reader :params
|
|
19
|
+
|
|
20
|
+
def initialize( opts = {} )
|
|
21
|
+
@params = {}
|
|
22
|
+
self.class.defaults.each_key { |k|
|
|
23
|
+
@params[k] = (opts[k] or opts[k.to_s] or self.class.defaults[k])
|
|
24
|
+
define_singleton_method( k ) { @params[k] }
|
|
25
|
+
instance_eval "def #{k}=(a); @params[:#{k}] = a; end"
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def to_hash
|
|
30
|
+
@params
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
require 'opencv-ffi/core/dynamic'
|
|
3
|
+
|
|
4
|
+
module CVFFI
|
|
5
|
+
|
|
6
|
+
class Sequence
|
|
7
|
+
include Enumerable
|
|
8
|
+
|
|
9
|
+
attr_accessor :seq
|
|
10
|
+
|
|
11
|
+
def initialize( seq )
|
|
12
|
+
raise "Don't know how to handle class #{seq.class}" unless seq.is_a?(CvSeq)
|
|
13
|
+
@seq = seq
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def each
|
|
17
|
+
size.times { |i|
|
|
18
|
+
yield CVFFI::cvGetSeqElem( @seq, i )
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def push( a )
|
|
23
|
+
CVFFI::cvSeqPush( @seq, a )
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def size
|
|
27
|
+
@seq.total
|
|
28
|
+
end
|
|
29
|
+
alias :length :size
|
|
30
|
+
|
|
31
|
+
def [](i)
|
|
32
|
+
CVFFI::cvGetSeqElem( @seq, i )
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
require 'nice-ffi'
|
|
3
|
+
|
|
4
|
+
module CVFFI
|
|
5
|
+
|
|
6
|
+
class FloatArrayCommon < NiceFFI::Struct
|
|
7
|
+
include Enumerable
|
|
8
|
+
|
|
9
|
+
class << self; attr_accessor :nElem; end
|
|
10
|
+
|
|
11
|
+
def nElem; self.class.nElem; end
|
|
12
|
+
alias :length :nElem
|
|
13
|
+
|
|
14
|
+
def each
|
|
15
|
+
nElem.times { |i|
|
|
16
|
+
yield d[i]
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#def [](i)
|
|
21
|
+
# d[i]
|
|
22
|
+
#end
|
|
23
|
+
|
|
24
|
+
#def []=(i)
|
|
25
|
+
# d[i] = i
|
|
26
|
+
#end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class Float64 < FloatArrayCommon
|
|
30
|
+
@nElem = 64
|
|
31
|
+
layout :d, [ :float, @nElem ]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Float128 < FloatArrayCommon
|
|
35
|
+
@nElem = 128
|
|
36
|
+
layout :d, [ :float, @nElem ]
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/opencv-ffi.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
require 'opencv-ffi/cvffi'
|
|
3
|
+
require 'opencv-ffi/core'
|
|
4
|
+
|
|
5
|
+
module CVFFI
|
|
6
|
+
load_library("opencv_calib3d", @pathset)
|
|
7
|
+
|
|
8
|
+
enum :cvRansacMethod, [ :CV_FM_7POINT, 1,
|
|
9
|
+
:CV_FM_8POINT, 2,
|
|
10
|
+
:CV_FM_LMEDS, 4,
|
|
11
|
+
:CV_FM_RANSAC, 8 ]
|
|
12
|
+
|
|
13
|
+
# CVAPI(int) cvFindFundamentalMat( const CvMat* points1,
|
|
14
|
+
# const CvMat* points2,
|
|
15
|
+
# CvMat* fundamental_matrix,
|
|
16
|
+
# int method CV_DEFAULT(CV_FM_RANSAC),
|
|
17
|
+
# double param1 CV_DEFAULT(3.),
|
|
18
|
+
# double param2 CV_DEFAULT(0.99),
|
|
19
|
+
# CvMat* status CV_DEFAULT(NULL) );
|
|
20
|
+
attach_function :cvFindFundamentalMat, [ :pointer, :pointer, :pointer,
|
|
21
|
+
:int, :double, :double, :pointer ], :int
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## An omnibus file which brings in all the core/* sub-files
|
|
2
|
+
|
|
3
|
+
require 'opencv-ffi/core/library'
|
|
4
|
+
|
|
5
|
+
module CVFFI
|
|
6
|
+
|
|
7
|
+
enum :cvBoolean, [ :false, 0,
|
|
8
|
+
:true ]
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require 'opencv-ffi/core/types'
|
|
13
|
+
require 'opencv-ffi/core/dynamic'
|
|
14
|
+
require 'opencv-ffi/core/draw'
|
|
15
|
+
require 'opencv-ffi/core/operations'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
require 'opencv-ffi/core/library'
|
|
3
|
+
require 'opencv-ffi/core/types'
|
|
4
|
+
|
|
5
|
+
module CVFFI
|
|
6
|
+
|
|
7
|
+
CvFontDefines = enum [:CV_FONT_HERSHEY_SIMPLEX, 0,
|
|
8
|
+
:CV_FONT_HERSHEY_PLAIN,
|
|
9
|
+
:CV_FONT_HERSHEY_DUPLEX,
|
|
10
|
+
:CV_FONT_HERSHEY_COMPLEX,
|
|
11
|
+
:CV_FONT_HERSHEY_TRIPLEX,
|
|
12
|
+
:CV_FONT_HERSHEY_COMPLEX_SMALL,
|
|
13
|
+
:CV_FONT_HERSHEY_SCRIPT_SIMPLEX,
|
|
14
|
+
:CV_FONT_HERSHEY_SCRIPT_COMPLEX,
|
|
15
|
+
:CV_FONT_NORMAL, 8,
|
|
16
|
+
:CV_FONT_ITALIC, 16 ]
|
|
17
|
+
|
|
18
|
+
enum [:CV_AA, 16]
|
|
19
|
+
|
|
20
|
+
class CvFont < NiceFFI::Struct
|
|
21
|
+
layout :nameFont, :string,
|
|
22
|
+
:color, CvScalar,
|
|
23
|
+
:font_face, :int,
|
|
24
|
+
:ascii, :pointer,
|
|
25
|
+
:greek, :pointer,
|
|
26
|
+
:cyrillic, :pointer,
|
|
27
|
+
:hscale, :float,
|
|
28
|
+
:vscale, :float,
|
|
29
|
+
:shear, :float,
|
|
30
|
+
:thickness, :int,
|
|
31
|
+
:dx, :float,
|
|
32
|
+
:line_type, :int
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# CVAPI(void) cvCircle( CvArr* img,
|
|
36
|
+
# CvPoint center,
|
|
37
|
+
# int radius,
|
|
38
|
+
# CvScalar color,
|
|
39
|
+
# int thickness CV_DEFAULT(1),
|
|
40
|
+
# int line_type CV_DEFAULT(8),
|
|
41
|
+
# int shift CV_DEFAULT(0));
|
|
42
|
+
attach_function :cvCircle, [ :pointer, CvPoint.by_value, :int,
|
|
43
|
+
CvScalar.by_value, :int, :int, :int ], :void
|
|
44
|
+
|
|
45
|
+
attach_function :cvGetTextSize, [ :string, :pointer, :pointer, :pointer ], :void
|
|
46
|
+
|
|
47
|
+
# CVAPI(void) cvInitFont( CvFont* font, int font_face,
|
|
48
|
+
# double hscale, double vscale,
|
|
49
|
+
# double shear CV_DEFAULT(0),
|
|
50
|
+
# int thickness CV_DEFAULT(1),
|
|
51
|
+
# int line_type CV_DEFAULT(8));
|
|
52
|
+
attach_function :cvInitFont, [:pointer, CvFontDefines, :double, :double, :double, :int, :int ], :void
|
|
53
|
+
#attach_function :cvFont, [:double, :int ], CvFont.by_value
|
|
54
|
+
|
|
55
|
+
# CVAPI(void) cvLine( CvArr* img,
|
|
56
|
+
# CvPoint pt1,
|
|
57
|
+
# CvPoint pt2,
|
|
58
|
+
# CvScalar color,
|
|
59
|
+
# int thickness CV_DEFAULT(1),
|
|
60
|
+
# int line_type CV_DEFAULT(8),
|
|
61
|
+
# int shift CV_DEFAULT(0) );
|
|
62
|
+
attach_function :cvLine, [ :pointer, CvPoint.by_value, CvPoint.by_value,
|
|
63
|
+
CvScalar.by_value, :int, :int, :int ], :void
|
|
64
|
+
|
|
65
|
+
attach_function :cvPutText, [ :pointer, :string,
|
|
66
|
+
CvPoint.by_value, :pointer,
|
|
67
|
+
CvScalar.by_value ], :void
|
|
68
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
require 'opencv-ffi/core/library'
|
|
3
|
+
require 'opencv-ffi/core/types'
|
|
4
|
+
|
|
5
|
+
module CVFFI
|
|
6
|
+
|
|
7
|
+
attach_function :cvCreateMemStorage, [ :int ], CvMemStorage.typed_pointer
|
|
8
|
+
attach_function :cvReleaseMemStorage, [:pointer], :void
|
|
9
|
+
|
|
10
|
+
attach_function :cvGetSeqElem, [ :pointer, :int ], :pointer
|
|
11
|
+
attach_function :cvSeqPush, [:pointer, :pointer ], :pointer
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
|
|
2
|
+
require 'opencv-ffi/core/library'
|
|
3
|
+
require 'opencv-ffi/core/types'
|
|
4
|
+
|
|
5
|
+
module CVFFI
|
|
6
|
+
|
|
7
|
+
CvMatType = enum :cvMatType, [ :CV_8U, 0,
|
|
8
|
+
:CV_8UC1, 0,
|
|
9
|
+
:CV_8S,
|
|
10
|
+
:CV_16U,
|
|
11
|
+
:CV_16S,
|
|
12
|
+
:CV_32S,
|
|
13
|
+
:CV_32F,
|
|
14
|
+
:CV_64F,
|
|
15
|
+
:CV_USRTYPE1,
|
|
16
|
+
:CV_8UC2, 8,
|
|
17
|
+
:CV_8SC2,
|
|
18
|
+
:CV_16UC2,
|
|
19
|
+
:CV_16SC2,
|
|
20
|
+
:CV_32SC2,
|
|
21
|
+
:CV_32FC2,
|
|
22
|
+
:CV_64FC2,
|
|
23
|
+
:CV_8UC3, 16,
|
|
24
|
+
:CV_8SC3,
|
|
25
|
+
:CV_16UC3,
|
|
26
|
+
:CV_16SC3,
|
|
27
|
+
:CV_32SC3,
|
|
28
|
+
:CV_32FC3,
|
|
29
|
+
:CV_64FC3 ]
|
|
30
|
+
|
|
31
|
+
## As present, the type encodes 9 bits of nChannels and 3 bits of typ
|
|
32
|
+
def self.matMagicType( m )
|
|
33
|
+
type = case m.type
|
|
34
|
+
when Fixnum
|
|
35
|
+
m.type
|
|
36
|
+
when Symbol
|
|
37
|
+
CvMatType[m.type]
|
|
38
|
+
else
|
|
39
|
+
raise "Can't convert #{m.type} to a numberic OpenCV type"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
type & 0xFFF
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.matChannels( m )
|
|
46
|
+
(matMagicType(m) >> 3) + 1
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# A bit clumsy
|
|
50
|
+
def self.matType( m )
|
|
51
|
+
case m.type & 0x7
|
|
52
|
+
when :CV_8U; :CV_8U
|
|
53
|
+
else
|
|
54
|
+
assert RuntimeError, "This shouldn't happen!"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
attach_function :cvAddWeighted, [ :pointer, :double, :pointer, :double, :double, :pointer ], :void
|
|
59
|
+
|
|
60
|
+
attach_function :cvCloneImage, [ :pointer ], IplImage.typed_pointer
|
|
61
|
+
attach_function :cvCloneMat, [ :pointer ], CvMat.typed_pointer
|
|
62
|
+
|
|
63
|
+
enum :cvCmpTypes, [ :CV_CMP_EQ, :CV_CMP_GT, :CV_CMP_GE, :CV_CMP_LT, :CV_CMP_LE, :CV_CMP_NE ]
|
|
64
|
+
attach_function :cvCmp, [:pointer, :pointer, :pointer, :int], :void
|
|
65
|
+
|
|
66
|
+
attach_function :cvCreateMat, [ :int, :int, :cvMatType ], CvMat.typed_pointer
|
|
67
|
+
attach_function :cvCreateImage, [ CvSize.by_value, :int, :int ], IplImage.typed_pointer
|
|
68
|
+
|
|
69
|
+
attach_function :cvCopy, [ :pointer, :pointer, :pointer ], :void
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
attach_function :cvSetImageROI, [:pointer, CvRect.by_value ], :void
|
|
73
|
+
attach_function :cvGetImageROI, [:pointer], CvRect.by_value
|
|
74
|
+
attach_function :cvResetImageROI, [:pointer], :void
|
|
75
|
+
|
|
76
|
+
# CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 );
|
|
77
|
+
attach_function :cvGet1D, [ :pointer, :int ], CvScalar.by_value
|
|
78
|
+
attach_function :cvGet2D, [ :pointer, :int, :int ], CvScalar.by_value
|
|
79
|
+
attach_function :cvGet3D, [ :pointer, :int, :int, :int ], CvScalar.by_value
|
|
80
|
+
|
|
81
|
+
attach_function :cvGetReal1D, [ :pointer, :int ], :double
|
|
82
|
+
attach_function :cvGetReal2D, [ :pointer, :int, :int ], :double
|
|
83
|
+
attach_function :cvGetReal3D, [ :pointer, :int, :int, :int ], :double
|
|
84
|
+
|
|
85
|
+
enum :cvNormTypes, [ :CV_C, 1,
|
|
86
|
+
:CV_L1, 2,
|
|
87
|
+
:CV_L2, 4 ]
|
|
88
|
+
attach_function :real_cvNorm, :cvNorm, [ :pointer, :pointer, :int, :pointer ], :double
|
|
89
|
+
def self.cvNorm( arr1, arr2 = nil, normType = :CV_L2, mask = nil )
|
|
90
|
+
real_cvNorm( arr1, arr2, normType, mask )
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
attach_function :cvSet, [ :pointer, CvScalar.by_value, :pointer ], :void
|
|
94
|
+
|
|
95
|
+
attach_function :cvSet1D, [ :pointer, :int, CvScalar.by_value ], :void
|
|
96
|
+
attach_function :cvSet2D, [ :pointer, :int, :int, CvScalar.by_value ], :void
|
|
97
|
+
attach_function :cvSet3D, [ :pointer, :int, :int, :int, CvScalar.by_value ], :void
|
|
98
|
+
|
|
99
|
+
attach_function :cvSetReal1D, [ :pointer, :int, :double ], :void
|
|
100
|
+
attach_function :cvSetReal2D, [ :pointer, :int, :int, :double ], :void
|
|
101
|
+
attach_function :cvSetReal3D, [ :pointer, :int, :int, :int, :double ], :void
|
|
102
|
+
|
|
103
|
+
attach_function :cvSetIdentity, [ :pointer, CvScalar.by_value ], :void
|
|
104
|
+
attach_function :cvSetZero, [ :pointer ], :void
|
|
105
|
+
|
|
106
|
+
attach_function :cvSolveCubic, [:pointer, :pointer ], :void
|
|
107
|
+
|
|
108
|
+
attach_function :cvSum, [:pointer], CvScalar.by_value
|
|
109
|
+
|
|
110
|
+
attach_function :cvTranspose, [:pointer, :pointer], :void
|
|
111
|
+
|
|
112
|
+
attach_function :cvReleaseMat, [ :pointer ], :void
|
|
113
|
+
attach_function :cvReleaseData, [ :pointer ], :void
|
|
114
|
+
|
|
115
|
+
# cvReleaseImage expects a double-pointer to an IplImage
|
|
116
|
+
attach_function :cvReleaseImageReal, :cvReleaseImage, [ :pointer ], :void
|
|
117
|
+
def self.cvReleaseImage( iplImage )
|
|
118
|
+
#ptr = FFI::MemoryPointer.new :pointer
|
|
119
|
+
#ptr.put_pointer(0, iplImage.to_ptr )
|
|
120
|
+
#cvReleaseImageReal iplImage
|
|
121
|
+
end
|
|
122
|
+
end
|