Class: OpenCV::Cv::Mat
- Inherits:
-
Object
- Object
- OpenCV::Cv::Mat
- Extended by:
- FFI::DataConverter
- Includes:
- Enumerable
- Defined in:
- lib/ropencv/ropencv_ruby.rb,
lib/ropencv/ropencv_types.rb
Constants collapse
- MAGIC_VAL =
0- AUTO_STEP =
0- CONTINUOUS_FLAG =
CV_MAT_CONT_FLAG- SUBMATRIX_FLAG =
CV_SUBMAT_FLAG- MAGIC_MASK =
0- TYPE_MASK =
0- DEPTH_MASK =
7
Constant Summary collapse
- DISPLAYED_ROWS_MAX =
100- DISPLAYED_COLS_MAX =
100
Class Method Summary collapse
- .diag(d) ⇒ Cv::Mat
- .eye(*args) ⇒ Object
- .new(*args) ⇒ Object
-
.null ⇒ Object
returns a null pointer to the object.
- .ones(*args) ⇒ Object
- .rbind_new ⇒ Object
- .zeros(*args) ⇒ Object
Instance Method Summary collapse
- #!=(val) ⇒ Object
- #*(*args) ⇒ Object
- #+(*args) ⇒ Object
- #-(*args) ⇒ Object
- #-@ ⇒ Object
- #/(*args) ⇒ Object
- #<(val) ⇒ Object
- #<=(val) ⇒ Object
- #==(val) ⇒ Object
- #===(val) ⇒ Object
- #>(val) ⇒ Object
- #>=(val) ⇒ Object
- #[](i, j = nil, k = 0) ⇒ Object
- #[]=(i, j, k = nil, val = nil) ⇒ Object
- #assign_to(m, type = -1)) ⇒ Void (also: #assignTo)
- #at(i, j = nil, k = 0) ⇒ Object
- #block(rect) ⇒ Cv::Mat
- #channels ⇒ Fixnum
- #check_vector(elem_channels, depth = -1,, require_continuous = true) ⇒ Fixnum (also: #checkVector)
- #clone ⇒ Cv::Mat
- #coerce(other) ⇒ Object
- #col(c) ⇒ Cv::Mat
- #col_range(*args) ⇒ Object
- #cols ⇒ Fixnum (also: #get_cols)
- #compare(val, type) ⇒ Object
- #convert_to(m, rtype, alpha = 1, beta = 0) ⇒ Void (also: #convertTo)
- #copy_to(*args) ⇒ Object
- #create(*args) ⇒ Object
- #cross(m) ⇒ Cv::Mat
- #data ⇒ Uchar (also: #get_data)
- #depth ⇒ Fixnum
- #diag(d = 0) ⇒ Cv::Mat
- #dot(m) ⇒ Double
- #each ⇒ Object
- #each_col(&block) ⇒ Object
- #each_col_with_index(&block) ⇒ Object
- #each_row(&block) ⇒ Object
- #each_row_with_index(&block) ⇒ Object
- #elem_size ⇒ Size_T (also: #elemSize)
- #elem_size1 ⇒ Size_T (also: #elemSize1)
- #empty ⇒ Bool
-
#flags ⇒ Fixnum
(also: #get_flags)
methods.
- #inv(method = DECOMP_LU) ⇒ Cv::Mat
- #is_continuous ⇒ Bool (also: #isContinuous)
- #is_submatrix ⇒ Bool (also: #isSubmatrix)
- #mul(m, scale = 1) ⇒ Cv::Mat
- #pretty_print(pp) ⇒ Object
- #ptr(*args) ⇒ Object
- #reshape(cn, rows = 0) ⇒ Cv::Mat
- #row(y) ⇒ Cv::Mat
- #row_range(*args) ⇒ Object
- #rows ⇒ Fixnum (also: #get_rows)
- #set(i, j, k = nil, val = nil) ⇒ Object
- #size ⇒ Cv::Size
- #step ⇒ Size_T (also: #get_step)
- #step1(i = 0) ⇒ Size_T
- #t ⇒ Cv::Mat
- #to_a ⇒ Object
- #to_f ⇒ Object
- #to_i ⇒ Object
-
#to_MAT(variable_name) ⇒ Object
returns a string compatible to matlab's MAT-file.
-
#to_s ⇒ Object
converts Mat into a string by crawling through all its attributes.
- #total ⇒ Size_T
- #type ⇒ Fixnum
Class Method Details
.diag(d) ⇒ Cv::Mat
wrapper for static method cv::Mat cv::Mat::diag(const cv::Mat d)
13128 13129 13130 |
# File 'lib/ropencv/ropencv_types.rb', line 13128 def self.diag(d) Rbind::cv_mat_diag2(d) end |
.eye(rows, cols, type) ⇒ Cv::Mat .eye(size, type) ⇒ Cv::Mat
wrapper for overloaded static method eye
13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 |
# File 'lib/ropencv/ropencv_types.rb', line 13389 def self.eye(*args) # overloaded method wrapper for cv::Mat cv::Mat::eye(int rows, int cols, int type) @@cv_mat_eye_defaults0 ||= [nil, nil, nil] if(args.size >= 3 && args.size <= 3) targs = args.clone targs.size.upto(2) do |i| targs[i] = @@cv_mat_eye_defaults0[i] end begin result = Rbind::cv_mat_eye(*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end # overloaded method wrapper for cv::Mat cv::Mat::eye(const cv::Size size, int type) @@cv_mat_eye2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_eye2_defaults1[i] end begin result = Rbind::cv_mat_eye2(*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
.mat ⇒ Object .mat(m) ⇒ Object .mat(size, type) ⇒ Object .mat(rows, cols, type) ⇒ Object .mat(rows, cols, type, data, step = AUTO_STEP) ⇒ Object .mat(size, type, data, step = AUTO_STEP) ⇒ Object .mat(rows, cols, type, scalar) ⇒ Object .mat(size, type, scalar) ⇒ Object .mat(m, row_range, col_range = Cv::Range::all()) ⇒ Object .mat(m, roi) ⇒ Object
12486 12487 12488 12489 12490 12491 12492 12493 |
# File 'lib/ropencv/ropencv_types.rb', line 12486 def new(*args) # allow Mat.new([123,23],[2332,32]) if !args.find{|a| !a.is_a?(Array)} && args.size() > 1 rbind_new(args) else rbind_new(*args) end end |
.null ⇒ Object
returns a null pointer to the object
12436 12437 12438 |
# File 'lib/ropencv/ropencv_types.rb', line 12436 def self.null new(MatStruct.new) end |
.ones(rows, cols, type) ⇒ Cv::Mat .ones(size, type) ⇒ Cv::Mat
wrapper for overloaded static method ones
13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 |
# File 'lib/ropencv/ropencv_types.rb', line 13341 def self.ones(*args) # overloaded method wrapper for cv::Mat cv::Mat::ones(int rows, int cols, int type) @@cv_mat_ones_defaults0 ||= [nil, nil, nil] if(args.size >= 3 && args.size <= 3) targs = args.clone targs.size.upto(2) do |i| targs[i] = @@cv_mat_ones_defaults0[i] end begin result = Rbind::cv_mat_ones(*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end # overloaded method wrapper for cv::Mat cv::Mat::ones(const cv::Size size, int type) @@cv_mat_ones2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_ones2_defaults1[i] end begin result = Rbind::cv_mat_ones2(*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
.rbind_new ⇒ Object
324 |
# File 'lib/ropencv/ropencv_ruby.rb', line 324 alias :rbind_new :new |
.zeros(rows, cols, type) ⇒ Cv::Mat .zeros(size, type) ⇒ Cv::Mat
wrapper for overloaded static method zeros
13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 |
# File 'lib/ropencv/ropencv_types.rb', line 13293 def self.zeros(*args) # overloaded method wrapper for cv::Mat cv::Mat::zeros(int rows, int cols, int type) @@cv_mat_zeros_defaults0 ||= [nil, nil, nil] if(args.size >= 3 && args.size <= 3) targs = args.clone targs.size.upto(2) do |i| targs[i] = @@cv_mat_zeros_defaults0[i] end begin result = Rbind::cv_mat_zeros(*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end # overloaded method wrapper for cv::Mat cv::Mat::zeros(const cv::Size size, int type) @@cv_mat_zeros2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_zeros2_defaults1[i] end begin result = Rbind::cv_mat_zeros2(*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
Instance Method Details
#!=(val) ⇒ Object
677 678 679 |
# File 'lib/ropencv/ropencv_ruby.rb', line 677 def !=(val) compare(val,Cv::CMP_NE) end |
#*(mat) ⇒ Cv::Mat #*(val) ⇒ Cv::Mat #*(val) ⇒ Cv::Mat
wrapper for overloaded method *
12884 12885 12886 12887 12888 12889 12890 12891 12892 |
# File 'lib/ropencv/ropencv_types.rb', line 12884 def *(val) if val.is_a? Float Rbind::cv_mat_operator_mult2( self, val) elsif val.is_a? Fixnum Rbind::cv_mat_operator_mult3( self, val) else Rbind::cv_mat_operator_mult( self, val) end end |
#+(mat) ⇒ Cv::Mat #+(val) ⇒ Cv::Mat #+(val) ⇒ Cv::Mat
wrapper for overloaded method +
12766 12767 12768 12769 12770 12771 12772 12773 12774 |
# File 'lib/ropencv/ropencv_types.rb', line 12766 def +(val) if val.is_a? Float Rbind::cv_mat_operator_plus2( self, val) elsif val.is_a? Fixnum Rbind::cv_mat_operator_plus3( self, val) else Rbind::cv_mat_operator_plus( self, val) end end |
#-(mat) ⇒ Cv::Mat #-(val) ⇒ Cv::Mat #-(val) ⇒ Cv::Mat
wrapper for overloaded method -
12825 12826 12827 12828 12829 12830 12831 12832 12833 |
# File 'lib/ropencv/ropencv_types.rb', line 12825 def -(val) if val.is_a? Float Rbind::cv_mat_operator_minus2( self, val) elsif val.is_a? Fixnum Rbind::cv_mat_operator_minus3( self, val) else Rbind::cv_mat_operator_minus( self, val) end end |
#-@ ⇒ Object
391 392 393 |
# File 'lib/ropencv/ropencv_ruby.rb', line 391 def -@ Cv::Mat.zeros(rows,cols,type)-self end |
#/(mat) ⇒ Cv::Mat #/(val) ⇒ Cv::Mat #/(val) ⇒ Cv::Mat
wrapper for overloaded method /
12943 12944 12945 12946 12947 12948 12949 12950 12951 |
# File 'lib/ropencv/ropencv_types.rb', line 12943 def /(val) if val.is_a? Float Rbind::cv_mat_operator_div2( self, val) elsif val.is_a? Fixnum Rbind::cv_mat_operator_div3( self, val) else Rbind::cv_mat_operator_div( self, val) end end |
#<(val) ⇒ Object
669 670 671 |
# File 'lib/ropencv/ropencv_ruby.rb', line 669 def <(val) compare(val,Cv::CMP_LT) end |
#<=(val) ⇒ Object
673 674 675 |
# File 'lib/ropencv/ropencv_ruby.rb', line 673 def <=(val) compare(val,Cv::CMP_LE) end |
#==(val) ⇒ Object
657 658 659 |
# File 'lib/ropencv/ropencv_ruby.rb', line 657 def ==(val) compare(val,Cv::CMP_EQ) end |
#===(val) ⇒ Object
681 682 683 684 685 |
# File 'lib/ropencv/ropencv_ruby.rb', line 681 def ===(val) val = compare(val,Cv::CMP_EQ) count = cv::countNonZero(val) count == val.rows*val.cols end |
#>(val) ⇒ Object
661 662 663 |
# File 'lib/ropencv/ropencv_ruby.rb', line 661 def >(val) compare(val,Cv::CMP_GT) end |
#>=(val) ⇒ Object
665 666 667 |
# File 'lib/ropencv/ropencv_ruby.rb', line 665 def >=(val) compare(val,Cv::CMP_GE) end |
#[](i, j = nil, k = 0) ⇒ Object
498 499 500 |
# File 'lib/ropencv/ropencv_ruby.rb', line 498 def [](i,j=nil,k=0) at(i,j,k) end |
#[]=(i, j, k = nil, val = nil) ⇒ Object
502 503 504 |
# File 'lib/ropencv/ropencv_ruby.rb', line 502 def []=(i,j,k=nil,val=nil) set(i,j,k,val) end |
#assign_to(m, type = -1)) ⇒ Void Also known as: assignTo
method wrapper for void cv::Mat::assignTo(cv::Mat& m, int type = -1)
13202 13203 13204 13205 |
# File 'lib/ropencv/ropencv_types.rb', line 13202 def assign_to(m, type = -1) __validate_pointer__ Rbind::cv_mat_assign_to( self, m, type) end |
#at(i, j = nil, k = 0) ⇒ Object
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/ropencv/ropencv_ruby.rb', line 395 def at(i,j=nil,k=0) raise ArgumentError,"channel #{k} out of bound" if k >= channels i,j = if j == nil if i.is_a?(Cv::Point) [i.y,i.x] elsif rows == 1 [0,i] else [i,0] end else [i,j] end if i >= rows || i < 0 || j >= cols || j <0 raise ArgumentError,"out of bound #{i}/#{j} #{rows}/#{cols}" end j = j*channels+k case type & 7 when CV_8U data.get_uint8(i*step+j) when CV_16U data.get_uint16(i*step+j*2) when CV_16S data.get_int16(i*step+j*2) when CV_32S data.get_int32(i*step+j*4) when CV_32F data.get_float32(i*step+j*4) when CV_64F data.get_float64(i*step+j*8) else raise "cannot connvert #{self.class} of type #{type} to ruby" end end |
#block(rect) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::operator()(const cv::Rect rect)
13633 13634 13635 13636 13637 13638 13639 13640 13641 |
# File 'lib/ropencv/ropencv_types.rb', line 13633 def block(rect) __validate_pointer__ result = Rbind::cv_mat_block( self, rect) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#channels ⇒ Fixnum
method wrapper for int cv::Mat::channels()
13530 13531 13532 13533 |
# File 'lib/ropencv/ropencv_types.rb', line 13530 def channels() __validate_pointer__ Rbind::cv_mat_channels( self) end |
#check_vector(elem_channels, depth = -1,, require_continuous = true) ⇒ Fixnum Also known as: checkVector
method wrapper for int cv::Mat::checkVector(int elemChannels, int depth = -1, bool requireContinuous = true)
13562 13563 13564 13565 |
# File 'lib/ropencv/ropencv_types.rb', line 13562 def check_vector(elem_channels, depth = -1, require_continuous = true) __validate_pointer__ Rbind::cv_mat_check_vector( self, elem_channels, depth, require_continuous) end |
#clone ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::clone()
13134 13135 13136 13137 13138 13139 13140 13141 13142 |
# File 'lib/ropencv/ropencv_types.rb', line 13134 def clone() __validate_pointer__ result = Rbind::cv_mat_clone( self) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#coerce(other) ⇒ Object
430 431 432 433 434 435 436 437 438 439 |
# File 'lib/ropencv/ropencv_ruby.rb', line 430 def coerce(other) case other when Float [other,to_f] when Fixnum [other,to_i] else raise TypeError, "#{self.class} can't be coerced into #{other.class}" end end |
#col(c) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::col(int c)
13006 13007 13008 13009 13010 13011 13012 13013 13014 |
# File 'lib/ropencv/ropencv_types.rb', line 13006 def col(c) __validate_pointer__ result = Rbind::cv_mat_col( self, c) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#col_range(startcol, endcol) ⇒ Cv::Mat #col_range(r) ⇒ Cv::Mat
wrapper for overloaded method col_range
13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 |
# File 'lib/ropencv/ropencv_types.rb', line 13073 def col_range(*args) __validate_pointer__ # overloaded method wrapper for cv::Mat cv::Mat::colRange(int startcol, int endcol) @@cv_mat_col_range_defaults0 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_col_range_defaults0[i] end begin result = Rbind::cv_mat_col_range(self,*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end # overloaded method wrapper for cv::Mat cv::Mat::colRange(const cv::Range r) @@cv_mat_col_range2_defaults1 ||= [nil] if(args.size >= 1 && args.size <= 1) targs = args.clone targs.size.upto(0) do |i| targs[i] = @@cv_mat_col_range2_defaults1[i] end begin result = Rbind::cv_mat_col_range2(self,*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
#cols ⇒ Fixnum Also known as: get_cols
method wrapper for int cols
12732 12733 12734 12735 |
# File 'lib/ropencv/ropencv_types.rb', line 12732 def cols() __validate_pointer__ Rbind::cv_mat_get_cols( self) end |
#compare(val, type) ⇒ Object
687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'lib/ropencv/ropencv_ruby.rb', line 687 def compare(val,type) val = if val.is_a?(Cv::Mat) val elsif val.respond_to?(:to_a) val.to_a else [val] end dst = Cv::Mat.new Cv::compare(self,val,dst,type) dst end |
#convert_to(m, rtype, alpha = 1, beta = 0) ⇒ Void Also known as: convertTo
method wrapper for void cv::Mat::convertTo(cv::Mat& m, int rtype, double alpha = 1, double beta = 0)
13192 13193 13194 13195 |
# File 'lib/ropencv/ropencv_types.rb', line 13192 def convert_to(m, rtype, alpha = 1, beta = 0) __validate_pointer__ Rbind::cv_mat_convert_to( self, m, rtype, alpha, beta) end |
#copy_to(m) ⇒ Void #copy_to(m, mask) ⇒ Void
wrapper for overloaded method copy_to
13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 |
# File 'lib/ropencv/ropencv_types.rb', line 13153 def copy_to(*args) __validate_pointer__ # overloaded method wrapper for void cv::Mat::copyTo(cv::Mat& m) @@cv_mat_copy_to_defaults0 ||= [nil] if(args.size >= 1 && args.size <= 1) targs = args.clone targs.size.upto(0) do |i| targs[i] = @@cv_mat_copy_to_defaults0[i] end begin return Rbind::cv_mat_copy_to(self,*targs) rescue TypeError => e @error = e end end # overloaded method wrapper for void cv::Mat::copyTo(cv::Mat& m, cv::Mat& mask) @@cv_mat_copy_to2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_copy_to2_defaults1[i] end begin return Rbind::cv_mat_copy_to2(self,*targs) rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
#create(rows, cols, type) ⇒ Void #create(size, type) ⇒ Void
wrapper for overloaded method create
13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 |
# File 'lib/ropencv/ropencv_types.rb', line 13437 def create(*args) __validate_pointer__ # overloaded method wrapper for void cv::Mat::create(int rows, int cols, int type) @@cv_mat_create_defaults0 ||= [nil, nil, nil] if(args.size >= 3 && args.size <= 3) targs = args.clone targs.size.upto(2) do |i| targs[i] = @@cv_mat_create_defaults0[i] end begin return Rbind::cv_mat_create(self,*targs) rescue TypeError => e @error = e end end # overloaded method wrapper for void cv::Mat::create(const cv::Size size, int type) @@cv_mat_create2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_create2_defaults1[i] end begin return Rbind::cv_mat_create2(self,*targs) rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
#cross(m) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::cross(const cv::Mat m)
13264 13265 13266 13267 13268 13269 13270 13271 13272 |
# File 'lib/ropencv/ropencv_types.rb', line 13264 def cross(m) __validate_pointer__ result = Rbind::cv_mat_cross( self, m) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#data ⇒ Uchar Also known as: get_data
method wrapper for uchar* data
12748 12749 12750 12751 |
# File 'lib/ropencv/ropencv_types.rb', line 12748 def data() __validate_pointer__ Rbind::cv_mat_get_data( self) end |
#depth ⇒ Fixnum
method wrapper for int cv::Mat::depth()
13523 13524 13525 13526 |
# File 'lib/ropencv/ropencv_types.rb', line 13523 def depth() __validate_pointer__ Rbind::cv_mat_depth( self) end |
#diag(d = 0) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::diag(int d = 0)
13115 13116 13117 13118 13119 13120 13121 13122 13123 |
# File 'lib/ropencv/ropencv_types.rb', line 13115 def diag(d = 0) __validate_pointer__ result = Rbind::cv_mat_diag( self, d) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#dot(m) ⇒ Double
method wrapper for double cv::Mat::dot(const cv::Mat m)
13277 13278 13279 13280 |
# File 'lib/ropencv/ropencv_types.rb', line 13277 def dot(m) __validate_pointer__ Rbind::cv_mat_dot( self, m) end |
#each ⇒ Object
566 567 568 569 570 571 572 573 574 575 576 |
# File 'lib/ropencv/ropencv_ruby.rb', line 566 def each if block_given? 0.upto(rows-1) do |row| 0.upto(cols-1) do |col| yield at(row,col) end end else to_enum(:each) end end |
#each_col(&block) ⇒ Object
610 611 612 613 614 615 616 617 618 |
# File 'lib/ropencv/ropencv_ruby.rb', line 610 def each_col(&block) if block_given? each_col_with_index do |c,i| yield(c) end else to_enum(:each_col) end end |
#each_col_with_index(&block) ⇒ Object
589 590 591 592 593 594 595 596 597 598 |
# File 'lib/ropencv/ropencv_ruby.rb', line 589 def each_col_with_index(&block) if block_given? c = cols 0.upto(c-1) do |i| yield(col(i),i) end else to_enum(:each_col_with_index) end end |
#each_row(&block) ⇒ Object
600 601 602 603 604 605 606 607 608 |
# File 'lib/ropencv/ropencv_ruby.rb', line 600 def each_row(&block) if block_given? each_row_with_index do |r,i| yield(r) end else to_enum(:each_row) end end |
#each_row_with_index(&block) ⇒ Object
578 579 580 581 582 583 584 585 586 587 |
# File 'lib/ropencv/ropencv_ruby.rb', line 578 def each_row_with_index(&block) if block_given? r = rows 0.upto(r-1) do |i| yield(row(i),i) end else to_enum(:each_row_with_index) end end |
#elem_size ⇒ Size_T Also known as: elemSize
method wrapper for size_t cv::Mat::elemSize()
13488 13489 13490 13491 |
# File 'lib/ropencv/ropencv_types.rb', line 13488 def elem_size() __validate_pointer__ Rbind::cv_mat_elem_size( self) end |
#elem_size1 ⇒ Size_T Also known as: elemSize1
method wrapper for size_t cv::Mat::elemSize1()
13496 13497 13498 13499 |
# File 'lib/ropencv/ropencv_types.rb', line 13496 def elem_size1() __validate_pointer__ Rbind::cv_mat_elem_size1( self) end |
#empty ⇒ Bool
method wrapper for bool cv::Mat::empty()
13545 13546 13547 13548 |
# File 'lib/ropencv/ropencv_types.rb', line 13545 def empty() __validate_pointer__ Rbind::cv_mat_empty( self) end |
#flags ⇒ Fixnum Also known as: get_flags
method wrapper for int flags
methods
12716 12717 12718 12719 |
# File 'lib/ropencv/ropencv_types.rb', line 12716 def flags() __validate_pointer__ Rbind::cv_mat_get_flags( self) end |
#inv(method = DECOMP_LU) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::inv(int method = DECOMP_LU)
13237 13238 13239 13240 13241 13242 13243 13244 13245 |
# File 'lib/ropencv/ropencv_types.rb', line 13237 def inv(method = DECOMP_LU) __validate_pointer__ result = Rbind::cv_mat_inv( self, method) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#is_continuous ⇒ Bool Also known as: isContinuous
method wrapper for bool cv::Mat::isContinuous()
13472 13473 13474 13475 |
# File 'lib/ropencv/ropencv_types.rb', line 13472 def is_continuous() __validate_pointer__ Rbind::cv_mat_is_continuous( self) end |
#is_submatrix ⇒ Bool Also known as: isSubmatrix
method wrapper for bool cv::Mat::isSubmatrix()
13480 13481 13482 13483 |
# File 'lib/ropencv/ropencv_types.rb', line 13480 def is_submatrix() __validate_pointer__ Rbind::cv_mat_is_submatrix( self) end |
#mul(m, scale = 1) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::mul(const cv::Mat m, double scale = 1)
13251 13252 13253 13254 13255 13256 13257 13258 13259 |
# File 'lib/ropencv/ropencv_types.rb', line 13251 def mul(m, scale = 1) __validate_pointer__ result = Rbind::cv_mat_mul( self, m, scale) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#pretty_print(pp) ⇒ Object
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/ropencv/ropencv_ruby.rb', line 546 def pretty_print(pp) if(rows <= DISPLAYED_ROWS_MAX && cols <= DISPLAYED_COLS_MAX) format = case type & 7 when CV_8U '%3.u' else '%6.3f' end str = to_a.map do |r| str = r.map do |e| sprintf(format,e) end.join(" ") "|#{str}|" end.join("\n") pp.text str else pp.text self.to_s end end |
#ptr(_i0 = 0) ⇒ Uchar #ptr(_i0, _i1) ⇒ Uchar #ptr(_i0, _i1, _i2) ⇒ Uchar
wrapper for overloaded method ptr
13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 |
# File 'lib/ropencv/ropencv_types.rb', line 13583 def ptr(*args) __validate_pointer__ # overloaded method wrapper for uchar* cv::Mat::ptr(int i0 = 0) @@cv_mat_ptr_defaults0 ||= [0] if(args.size >= 0 && args.size <= 1) targs = args.clone targs.size.upto(0) do |i| targs[i] = @@cv_mat_ptr_defaults0[i] end begin return Rbind::cv_mat_ptr(self,*targs) rescue TypeError => e @error = e end end # overloaded method wrapper for uchar* cv::Mat::ptr(int i0, int i1) @@cv_mat_ptr2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_ptr2_defaults1[i] end begin return Rbind::cv_mat_ptr2(self,*targs) rescue TypeError => e @error = e end end # overloaded method wrapper for uchar* cv::Mat::ptr(int i0, int i1, int i2) @@cv_mat_ptr3_defaults2 ||= [nil, nil, nil] if(args.size >= 3 && args.size <= 3) targs = args.clone targs.size.upto(2) do |i| targs[i] = @@cv_mat_ptr3_defaults2[i] end begin return Rbind::cv_mat_ptr3(self,*targs) rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
#reshape(cn, rows = 0) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::reshape(int cn, int rows = 0)
13212 13213 13214 13215 13216 13217 13218 13219 13220 |
# File 'lib/ropencv/ropencv_types.rb', line 13212 def reshape(cn, rows = 0) __validate_pointer__ result = Rbind::cv_mat_reshape( self, cn, rows) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#row(y) ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::row(int y)
12993 12994 12995 12996 12997 12998 12999 13000 13001 |
# File 'lib/ropencv/ropencv_types.rb', line 12993 def row(y) __validate_pointer__ result = Rbind::cv_mat_row( self, y) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#row_range(startrow, endrow) ⇒ Cv::Mat #row_range(r) ⇒ Cv::Mat
wrapper for overloaded method row_range
13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 |
# File 'lib/ropencv/ropencv_types.rb', line 13025 def row_range(*args) __validate_pointer__ # overloaded method wrapper for cv::Mat cv::Mat::rowRange(int startrow, int endrow) @@cv_mat_row_range_defaults0 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_row_range_defaults0[i] end begin result = Rbind::cv_mat_row_range(self,*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end # overloaded method wrapper for cv::Mat cv::Mat::rowRange(const cv::Range r) @@cv_mat_row_range2_defaults1 ||= [nil] if(args.size >= 1 && args.size <= 1) targs = args.clone targs.size.upto(0) do |i| targs[i] = @@cv_mat_row_range2_defaults1[i] end begin result = Rbind::cv_mat_row_range2(self,*targs) # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__? return result rescue TypeError => e @error = e end end raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}" end |
#rows ⇒ Fixnum Also known as: get_rows
method wrapper for int rows
12724 12725 12726 12727 |
# File 'lib/ropencv/ropencv_types.rb', line 12724 def rows() __validate_pointer__ Rbind::cv_mat_get_rows( self) end |
#set(i, j, k = nil, val = nil) ⇒ Object
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/ropencv/ropencv_ruby.rb', line 457 def set(i,j,k=nil,val=nil) k,val = if val == nil [val,k] else [k,val] end k ||= 0 raise ArgumentError,"channel #{k} out of bound" if k >= channels i,j,val = if val == nil if i.is_a?(Cv::Point) [i.y,i.x,j] elsif rows == 1 [0,i,j] else [i,0,j] end else [i,j,val] end if i >= rows || i < 0 || j >= cols || j <0 raise ArgumentError,"out of bound #{i}/#{j}" end j = j*channels+k case type & 7 when CV_8U data.put_uint8(i*step+j,val) when CV_16U data.put_uint16(i*step+j*2,val) when CV_16S data.put_int16(i*step+j*2,val) when CV_32S data.put_int32(i*step+j*4,val) when CV_32F data.put_float32(i*step+j*4,val) when CV_64F data.put_float64(i*step+j*8,val) else raise "cannot connvert #{self.class} of type #{type} to ruby" end end |
#size ⇒ Cv::Size
method wrapper for cv::Size cv::Mat::size()
13504 13505 13506 13507 13508 13509 13510 13511 13512 |
# File 'lib/ropencv/ropencv_types.rb', line 13504 def size() __validate_pointer__ result = Rbind::cv_mat_size( self) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#step ⇒ Size_T Also known as: get_step
method wrapper for size_t step
12740 12741 12742 12743 |
# File 'lib/ropencv/ropencv_types.rb', line 12740 def step() __validate_pointer__ Rbind::cv_mat_get_step( self) end |
#step1(i = 0) ⇒ Size_T
method wrapper for size_t cv::Mat::step1(int i = 0)
13538 13539 13540 13541 |
# File 'lib/ropencv/ropencv_types.rb', line 13538 def step1(i = 0) __validate_pointer__ Rbind::cv_mat_step1( self, i) end |
#t ⇒ Cv::Mat
method wrapper for cv::Mat cv::Mat::t()
13224 13225 13226 13227 13228 13229 13230 13231 13232 |
# File 'lib/ropencv/ropencv_types.rb', line 13224 def t() __validate_pointer__ result = Rbind::cv_matt( self) if result.respond_to?(:__owner__?) && !result.__owner__? # store owner insight the pointer to not get garbage collected result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) end result end |
#to_a ⇒ Object
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
# File 'lib/ropencv/ropencv_ruby.rb', line 632 def to_a h,w,c,s,ptr = [rows,cols,channels,step,data] getter = case type & 7 when CV_8U ptr.method(:get_array_of_uint8) when CV_16U ptr.method(:get_array_of_uint16) when CV_16S ptr.method(:get_array_of_int16) when CV_32S ptr.method(:get_array_of_int32) when CV_32F ptr.method(:get_array_of_float32) when CV_64F ptr.method(:get_array_of_float64) else raise "cannot connvert #{self.class} to array" end result = [] 0.upto(h-1) do |i| result << getter.call(s*i,w*c) end result end |
#to_f ⇒ Object
441 442 443 444 445 446 447 |
# File 'lib/ropencv/ropencv_ruby.rb', line 441 def to_f if rows == 1 && cols == 1 at(0,0).to_f else raise "Matrix #{self} has more than one element" end end |
#to_i ⇒ Object
449 450 451 452 453 454 455 |
# File 'lib/ropencv/ropencv_ruby.rb', line 449 def to_i if rows == 1 && cols == 1 at(0,0).to_i else raise "Matrix #{self} has more than one element" end end |
#to_MAT(variable_name) ⇒ Object
returns a string compatible to matlab's MAT-file
621 622 623 624 625 626 627 628 629 630 |
# File 'lib/ropencv/ropencv_ruby.rb', line 621 def to_MAT(variable_name) "% Created by ropencv, \#{Time.now}\n% name: \#{variable_name}\n% type: matrix\n% rows: \#{rows}\n% columns: \#{cols}\n\#{to_a.map{|row|row.join(\" \")}.join(\"\\n\")}\n" end |
#to_s ⇒ Object
converts Mat into a string by crawling through all its attributes
12698 12699 12700 |
# File 'lib/ropencv/ropencv_types.rb', line 12698 def to_s "#<cv::Mat flags=#{self.flags} rows=#{self.rows} cols=#{self.cols} step=#{self.step} data=#{self.data}>" end |
#total ⇒ Size_T
method wrapper for size_t cv::Mat::total()
13552 13553 13554 13555 |
# File 'lib/ropencv/ropencv_types.rb', line 13552 def total() __validate_pointer__ Rbind::cv_mat_total( self) end |
#type ⇒ Fixnum
method wrapper for int cv::Mat::type()
13516 13517 13518 13519 |
# File 'lib/ropencv/ropencv_types.rb', line 13516 def type() __validate_pointer__ Rbind::cv_mat_type( self) end |