Class: OpenCV::Cv::Mat

Inherits:
Object
  • Object
show all
Extended by:
FFI::DataConverter
Defined in:
lib/ruby/ropencv/ropencv_ruby.rb,
lib/ruby/ropencv/ropencv_types.rb

Constants collapse

MAGIC_VAL =
0x42FF0000
AUTO_STEP =
0
CONTINUOUS_FLAG =
CV_MAT_CONT_FLAG
SUBMATRIX_FLAG =
CV_SUBMAT_FLAG
MAGIC_MASK =
0xFFFF0000
TYPE_MASK =
0x00000FFF
DEPTH_MASK =
7

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Mat

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Mat.



6385
6386
6387
6388
6389
6390
6391
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6385

def initialize(ptr)
    @__obj_ptr__ = if ptr.is_a? MatStruct
                       ptr
                   else
                       MatStruct.new(FFI::AutoPointer.new(ptr,MatStruct.method(:release)))
                   end
end

Instance Attribute Details

#__obj_ptr__Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6382
6383
6384
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6382

def __obj_ptr__
  @__obj_ptr__
end

Class Method Details

.diag(d) ⇒ Object

wrapper for cv::Mat cv::Mat::diag(const cv::Mat d)



6716
6717
6718
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6716

def self.diag(d)
    Rbind::cv_mat_diag2(d)
end

.eye(*args) ⇒ Object

wrapper for overloaded method eye

Raises:

  • (ArgumentError)


6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6889

def self.eye(*args)
    # 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)
        args.size.upto(2) do |i|
            args[i] = @@cv_mat_eye_defaults0[i]
        end
        begin
            result = Rbind::cv_mat_eye(*args)
            # 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

    # 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)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_eye2_defaults1[i]
        end
        begin
            result = Rbind::cv_mat_eye2(*args)
            # 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

