Class: OpenCV::Cv::Scalar

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Scalar

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 Scalar.



2898
2899
2900
2901
2902
2903
2904
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2898

def initialize(ptr)
    @__obj_ptr__ = if ptr.is_a? ScalarStruct
                       ptr
                   else
                       ScalarStruct.new(FFI::AutoPointer.new(ptr,ScalarStruct.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.



2895
2896
2897
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2895

def __obj_ptr__
  @__obj_ptr__
end

Class Method Details

.all(_v0) ⇒ Object

wrapper for cv::Scalar cv::Scalar::all(double v0)



2928
2929
2930
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2928

def self.all(_v0)
    Rbind::cv_scalar_all(_v0)
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



2890
2891
2892
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2890

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

.new(*args) ⇒ Object

Raises:

  • (ArgumentError)


2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2821

def self.new(*args)
    if args.first.is_a?(FFI::Pointer) || args.first.is_a?(ScalarStruct)
        raise ArgumentError, "too many arguments for creating #{self.name} from Pointer" unless args.size == 1
        return super(args.first)
    end
    # wrapper for cv::Scalar::Scalar()
    @@cv_scalar_scalar_defaults0 ||= []
    if(args.size >= 0 && args.size <= 0)
        args.size.upto(-1) do |i|
            args[i] = @@cv_scalar_scalar_defaults0[i]
        end
        begin
            return Rbind::cv_scalar_scalar(*args)
        rescue TypeError => e
            @error = e
        end
    end

    # wrapper for cv::Scalar::Scalar(double v0)
    @@cv_scalar_scalar2_defaults1 ||= [nil]
    if(args.size >= 1 && args.size <= 1)
        args.size.upto(0) do |i|
            args[i] = @@cv_scalar_scalar2_defaults1[i]
        end
        begin
            return Rbind::cv_scalar_scalar2(*args)
        rescue TypeError => e
            @error = e
        end
    end

    # wrapper for cv::Scalar::Scalar(double v0, double v1, double v2=0, double v3=0)
    @@cv_scalar_scalar3_defaults2 ||= [nil, nil, 0, 0]
    if(args.size >= 2 && args.size <= 4)
        args.size.upto(3) do |i|
            args[i] = @@cv_scalar_scalar3_defaults2[i]
        end
        begin
            return Rbind::cv_scalar_scalar3(*args)
        rescue TypeError => e
            @error = e
        end
    end

    raise ArgumentError, "no constructor for #{self}(#{args.inspect})"
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.



2878
2879
2880
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2878

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

.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.



2869
2870
2871
2872
2873
2874
2875
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2869

def self.rbind_to_native(obj,context)
    if obj.is_a? Scalar
        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



2884
2885
2886
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2884

def self.to_native(obj,context)
    rbind_to_native(obj,context)
end

Instance Method Details

#[](elem) ⇒ Object

wrapper for double cv::Scalar::operator[](size_t elem)



2954
2955
2956
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2954

def [](elem)
    Rbind::cv_scalar_operator_array( self, elem)
end

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



26
27
28
29
30
# File 'lib/ruby/ropencv/ropencv_ruby.rb', line 26

def []=(i,value=nil)
    raise "out of bound #{value}" if value < 0 || value > 3
    val.put_float64(i*8,value)
    value
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)


2909
2910
2911
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2909

def __owner__?
    @__obj_ptr__[:bowner]
end

#conjObject

wrapper for cv::Scalar cv::Scalar::conj()



2941
2942
2943
2944
2945
2946
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2941

def conj()
    result = Rbind::cv_scalar_conj( 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

#is_realObject

wrapper for bool cv::Scalar::isReal()



2949
2950
2951
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2949

def is_real()
    Rbind::cv_scalar_is_real( self)
end

#mul(other, scale = 1) ⇒ Object

wrapper for cv::Scalar cv::Scalar::mul(const cv::Scalar other, double scale=1)



2933
2934
2935
2936
2937
2938
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2933

def mul(other, scale = 1)
    result = Rbind::cv_scalar_mul( self, other, 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

#valObject

methods wrapper for double *val



2923
2924
2925
# File 'lib/ruby/ropencv/ropencv_types.rb', line 2923

def val()
    Rbind::cv_scalar_get_val( self)
end