Class: OpenCV::Cv::Flann::Index

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Index

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



5969
5970
5971
5972
5973
5974
5975
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5969

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



5966
5967
5968
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5966

def __obj_ptr__
  @__obj_ptr__
end

Class Method Details

.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



5961
5962
5963
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5961

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

.new(*args) ⇒ Object

Raises:

  • (ArgumentError)


5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5905

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

    # wrapper for cv::flann::Index::Index(const cv::Mat features, const cv::flann::IndexParams params, const cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2)
    @@cv_flann_index_index2_defaults1 ||= [nil, nil, cvflann::FLANN_DIST_L2]
    if(args.size >= 2 && args.size <= 3)
        args.size.upto(2) do |i|
            args[i] = @@cv_flann_index_index2_defaults1[i]
        end
        begin
            return Rbind::cv_flann_index_index2(*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.



5949
5950
5951
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5949

def self.rbind_from_native(ptr,context)
    Index.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.



5940
5941
5942
5943
5944
5945
5946
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5940

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



5955
5956
5957
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5955

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

Instance Method Details

#__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)


5980
5981
5982
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5980

def __owner__?
    @__obj_ptr__[:bowner]
end

#build(features, params, dist_type = cvflann::FLANN_DIST_L2) ⇒ Object

methods wrapper for void cv::flann::Index::build(const cv::Mat features, const cv::flann::IndexParams params, const cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2)



5994
5995
5996
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5994

def build(features, params, dist_type = cvflann::FLANN_DIST_L2)
    Rbind::cv_flann_index_build( self, features, params, dist_type)
end

#get_algorithmObject

wrapper for cvflann::flann_algorithm_t cv::flann::Index::getAlgorithm()



6032
6033
6034
6035
6036
6037
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6032

def get_algorithm()
    result = Rbind::cv_flann_index_get_algorithm( 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

#get_distanceObject

wrapper for cvflann::flann_distance_t cv::flann::Index::getDistance()



6024
6025
6026
6027
6028
6029
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6024

def get_distance()
    result = Rbind::cv_flann_index_get_distance( 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

#knn_search(query, indices, dists, knn, params = Cv::Flann::SearchParams.new()) ⇒ Object

wrapper for void cv::flann::Index::knnSearch(const cv::Mat query, cv::Mat indices, cv::Mat dists, int knn, const cv::flann::SearchParams params=SearchParams())



5999
6000
6001
# File 'lib/ruby/ropencv/ropencv_types.rb', line 5999

def knn_search(query, indices, dists, knn, params = Cv::Flann::SearchParams.new())
    Rbind::cv_flann_index_knn_search( self, query, indices, dists, knn, params)
end

#load(features, filename) ⇒ Object

wrapper for bool cv::flann::Index::load(const cv::Mat features, const cv::String filename)



6014
6015
6016
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6014

def load(features, filename)
    Rbind::cv_flann_index_load( self, features, filename)
end

#radius_search(query, indices, dists, radius, max_results, params = Cv::Flann::SearchParams.new()) ⇒ Object

wrapper for int cv::flann::Index::radiusSearch(const cv::Mat query, cv::Mat indices, cv::Mat dists, double radius, int maxResults, const cv::flann::SearchParams params=SearchParams())



6004
6005
6006
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6004

def radius_search(query, indices, dists, radius, max_results, params = Cv::Flann::SearchParams.new())
    Rbind::cv_flann_index_radius_search( self, query, indices, dists, radius, max_results, params)
end

#releaseObject

wrapper for void cv::flann::Index::release()



6019
6020
6021
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6019

def release()
    Rbind::cv_flann_index_release( self)
end

#save(filename) ⇒ Object

wrapper for void cv::flann::Index::save(const cv::String filename)



6009
6010
6011
# File 'lib/ruby/ropencv/ropencv_types.rb', line 6009

def save(filename)
    Rbind::cv_flann_index_save( self, filename)
end