class mrpt::vision::CFeatureList

A list of visual features, to be used as output by detectors, as input/output by trackers, etc.

#include <mrpt/vision/CFeature.h>

class CFeatureList: public mrpt::math::KDTreeCapable
{
public:
    // typedefs

    typedef TInternalFeatList::iterator iterator;
    typedef TInternalFeatList::const_iterator const_iterator;
    typedef TInternalFeatList::reverse_iterator reverse_iterator;
    typedef TInternalFeatList::const_reverse_iterator const_reverse_iterator;

    //
methods

    iterator begin();
    iterator end();
    const_iterator begin() const;
    const_iterator end() const;
    reverse_iterator rbegin();
    reverse_iterator rend();
    const_reverse_iterator rbegin() const;
    const_reverse_iterator rend() const;
    iterator erase(const iterator& it);
    bool empty() const;
    size_t size() const;
    void clear();
    void resize(size_t N);
    void emplace_back(CFeature&& f);
    void push_back(const CFeature& f);
    CFeature& operator [] (const unsigned int index);
    const CFeature& operator [] (const unsigned int index) const;
    size_t kdtree_get_point_count() const;
    float kdtree_get_pt(const size_t idx, int dim) const;
    float kdtree_distance(const float* p1, const size_t idx_p2, ] size_t size) const;

    template <typename BBOX>
    bool kdtree_get_bbox(] BBOX& bb) const;

    float getFeatureX(size_t i) const;
    float getFeatureY(size_t i) const;
    TFeatureID getFeatureID(size_t i) const;
    float getFeatureResponse(size_t i) const;
    bool isPointFeature(size_t i) const;
    float getScale(size_t i) const;
    TFeatureTrackStatus getTrackStatus(size_t i);

    void setFeatureX(
        size_t i,
        float x
        );

    void setFeatureXf(
        size_t i,
        float x
        );

    void setFeatureY(
        size_t i,
        float y
        );

    void setFeatureYf(
        size_t i,
        float y
        );

    void setFeatureID(
        size_t i,
        TFeatureID id
        );

    void setFeatureResponse(
        size_t i,
        float r
        );

    void setScale(
        size_t i,
        uint8_t s
        );

    void setTrackStatus(
        size_t i,
        TFeatureTrackStatus s
        );

    void mark_as_outdated() const;
    TKeyPointMethod get_type() const;
    void saveToTextFile(const std::string& fileName, bool APPEND = false);
    void loadFromTextFile(const std::string& fileName);
    void copyListFrom(const CFeatureList& otherList);
    TFeatureID getMaxID() const;
    const CFeature* getByID(const TFeatureID& ID) const;

    const CFeature* getByID(
        const TFeatureID& ID,
        int& out_idx
        ) const;

    const CFeature* nearest(const float x, const float y, double& max_dist) const;
    void mark_kdtree_as_outdated() const;
};

Inherited Members

public:
    // typedefs

    typedef KDTreeCapable<Derived, num_t, metric_t> self_t;

    // structs

    template <int _DIM = -1>
    struct TKDTreeDataHolder;

    struct TKDTreeSearchParams;

    //
methods

    float kdTreeClosestPoint2DsqrError(const TPoint2D& p0) const;
    void kdTreeTwoClosestPoint2D(const TPoint2D& p0, TPoint2D& pOut1, TPoint2D& pOut2, float& outDistSqr1, float& outDistSqr2) const;

    std::vector<size_t> kdTreeNClosestPoint2D(
        const TPoint2D& p0,
        size_t N,
        std::vector<TPoint2D>& pOut,
        std::vector<float>& outDistSqr
        ) const;

    void kdTreeNClosestPoint2DIdx(
        const TPoint2D& p0,
        size_t N,
        std::vector<size_t>& outIdx,
        std::vector<float>& outDistSqr
        ) const;

    void kdTreeNClosestPoint3D(const TPoint3D& p0, size_t N, std::vector<TPoint3D>& pOut, std::vector<float>& outDistSqr) const;

    void kdTreeNClosestPoint3DIdx(
        const TPoint3D& p0,
        size_t N,
        std::vector<size_t>& outIdx,
        std::vector<float>& outDistSqr
        ) const;

    void kdTreeEnsureIndexBuilt3D();
    void kdTreeEnsureIndexBuilt2D();
    KDTreeCapable& operator = (const KDTreeCapable&);

Methods

size_t kdtree_get_point_count() const

Must return the number of data points.

float kdtree_get_pt(const size_t idx, int dim) const

Returns the dim’th component of the idx’th point in the class:

float kdtree_distance(const float* p1, const size_t idx_p2, ] size_t size) const

Returns the distance between the vector “p1[0:size-1]” and the data point with index “idx_p2” stored in the class:

TKeyPointMethod get_type() const

The type of the first feature in the list.

void saveToTextFile(const std::string& fileName, bool APPEND = false)

Save feature list to a text file.

void loadFromTextFile(const std::string& fileName)

Save feature list to a text file.

void copyListFrom(const CFeatureList& otherList)

Copies the content of another CFeatureList inside this one.

The inner features are also copied.

TFeatureID getMaxID() const

Get the maximum ID into the list.

const CFeature* getByID(const TFeatureID& ID) const

Get a reference to a Feature from its ID.

const CFeature* nearest(const float x, const float y, double& max_dist) const

Get a reference to the nearest feature to the a given 2D point (version returning distance to closest feature in “max_dist”)

See also all the available KD-tree search methods, listed in mrpt::math::KDTreeCapable

Parameters:

x

[IN] The query point x-coordinate

y

[IN] The query point y-coordinate

max_dist

[IN/OUT] At input: The maximum distance to search for. At output: The actual distance to the feature.

Returns:

A pointer to the found feature, or nullptr if not found.

void mark_kdtree_as_outdated() const

Call this when the list of features has been modified so the KD-tree is marked as outdated.