.from_native(ptr, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

can be overwritten by the user



6377
6378
6379
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6377

def self.from_native(ptr,context)
    rbind_from_native(ptr,context)
end

.new(*args) ⇒ Object

Raises:

  • (ArgumentError)


92
93
94
95
96
97
98
99
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 92

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

.ones(*args) ⇒ Object

wrapper for overloaded method ones

Raises:

  • (ArgumentError)


6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6852

def self.ones(*args)
    # 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)
        args.size.upto(2) do |i|
            args[i] = @@cv_mat_ones_defaults0[i]
        end
        begin
            result = Rbind::cv_mat_ones(*args)
            # 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

    # 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)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_ones2_defaults1[i]
        end
        begin
            result = Rbind::cv_mat_ones2(*args)
            # 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_from_native(ptr, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6365
6366
6367
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6365

def self.rbind_from_native(ptr,context)
    Mat.new(ptr)
end

.rbind_newObject



90
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 90

alias :rbind_new :new

.rbind_to_native(obj, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6356
6357
6358
6359
6360
6361
6362
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6356

def self.rbind_to_native(obj,context)
    if obj.is_a? Mat
        obj.__obj_ptr__
    else
        raise TypeError, "expected kind of #{name}, was #{obj.class}"
    end
end

.to_native(obj, context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

can be overwritten by the user



6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6371

def self.to_native(obj,context)
    if obj.is_a?(VectorPoint2f)
        cv::Mat.new(obj.size,2,cv::CV_32FC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
    elsif obj.is_a?(VectorPoint3f)
        cv::Mat.new(obj.size,3,cv::CV_32FC1,obj.data,cv::Mat::AUTO_STEP).__obj_ptr__
    elsif obj.is_a?(Array)
        h,w,e= if obj.first.is_a? Array
                   [obj.size,obj.first.size,obj.first.first]
               else
                   [obj.size,1,obj.first]
               end
        setter,step,type = if e.is_a? Fixnum
                               [:put_array_of_uint8,w,CV_8UC1]
                           elsif e.is_a? Float
                               [:put_array_of_float64,8*w,CV_64FC1]
                           else
                               raise "cannot connvert arrays of #{e.class} to array"
                           end
        mat = Mat.new(h,w,type)
        ptr = mat.data
        setter = ptr.method(setter)
        if h == 1 || w == 1
            setter.call(0,obj)
        else
            obj.each_with_index do |row,i|
                raise "number of row elements must be equal for each row" if row.size != w
                setter.call(i*step,row)
            end
        end
        mat.__obj_ptr__
    else
        rbind_to_native(obj,context)
    end
end

.zeros(*args) ⇒ Object

wrapper for overloaded method zeros

Raises:

  • (ArgumentError)


6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6815

def self.zeros(*args)
    # 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)
        args.size.upto(2) do |i|
            args[i] = @@cv_mat_zeros_defaults0[i]
        end
        begin
            result = Rbind::cv_mat_zeros(*args)
            # 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

    # 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)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_zeros2_defaults1[i]
        end
        begin
            result = Rbind::cv_mat_zeros2(*args)
            # 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

#*(*args) ⇒ Object

wrapper for overloaded method *

Raises:

  • (ArgumentError)


6530
6531
6532
6533
6534
6535
6536
6537
6538
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6530

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

#+(*args) ⇒ Object

wrapper for overloaded method +

Raises:

  • (ArgumentError)


6442
6443
6444
6445
6446
6447
6448
6449
6450
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6442

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

#-(*args) ⇒ Object

wrapper for overloaded method -

Raises:

  • (ArgumentError)


6486
6487
6488
6489
6490
6491
6492
6493
6494
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6486

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



137
138
139
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 137

def -@
    cv::Mat.zeros(rows,cols,type)-self
end

#/(*args) ⇒ Object

wrapper for overloaded method /

Raises:

  • (ArgumentError)


6574
6575
6576
6577
6578
6579
6580
6581
6582
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6574

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

#[](i, j = nil) ⇒ Object



222
223
224
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 222

def [](i,j=nil)
    at(i,j)
end

#[]=(i, j, val = nil) ⇒ Object



226
227
228
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 226

def []=(i,j,val=nil)
    set(i,j,val)
end

#__owner__?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

returns true if the underlying pointer is owner of the real object

Returns:

  • (Boolean)


6396
6397
6398
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6396

def __owner__?
    @__obj_ptr__[:bowner]
end

#assign_to(m, type = -1)) ⇒ Object

wrapper for void cv::Mat::assignTo(cv::Mat m, int type=-1)



6765
6766
6767
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6765

def assign_to(m, type = -1)
    Rbind::cv_mat_assign_to( self, m, type)
end

#at(i, j = nil) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 141

def at(i,j=nil)
    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}"
    end
    case type & 7
    when CV_8U
        data.get_uint8(i*step+j)
    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} to ruby"
    end
end

#block(rect) ⇒ Object

wrapper for cv::Mat cv::Mat::operator()(const cv::Rect rect)



7064
7065
7066
7067
7068
7069
# File 'lib/ruby/ropencv/ropencv_types.rb', line 7064

def block(rect)
    result = Rbind::cv_mat_block( self, rect)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#channelsObject

wrapper for int cv::Mat::channels()



6995
6996
6997
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6995

def channels()
    Rbind::cv_mat_channels( self)
end

#check_vector(elem_channels, depth = -1,, require_continuous = true) ⇒ Object

wrapper for int cv::Mat::checkVector(int elemChannels, int depth=-1, bool requireContinuous=true)



7015
7016
7017
# File 'lib/ruby/ropencv/ropencv_types.rb', line 7015

def check_vector(elem_channels, depth = -1, require_continuous = true)
    Rbind::cv_mat_check_vector( self, elem_channels, depth, require_continuous)
end

#cloneObject

wrapper for cv::Mat cv::Mat::clone()



6721
6722
6723
6724
6725
6726
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6721

def clone()
    result = Rbind::cv_mat_clone( self)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#coerce(other) ⇒ Object



168
169
170
171
172
173
174
175
176
177
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 168

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) ⇒ Object

wrapper for cv::Mat cv::Mat::col(int c)



6626
6627
6628
6629
6630
6631
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6626

def col(c)
    result = Rbind::cv_mat_col( self, c)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#col_range(*args) ⇒ Object

wrapper for overloaded method col_range

Raises:

  • (ArgumentError)


6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6671

def col_range(*args)
    # 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)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_col_range_defaults0[i]
        end
        begin
            result = Rbind::cv_mat_col_range(self,*args)
            # 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

    # wrapper for cv::Mat cv::Mat::colRange(const cv::Range r)
    @@cv_mat_col_range2_defaults1 ||= [nil]
    if(args.size >= 1 && args.size <= 1)
        args.size.upto(0) do |i|
            args[i] = @@cv_mat_col_range2_defaults1[i]
        end
        begin
            result = Rbind::cv_mat_col_range2(self,*args)
            # 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

#colsObject

wrapper for int cols



6427
6428
6429
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6427

def cols()
    Rbind::cv_mat_get_cols( self)
end

#convert_to(m, rtype, alpha = 1, beta = 0) ⇒ Object

wrapper for void cv::Mat::convertTo(cv::Mat m, int rtype, double alpha=1, double beta=0)



6760
6761
6762
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6760

def convert_to(m, rtype, alpha = 1, beta = 0)
    Rbind::cv_mat_convert_to( self, m, rtype, alpha, beta)
end

#copy_to(*args) ⇒ Object

wrapper for overloaded method copy_to

Raises:

  • (ArgumentError)


6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6729

def copy_to(*args)
    # wrapper for void cv::Mat::copyTo(cv::Mat m)
    @@cv_mat_copy_to_defaults0 ||= [nil]
    if(args.size >= 1 && args.size <= 1)
        args.size.upto(0) do |i|
            args[i] = @@cv_mat_copy_to_defaults0[i]
        end
        begin
            return Rbind::cv_mat_copy_to(self,*args)
        rescue TypeError => e
            @error = e
        end
    end

    # 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)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_copy_to2_defaults1[i]
        end
        begin
            return Rbind::cv_mat_copy_to2(self,*args)
        rescue TypeError => e
            @error = e
        end
    end

    raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}"
