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 =
1124007936
- AUTO_STEP =
0
- CONTINUOUS_FLAG =
Cv::CV_MAT_CONT_FLAG
- SUBMATRIX_FLAG =
Cv::CV_SUBMAT_FLAG
- MAGIC_MASK =
4294901760
- TYPE_MASK =
4095
- 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 const cv::Mat cv::Mat::diag(const cv::Mat d)
22134 22135 22136 |
# File 'lib/ropencv/ropencv_types.rb', line 22134 def self.diag(d) Rbind::cv_mat_diag__2(d) end |
.eye(rows, cols, type) ⇒ Cv::Mat .eye(size, type) ⇒ Cv::Mat
wrapper for overloaded static method eye
22395 22396 22397 22398 22399 22400 22401 22402 22403 22404 22405 22406 22407 22408 22409 22410 22411 22412 22413 22414 22415 22416 22417 22418 22419 22420 22421 22422 22423 22424 22425 22426 22427 22428 22429 22430 22431 |
# File 'lib/ropencv/ropencv_types.rb', line 22395 def self.eye(*args) # overloaded method wrapper for const 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 const cv::Mat cv::Mat::eye(const cv::Size size, int type) @@cv_mat_eye__2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_eye__2_defaults1[i] end begin result = Rbind::cv_mat_eye__2(*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(vec, copy = false) ⇒ Object .mat(vec, copy = false) ⇒ Object .mat(vec, copy = false) ⇒ Object .mat(vec, copy = false) ⇒ Object .mat(vec, copy = false) ⇒ 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
21422 21423 21424 21425 21426 21427 21428 21429 |
# File 'lib/ropencv/ropencv_types.rb', line 21422 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
21352 21353 21354 |
# File 'lib/ropencv/ropencv_types.rb', line 21352 def self.null new(MatStruct.new) end |
.ones(rows, cols, type) ⇒ Cv::Mat .ones(size, type) ⇒ Cv::Mat
wrapper for overloaded static method ones
22347 22348 22349 22350 22351 22352 22353 22354 22355 22356 22357 22358 22359 22360 22361 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 22379 22380 22381 22382 22383 |
# File 'lib/ropencv/ropencv_types.rb', line 22347 def self.ones(*args) # overloaded method wrapper for const 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 const cv::Mat cv::Mat::ones(const cv::Size size, int type) @@cv_mat_ones__2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_ones__2_defaults1[i] end begin result = Rbind::cv_mat_ones__2(*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
354 |
# File 'lib/ropencv/ropencv_ruby.rb', line 354 alias :rbind_new :new |
.zeros(rows, cols, type) ⇒ Cv::Mat .zeros(size, type) ⇒ Cv::Mat
wrapper for overloaded static method zeros
22299 22300 22301 22302 22303 22304 22305 22306 22307 22308 22309 22310 22311 22312 22313 22314 22315 22316 22317 22318 22319 22320 22321 22322 22323 22324 22325 22326 22327 22328 22329 22330 22331 22332 22333 22334 22335 |
# File 'lib/ropencv/ropencv_types.rb', line 22299 def self.zeros(*args) # overloaded method wrapper for const 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 const cv::Mat cv::Mat::zeros(const cv::Size size, int type) @@cv_mat_zeros__2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_zeros__2_defaults1[i] end begin result = Rbind::cv_mat_zeros__2(*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
708 709 710 |
# File 'lib/ropencv/ropencv_ruby.rb', line 708 def !=(val) compare(val,Cv::CMP_NE) end |
#*(mat) ⇒ Cv::Mat #*(val) ⇒ Cv::Mat #*(val) ⇒ Cv::Mat
wrapper for overloaded method *
21890 21891 21892 21893 21894 21895 21896 21897 21898 |
# File 'lib/ropencv/ropencv_types.rb', line 21890 def *(val) if val.is_a? Float Rbind::cv_mat_operator_mult__2( self, val) elsif val.is_a? 1.class Rbind::cv_mat_operator_mult__3( 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 +
21772 21773 21774 21775 21776 21777 21778 21779 21780 |
# File 'lib/ropencv/ropencv_types.rb', line 21772 def +(val) if val.is_a? Float Rbind::cv_mat_operator_plus__2( self, val) elsif val.is_a? 1.class Rbind::cv_mat_operator_plus__3( 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 -
21831 21832 21833 21834 21835 21836 21837 21838 21839 |
# File 'lib/ropencv/ropencv_types.rb', line 21831 def -(val) if val.is_a? Float Rbind::cv_mat_operator_minus__2( self, val) elsif val.is_a? 1.class Rbind::cv_mat_operator_minus__3( self, val) else Rbind::cv_mat_operator_minus( self, val) end end |
#-@ ⇒ Object
421 422 423 |
# File 'lib/ropencv/ropencv_ruby.rb', line 421 def -@ Cv::Mat.zeros(rows,cols,type)-self end |
#/(mat) ⇒ Cv::Mat #/(val) ⇒ Cv::Mat #/(val) ⇒ Cv::Mat
wrapper for overloaded method /
21949 21950 21951 21952 21953 21954 21955 21956 21957 |
# File 'lib/ropencv/ropencv_types.rb', line 21949 def /(val) if val.is_a? Float Rbind::cv_mat_operator_div__2( self, val) elsif val.is_a? 1.class Rbind::cv_mat_operator_div__3( self, val) else Rbind::cv_mat_operator_div( self, val) end end |
#<(val) ⇒ Object
700 701 702 |
# File 'lib/ropencv/ropencv_ruby.rb', line 700 def <(val) compare(val,Cv::CMP_LT) end |
#<=(val) ⇒ Object
704 705 706 |
# File 'lib/ropencv/ropencv_ruby.rb', line 704 def <=(val) compare(val,Cv::CMP_LE) end |
#==(val) ⇒ Object
688 689 690 |
# File 'lib/ropencv/ropencv_ruby.rb', line 688 def ==(val) compare(val,Cv::CMP_EQ) end |
#===(val) ⇒ Object
712 713 714 715 716 |
# File 'lib/ropencv/ropencv_ruby.rb', line 712 def ===(val) val = compare(val,Cv::CMP_EQ) count = cv::countNonZero(val) count == val.rows*val.cols end |
#>(val) ⇒ Object
692 693 694 |
# File 'lib/ropencv/ropencv_ruby.rb', line 692 def >(val) compare(val,Cv::CMP_GT) end |
#>=(val) ⇒ Object
696 697 698 |
# File 'lib/ropencv/ropencv_ruby.rb', line 696 def >=(val) compare(val,Cv::CMP_GE) end |
#[](i, j = nil, k = 0) ⇒ Object
529 530 531 |
# File 'lib/ropencv/ropencv_ruby.rb', line 529 def [](i,j=nil,k=0) at(i,j,k) end |
#[]=(i, j, k = nil, val = nil) ⇒ Object
533 534 535 |
# File 'lib/ropencv/ropencv_ruby.rb', line 533 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)
22208 22209 22210 22211 |
# File 'lib/ropencv/ropencv_types.rb', line 22208 def assign_to(m, type = -1) __validate_pointer__ Rbind::cv_mat_assign_to( self, m, type) end |
#at(i, j = nil, k = 0) ⇒ Object
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/ropencv/ropencv_ruby.rb', line 425 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.to_i] else [i.to_i,0] end else [i.to_i,j.to_i] 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 const cv::Mat cv::Mat::operator()(const cv::Rect rect)
22639 22640 22641 22642 22643 22644 22645 22646 22647 |
# File 'lib/ropencv/ropencv_types.rb', line 22639 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()
22536 22537 22538 22539 |
# File 'lib/ropencv/ropencv_types.rb', line 22536 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)
22568 22569 22570 22571 |
# File 'lib/ropencv/ropencv_types.rb', line 22568 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 const cv::Mat cv::Mat::clone()
22140 22141 22142 22143 22144 22145 22146 22147 22148 |
# File 'lib/ropencv/ropencv_types.rb', line 22140 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
460 461 462 463 464 465 466 467 468 469 |
# File 'lib/ropencv/ropencv_ruby.rb', line 460 def coerce(other) case other when Float [other,to_f] when 1.class [other,to_i] else raise TypeError, "#{self.class} can't be coerced into #{other.class}" end end |
#col(c) ⇒ Cv::Mat
method wrapper for const cv::Mat cv::Mat::col(int c)
22012 22013 22014 22015 22016 22017 22018 22019 22020 |
# File 'lib/ropencv/ropencv_types.rb', line 22012 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
22079 22080 22081 22082 22083 22084 22085 22086 22087 22088 22089 22090 22091 22092 22093 22094 22095 22096 22097 22098 22099 22100 22101 22102 22103 22104 22105 22106 22107 22108 22109 22110 22111 22112 22113 22114 22115 22116 |
# File 'lib/ropencv/ropencv_types.rb', line 22079 def col_range(*args) __validate_pointer__ # overloaded method wrapper for const 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 const cv::Mat cv::Mat::colRange(const cv::Range r) @@cv_mat_col_range__2_defaults1 ||= [nil] if(args.size >= 1 && args.size <= 1) targs = args.clone targs.size.upto(0) do |i| targs[i] = @@cv_mat_col_range__2_defaults1[i] end begin result = Rbind::cv_mat_col_range__2(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
21738 21739 21740 21741 |
# File 'lib/ropencv/ropencv_types.rb', line 21738 def cols() __validate_pointer__ Rbind::cv_mat_get_cols( self) end |
#compare(val, type) ⇒ Object
718 719 720 721 722 723 724 725 726 727 728 729 |
# File 'lib/ropencv/ropencv_ruby.rb', line 718 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)
22198 22199 22200 22201 |
# File 'lib/ropencv/ropencv_types.rb', line 22198 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
22159 22160 22161 22162 22163 22164 22165 22166 22167 22168 22169 22170 22171 22172 22173 22174 22175 22176 22177 22178 22179 22180 22181 22182 22183 22184 22185 22186 22187 22188 22189 22190 |
# File 'lib/ropencv/ropencv_types.rb', line 22159 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_to__2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_copy_to__2_defaults1[i] end begin return Rbind::cv_mat_copy_to__2(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
22443 22444 22445 22446 22447 22448 22449 22450 22451 22452 22453 22454 22455 22456 22457 22458 22459 22460 22461 22462 22463 22464 22465 22466 22467 22468 22469 22470 22471 22472 22473 22474 |
# File 'lib/ropencv/ropencv_types.rb', line 22443 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_create__2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_create__2_defaults1[i] end begin return Rbind::cv_mat_create__2(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 const cv::Mat cv::Mat::cross(const cv::Mat m)
22270 22271 22272 22273 22274 22275 22276 22277 22278 |
# File 'lib/ropencv/ropencv_types.rb', line 22270 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
21754 21755 21756 21757 |
# File 'lib/ropencv/ropencv_types.rb', line 21754 def data() __validate_pointer__ Rbind::cv_mat_get_data( self) end |
#depth ⇒ Fixnum
method wrapper for int cv::Mat::depth()
22529 22530 22531 22532 |
# File 'lib/ropencv/ropencv_types.rb', line 22529 def depth() __validate_pointer__ Rbind::cv_mat_depth( self) end |
#diag(d = 0) ⇒ Cv::Mat
method wrapper for const cv::Mat cv::Mat::diag(int d = 0)
22121 22122 22123 22124 22125 22126 22127 22128 22129 |
# File 'lib/ropencv/ropencv_types.rb', line 22121 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)
22283 22284 22285 22286 |
# File 'lib/ropencv/ropencv_types.rb', line 22283 def dot(m) __validate_pointer__ Rbind::cv_mat_dot( self, m) end |
#each ⇒ Object
597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/ropencv/ropencv_ruby.rb', line 597 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
641 642 643 644 645 646 647 648 649 |
# File 'lib/ropencv/ropencv_ruby.rb', line 641 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
620 621 622 623 624 625 626 627 628 629 |
# File 'lib/ropencv/ropencv_ruby.rb', line 620 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
631 632 633 634 635 636 637 638 639 |
# File 'lib/ropencv/ropencv_ruby.rb', line 631 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
609 610 611 612 613 614 615 616 617 618 |
# File 'lib/ropencv/ropencv_ruby.rb', line 609 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()
22494 22495 22496 22497 |
# File 'lib/ropencv/ropencv_types.rb', line 22494 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()
22502 22503 22504 22505 |
# File 'lib/ropencv/ropencv_types.rb', line 22502 def elem_size1() __validate_pointer__ Rbind::cv_mat_elem_size1( self) end |
#empty ⇒ Bool
method wrapper for bool cv::Mat::empty()
22551 22552 22553 22554 |
# File 'lib/ropencv/ropencv_types.rb', line 22551 def empty() __validate_pointer__ Rbind::cv_mat_empty( self) end |
#flags ⇒ Fixnum Also known as: get_flags
method wrapper for int flags
methods
21722 21723 21724 21725 |
# File 'lib/ropencv/ropencv_types.rb', line 21722 def flags() __validate_pointer__ Rbind::cv_mat_get_flags( self) end |
#inv(method = DECOMP_LU) ⇒ Cv::Mat
method wrapper for const cv::Mat cv::Mat::inv(int method = DECOMP_LU)
22243 22244 22245 22246 22247 22248 22249 22250 22251 |
# File 'lib/ropencv/ropencv_types.rb', line 22243 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()
22478 22479 22480 22481 |
# File 'lib/ropencv/ropencv_types.rb', line 22478 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()
22486 22487 22488 22489 |
# File 'lib/ropencv/ropencv_types.rb', line 22486 def is_submatrix() __validate_pointer__ Rbind::cv_mat_is_submatrix( self) end |
#mul(m, scale = 1) ⇒ Cv::Mat
method wrapper for const cv::Mat cv::Mat::mul(const cv::Mat m, double scale = 1)
22257 22258 22259 22260 22261 22262 22263 22264 22265 |
# File 'lib/ropencv/ropencv_types.rb', line 22257 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
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/ropencv/ropencv_ruby.rb', line 577 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
22589 22590 22591 22592 22593 22594 22595 22596 22597 22598 22599 22600 22601 22602 22603 22604 22605 22606 22607 22608 22609 22610 22611 22612 22613 22614 22615 22616 22617 22618 22619 22620 22621 22622 22623 22624 22625 22626 22627 22628 22629 22630 22631 22632 22633 22634 |
# File 'lib/ropencv/ropencv_types.rb', line 22589 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_ptr__2_defaults1 ||= [nil, nil] if(args.size >= 2 && args.size <= 2) targs = args.clone targs.size.upto(1) do |i| targs[i] = @@cv_mat_ptr__2_defaults1[i] end begin return Rbind::cv_mat_ptr__2(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_ptr__3_defaults2 ||= [nil, nil, nil] if(args.size >= 3 && args.size <= 3) targs = args.clone targs.size.upto(2) do |i| targs[i] = @@cv_mat_ptr__3_defaults2[i] end begin return Rbind::cv_mat_ptr__3(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 const cv::Mat cv::Mat::reshape(int cn, int rows = 0)
22218 22219 22220 22221 22222 22223 22224 22225 22226 |
# File 'lib/ropencv/ropencv_types.rb', line 22218 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 const cv::Mat cv::Mat::row(int y)
21999 22000 22001 22002 22003 22004 22005 22006 22007 |
# File 'lib/ropencv/ropencv_types.rb', line 21999 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
22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 22054 22055 22056 22057 22058 22059 22060 22061 22062 22063 22064 22065 22066 22067 22068 |
# File 'lib/ropencv/ropencv_types.rb', line 22031 def row_range(*args) __validate_pointer__ # overloaded method wrapper for const 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 const cv::Mat cv::Mat::rowRange(const cv::Range r) @@cv_mat_row_range__2_defaults1 ||= [nil] if(args.size >= 1 && args.size <= 1) targs = args.clone targs.size.upto(0) do |i| targs[i] = @@cv_mat_row_range__2_defaults1[i] end begin result = Rbind::cv_mat_row_range__2(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
21730 21731 21732 21733 |
# File 'lib/ropencv/ropencv_types.rb', line 21730 def rows() __validate_pointer__ Rbind::cv_mat_get_rows( self) end |
#set(i, j, k = nil, val = nil) ⇒ Object
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/ropencv/ropencv_ruby.rb', line 487 def set(i,j,k=nil,val=nil) k,val = if val == nil [val,k] else [k,val] end k ||= 0 k = k.to_i 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.to_i,j] else [i.to_i,0,j] end else [i.to_i,j.to_i,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 const cv::Size cv::Mat::size()
22510 22511 22512 22513 22514 22515 22516 22517 22518 |
# File 'lib/ropencv/ropencv_types.rb', line 22510 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
21746 21747 21748 21749 |
# File 'lib/ropencv/ropencv_types.rb', line 21746 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)
22544 22545 22546 22547 |
# File 'lib/ropencv/ropencv_types.rb', line 22544 def step1(i = 0) __validate_pointer__ Rbind::cv_mat_step1( self, i) end |
#t ⇒ Cv::Mat
method wrapper for const cv::Mat cv::Mat::t()
22230 22231 22232 22233 22234 22235 22236 22237 22238 |
# File 'lib/ropencv/ropencv_types.rb', line 22230 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
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
# File 'lib/ropencv/ropencv_ruby.rb', line 663 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
471 472 473 474 475 476 477 |
# File 'lib/ropencv/ropencv_ruby.rb', line 471 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
479 480 481 482 483 484 485 |
# File 'lib/ropencv/ropencv_ruby.rb', line 479 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
652 653 654 655 656 657 658 659 660 661 |
# File 'lib/ropencv/ropencv_ruby.rb', line 652 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
21704 21705 21706 |
# File 'lib/ropencv/ropencv_types.rb', line 21704 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()
22558 22559 22560 22561 |
# File 'lib/ropencv/ropencv_types.rb', line 22558 def total() __validate_pointer__ Rbind::cv_mat_total( self) end |
#type ⇒ Fixnum
method wrapper for int cv::Mat::type()
22522 22523 22524 22525 |
# File 'lib/ropencv/ropencv_types.rb', line 22522 def type() __validate_pointer__ Rbind::cv_mat_type( self) end |