Module: CVFFI::CvMatFunctions
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#at_f(i, j) ⇒ Object
This is somewhat awkward because the FFI::Struct-iness of CvMat uses the Array-like API calls (at, [], size, etc).
- #at_scalar(i, j) ⇒ Object
- #clone ⇒ Object
-
#coerce(other) ⇒ Object
This is the somewhat funny Matrix format for coerce which returns the template class as well as the coerced version of the matrix.
- #mat_size ⇒ Object
- #print(opts = {}) ⇒ Object
- #set_f(i, j, f) ⇒ Object
- #set_scalar(i, j, f) ⇒ Object
- #to_a ⇒ Object
- #to_CvMat(opt = {}) ⇒ Object
- #to_Matrix ⇒ Object
- #to_ScalarMatrix ⇒ Object
- #to_Vector ⇒ Object
- #transpose ⇒ Object
- #twin ⇒ Object
- #zero ⇒ Object
Class Method Details
.included(base) ⇒ Object
24 25 26 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 24 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#at_f(i, j) ⇒ Object
This is somewhat awkward because the FFI::Struct-iness of CvMat uses the Array-like API calls (at, [], size, etc)
82 83 84 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 82 def at_f(i,j) CVFFI::cvGetReal2D( self, i, j ) end |
#at_scalar(i, j) ⇒ Object
90 91 92 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 90 def at_scalar(i,j) CVFFI::cvGet2D( self, i, j ) end |
#clone ⇒ Object
98 99 100 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 98 def clone CVFFI::cvCloneMat( self ) end |
#coerce(other) ⇒ Object
This is the somewhat funny Matrix format for coerce which returns the template class as well as the coerced version of the matrix
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 31 def coerce( other ) case other when Matrix [other, to_Matrix] when Vector [other, to_Vector] else raise TypeError, "#{self.class} can't be coerced into #{other.class}, fool" end end |
#mat_size ⇒ Object
102 103 104 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 102 def mat_size CVFFI::CvSize.new( :width => self.width, :height => self.height ) end |
#print(opts = {}) ⇒ Object
120 121 122 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 120 def print( opts = {} ) CVFFI::print_matrix( self, opts ) end |
#set_f(i, j, f) ⇒ Object
86 87 88 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 86 def set_f( i,j, f ) CVFFI::cvSetReal2D( self, i, j, f ) end |
#set_scalar(i, j, f) ⇒ Object
94 95 96 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 94 def set_scalar( i,j, f ) CVFFI::cvSet2D( self, i, j, f ) end |
#to_a ⇒ Object
76 77 78 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 76 def to_a to_Vector.to_a end |
#to_CvMat(opt = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 43 def to_CvMat( opt = {} ) if opt[:type] raise "Need to convert CvMat types" if opt[:type] != type end self end |
#to_Matrix ⇒ Object
50 51 52 53 54 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 50 def to_Matrix Matrix.build( height, width ) { |i,j| at_f(i,j) } end |
#to_ScalarMatrix ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 56 def to_ScalarMatrix ScalarMatrix.rows Array.new( height ) { |y| Array.new( width ) { |x| d = CVFFI::cvGet2D( self, y,x ) d.w } } end |
#to_Vector ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 65 def to_Vector to_Matrix if height > 1 and width > 1 a = [] if height == 1 a = Array.new( width ) { |i| at_f(0,i) } else a = Array.new( height ) { |i| at_f(i,0) } end Vector[*a] end |
#transpose ⇒ Object
110 111 112 113 114 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 110 def transpose a = twin CVFFI::cvTranspose( self, a ) a end |
#twin ⇒ Object
106 107 108 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 106 def twin CVFFI::cvCreateMat( self.height, self.width, self.type ) end |
#zero ⇒ Object
116 117 118 |
# File 'lib/opencv-ffi-wrappers/core/mat.rb', line 116 def zero CVFFI::cvSetZero( self ) end |