end

#create(*args) ⇒ Object

wrapper for overloaded method create

Raises:

  • (ArgumentError)


6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6926

def create(*args)
    # 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)
        args.size.upto(2) do |i|
            args[i] = @@cv_mat_create_defaults0[i]
        end
        begin
            return Rbind::cv_mat_create(self,*args)
        rescue TypeError => e
            @error = e
        end
    end

    # 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)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_create2_defaults1[i]
        end
        begin
            return Rbind::cv_mat_create2(self,*args)
        rescue TypeError => e
            @error = e
        end
    end

    raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}"
end

#cross(m) ⇒ Object

wrapper for cv::Mat cv::Mat::cross(const cv::Mat m)



6802
6803
6804
6805
6806
6807
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6802

def cross(m)
    result = Rbind::cv_mat_cross( self, m)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#dataObject

wrapper for uchar *data



6437
6438
6439
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6437

def data()
    Rbind::cv_mat_get_data( self)
end

#depthObject

wrapper for int cv::Mat::depth()



6990
6991
6992
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6990

def depth()
    Rbind::cv_mat_depth( self)
end

#diag(d = 0) ⇒ Object

wrapper for cv::Mat cv::Mat::diag(int d=0)



6708
6709
6710
6711
6712
6713
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6708

def diag(d = 0)
    result = Rbind::cv_mat_diag( self, d)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#dot(m) ⇒ Object

wrapper for double cv::Mat::dot(const cv::Mat m)



6810
6811
6812
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6810

def dot(m)
    Rbind::cv_mat_dot( self, m)
end

#elem_sizeObject

wrapper for size_t cv::Mat::elemSize()



6967
6968
6969
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6967

def elem_size()
    Rbind::cv_mat_elem_size( self)
end

#elem_size1Object

wrapper for size_t cv::Mat::elemSize1()



6972
6973
6974
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6972

def elem_size1()
    Rbind::cv_mat_elem_size1( self)
end

#emptyObject

wrapper for bool cv::Mat::empty()



7005
7006
7007
# File 'lib/ruby/ropencv/ropencv_types.rb', line 7005

def empty()
    Rbind::cv_mat_empty( self)
end

#flagsObject

methods wrapper for int flags



6417
6418
6419
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6417

def flags()
    Rbind::cv_mat_get_flags( self)
end

#inv(method = DECOMP_LU) ⇒ Object

wrapper for cv::Mat cv::Mat::inv(int method=DECOMP_LU)



6786
6787
6788
6789
6790
6791
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6786

def inv(method = DECOMP_LU)
    result = Rbind::cv_mat_inv( self, method)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#is_continuousObject

wrapper for bool cv::Mat::isContinuous()



6957
6958
6959
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6957

def is_continuous()
    Rbind::cv_mat_is_continuous( self)
end

#is_submatrixObject

wrapper for bool cv::Mat::isSubmatrix()



6962
6963
6964
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6962

def is_submatrix()
    Rbind::cv_mat_is_submatrix( self)
end

#mul(m, scale = 1) ⇒ Object

wrapper for cv::Mat cv::Mat::mul(const cv::Mat m, double scale=1)



6794
6795
6796
6797
6798
6799
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6794

def mul(m, scale = 1)
    result = Rbind::cv_mat_mul( self, m, scale)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#pretty_print(pp) ⇒ Object



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 270

def pretty_print(pp)
    format = case type & 7
             when CV_8U
                 '%3.u'
             else
                 '%6.3f'
             end
    a = if cols == 1 || rows == 1
            [to_a]
        else
            to_a
        end
    str = a.map do |r|
        str = r.map do |e|
            sprintf(format,e)
        end.join(" ")
        "|#{str}|"
    end.join("\n")
        pp.text str
end

#ptr(*args) ⇒ Object

