class mrpt::vision::CFeature

A generic 2D feature from an image, extracted with CFeatureExtraction Each feature may have one or more descriptors (see descriptors), in addition to an image patch.

The (Euclidean) distance between descriptors in a pair of features can be computed with descriptorDistanceTo, while the similarity of the patches is given by patchCorrelationTo.

See also:

CFeatureList, TKeyPoint, TKeyPointList

#include <mrpt/vision/CFeature.h>

class CFeature: public mrpt::serialization::CSerializable
{
public:
    // structs

    struct TDescriptors;

    //
fields

    TKeyPointf keypoint;
    std::optional<mrpt::img::CImage> patch;
    uint16_t patchSize {21};
    TKeyPointMethod type {featNotDefined};
    TFeatureTrackStatus track_status {status_IDLE};
    float response {0.0};
    float orientation {0.0};
    uint8_t user_flags {0};
    float x2[2];
    float y2[2];
    double depth {       0};
    double initialDepth {        0};
    mrpt::math::TPoint3D p3D;
    TDescriptors descriptors;

    // construction

    CFeature();

    //
methods

    bool isPointFeature() const;
    bool getFirstDescriptorAsMatrix(mrpt::math::CMatrixFloat& desc) const;
    float patchCorrelationTo(const CFeature& oFeature) const;

    float descriptorDistanceTo(
        const CFeature& oFeature,
        TDescriptorType descriptorToUse = descAny,
        bool normalize_distances = true
        ) const;

    float descriptorSIFTDistanceTo(const CFeature& oFeature, bool normalize_distances = true) const;
    float descriptorSURFDistanceTo(const CFeature& oFeature, bool normalize_distances = true) const;
    float descriptorSpinImgDistanceTo(const CFeature& oFeature, bool normalize_distances = true) const;

    float descriptorPolarImgDistanceTo(
        const CFeature& oFeature,
        float& minDistAngle,
        bool normalize_distances = true
        ) const;

    float descriptorLogPolarImgDistanceTo(
        const CFeature& oFeature,
        float& minDistAngle,
        bool normalize_distances = true
        ) const;

    uint8_t descriptorORBDistanceTo(const CFeature& oFeature) const;
    float descriptorBLDDistanceTo(const CFeature& oFeature, bool normalize_distances = true) const;
    float descriptorLATCHDistanceTo(const CFeature& oFeature, bool normalize_distances = true) const;
    void saveToTextFile(const std::string& filename, bool APPEND = false);
    TKeyPointMethod get_type() const;
    void dumpToTextStream(std::ostream& out) const;
    void dumpToConsole() const;
};

Fields

std::optional<mrpt::img::CImage> patch

A patch of the image surrounding the feature.

uint16_t patchSize {21}

Size of the patch (patchSize x patchSize) (it must be an odd number)

TKeyPointMethod type {featNotDefined}

Keypoint method used to detect this feature.

TFeatureTrackStatus track_status {status_IDLE}

Status of the feature tracking process.

float response {0.0}

A measure of the “goodness” of the feature.

float orientation {0.0}

Main orientation of the feature.

uint8_t user_flags {0}

A field for any other flags needed by the user (this has not a predefined meaning)

float y2[2]

Coordinates for a LSD Detector to represent a line.

double depth {      0}

The estimated depth in 3D of this feature wrt the camera.

double initialDepth {       0}

in the current frame

The estimated depth in 3D of this feature wrt the

mrpt::math::TPoint3D p3D

camera that took its image

The estimated 3D point of this feature wrt its camera

Methods

bool isPointFeature() const

Return false only for Blob detectors (SIFT, SURF)

bool getFirstDescriptorAsMatrix(mrpt::math::CMatrixFloat& desc) const

Return the first found descriptor, as a matrix.

Returns:

false on error, i.e. there is no valid descriptor.

float patchCorrelationTo(const CFeature& oFeature) const

Computes the normalized cross-correlation between the patches of this and another feature (normalized in the range [0,1], such as 0=best, 1=worst).

If this or the other features does not have patches or they are of different sizes, an exception will be raised.

See also:

descriptorDistanceTo

float descriptorDistanceTo(
    const CFeature& oFeature,
    TDescriptorType descriptorToUse = descAny,
    bool normalize_distances = true
    ) const

Computes the Euclidean Distance between this feature’s and other feature’s descriptors, using the given descriptor or the first present one.

If descriptorToUse is not descAny and that descriptor is not present in one of the features, an exception will be raised.

See also:

patchCorrelationTo

float descriptorSIFTDistanceTo(
    const CFeature& oFeature,
    bool normalize_distances = true
    ) const

Computes the Euclidean Distance between “this” and the “other” descriptors.

float descriptorSURFDistanceTo(
    const CFeature& oFeature,
    bool normalize_distances = true
    ) const

Computes the Euclidean Distance between “this” and the “other” descriptors.

float descriptorSpinImgDistanceTo(
    const CFeature& oFeature,
    bool normalize_distances = true
    ) const

Computes the Euclidean Distance between “this” and the “other” descriptors.

float descriptorPolarImgDistanceTo(
    const CFeature& oFeature,
    float& minDistAngle,
    bool normalize_distances = true
    ) const

Returns the minimum Euclidean Distance between “this” and the “other” polar image descriptor, for the best shift in orientation.

Parameters:

oFeature

The other feature to compare with.

minDistAngle

The placeholder for the angle at which the smallest distance is found.

Returns:

The distance for the best orientation (minimum distance).

float descriptorLogPolarImgDistanceTo(
    const CFeature& oFeature,
    float& minDistAngle,
    bool normalize_distances = true
    ) const

Returns the minimum Euclidean Distance between “this” and the “other” log-polar image descriptor, for the best shift in orientation.

Parameters:

oFeature

The other feature to compare with.

minDistAngle

The placeholder for the angle at which the smallest distance is found.

Returns:

The distance for the best orientation (minimum distance).

uint8_t descriptorORBDistanceTo(const CFeature& oFeature) const

Computes the Hamming distance “this” and the “other” descriptor ORB descriptor.

float descriptorBLDDistanceTo(
    const CFeature& oFeature,
    bool normalize_distances = true
    ) const

Computes the Euclidean Distance between “this” and the “other” descriptors.

float descriptorLATCHDistanceTo(
    const CFeature& oFeature,
    bool normalize_distances = true
    ) const

Computes the Euclidean Distance between “this” and the “other” descriptors.

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

Save the feature to a text file in this format: “%% Dump of mrpt::vision::CFeatureList. Each line format is:n” “%% ID TYPE X Y ORIENTATION SCALE TRACK_STATUS RESPONSE HAS_SIFT [SIFT] HAS_SURF [SURF] HAS_MULTI [MULTI_i] HAS_ORB [ORB]” “%% |———————- feature ——————| |———————- descriptors ————————|” “%% with:n” “%% TYPE : The used detector: 0:KLT, 1: Harris, 2: BCD, 3: SIFT, 4: SURF, 5: Beacon, 6: FAST, 7: ORBn” “%% HAS_* : 1 if a descriptor of that type is associated to the feature.

“%% SIFT : Present if HAS_SIFT=1: N DESC_0 … DESC_N-1” “%% SURF : Present if HAS_SURF=1: N DESC_0 … DESC_N-1” “%% MULTI : Present if HAS_MULTI=1: SCALE ORI N DESC_0 … DESC_N-1”

“%% ORB : Present if HAS_ORB=1: DESC_0 … DESC_31 “%%—————————————————————————–n”);

TKeyPointMethod get_type() const

Get the type of the feature.

void dumpToTextStream(std::ostream& out) const

Dump feature information into a text stream.