wrapper for overloaded method ptr

Raises:

  • (ArgumentError)


7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
# File 'lib/ruby/ropencv/ropencv_types.rb', line 7020

def ptr(*args)
    # wrapper for uchar * cv::Mat::ptr(int i0=0)
    @@cv_mat_ptr_defaults0 ||= [0]
    if(args.size >= 0 && args.size <= 1)
        args.size.upto(0) do |i|
            args[i] = @@cv_mat_ptr_defaults0[i]
        end
        begin
            return Rbind::cv_mat_ptr(self,*args)
        rescue TypeError => e
            @error = e
        end
    end

    # wrapper for uchar * cv::Mat::ptr(int i0, int i1)
    @@cv_mat_ptr2_defaults1 ||= [nil, nil]
    if(args.size >= 2 && args.size <= 2)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_ptr2_defaults1[i]
        end
        begin
            return Rbind::cv_mat_ptr2(self,*args)
        rescue TypeError => e
            @error = e
        end
    end

    # 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)
        args.size.upto(2) do |i|
            args[i] = @@cv_mat_ptr3_defaults2[i]
        end
        begin
            return Rbind::cv_mat_ptr3(self,*args)
        rescue TypeError => e
            @error = e
        end
    end

    raise ArgumentError, "No overloaded signature fits to: #{args.map(&:class)}"
end

#reshape(cn, rows = 0) ⇒ Object

wrapper for cv::Mat cv::Mat::reshape(int cn, int rows=0)



6770
6771
6772
6773
6774
6775
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6770

def reshape(cn, rows = 0)
    result = Rbind::cv_mat_reshape( self, cn, rows)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#row(y) ⇒ Object

wrapper for cv::Mat cv::Mat::row(int y)



6618
6619
6620
6621
6622
6623
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6618

def row(y)
    result = Rbind::cv_mat_row( self, y)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#row_range(*args) ⇒ Object

wrapper for overloaded method row_range

Raises:

  • (ArgumentError)


6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6634

def row_range(*args)
    # 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)
        args.size.upto(1) do |i|
            args[i] = @@cv_mat_row_range_defaults0[i]
        end
        begin
            result = Rbind::cv_mat_row_range(self,*args)
            # 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

    # wrapper for cv::Mat cv::Mat::rowRange(const cv::Range r)
    @@cv_mat_row_range2_defaults1 ||= [nil]
    if(args.size >= 1 && args.size <= 1)
        args.size.upto(0) do |i|
            args[i] = @@cv_mat_row_range2_defaults1[i]
        end
        begin
            result = Rbind::cv_mat_row_range2(self,*args)
            # 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

#rowsObject

wrapper for int rows



6422
6423
6424
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6422

def rows()
    Rbind::cv_mat_get_rows( self)
end

#set(i, j, val = nil) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 195

def set(i,j,val=nil)
    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
    case type & 7
    when CV_8U
        data.put_uint8(i*step+j,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} to ruby"
    end
end

#sizeObject

wrapper for cv::Size cv::Mat::size()



6977
6978
6979
6980
6981
6982
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6977

def size()
    result = Rbind::cv_mat_size( self)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#stepObject

wrapper for size_t step



6432
6433
6434
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6432

def step()
    Rbind::cv_mat_get_step( self)
end

#step1(i = 0) ⇒ Object

wrapper for size_t cv::Mat::step1(int i=0)



7000
7001
7002
# File 'lib/ruby/ropencv/ropencv_types.rb', line 7000

def step1(i = 0)
    Rbind::cv_mat_step1( self, i)
end

#tObject

wrapper for cv::Mat cv::Mat::t()



6778
6779
6780
6781
6782
6783
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6778

def t()
    result = Rbind::cv_matt( self)
    # store owner insight the pointer to not get garbage collected
    result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
    result
end

#to_aObject



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 291

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_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
    if w  == 1 || h == 1
        getter.call(0,total)
    else
        result = []
        0.upto(h-1) do |i|
            result << getter.call(s*i,w*c)
        end
        result
    end
end

#to_fObject



179
180
181
182
183
184
185
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 179

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_iObject



187
188
189
190
191
192
193
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 187

def to_i
    if rows == 1 && cols == 1
        at(0,0).to_i
    else
        raise "Matrix #{self} has more than one element"
    end
end

#totalObject

wrapper for size_t cv::Mat::total()



7010
7011
7012
# File 'lib/ruby/ropencv/ropencv_types.rb', line 7010

def total()
    Rbind::cv_mat_total( self)
end

#typeObject

wrapper for int cv::Mat::type()



6985
6986
6987
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6985

def type()
    Rbind::cv_mat_type( self)
end