template struct mrpt::obs::TPixelLabelInfo

Pixel-wise semantic label struct.

See CObservation3DRangeScan::pixelLabels

#include <mrpt/obs/TPixelLabelInfo.h>

template <unsigned int BYTES_REQUIRED_>
struct TPixelLabelInfo: public mrpt::obs::TPixelLabelInfoBase
{
    // typedefs

    typedef std::shared_ptr<TPixelLabelInfo> Ptr;
    typedef typename mrpt::uint_select_by_bytecount<BYTES_REQUIRED>::type bitmask_t;
    typedef mrpt::math::CMatrixDynamic<bitmask_t> TPixelLabelMatrix;

    //
fields

    static constexpr unsigned int BYTES_REQUIRED = BYTES_REQUIRED_;
    TPixelLabelMatrix pixelLabels;
    TMapLabelID2Name pixelLabelNames;
    const uint8_t BITFIELD_BYTES;

    //
methods

    virtual void setSize(const int NROWS, const int NCOLS);
    virtual void setLabel(const int row, const int col, uint8_t label_idx);

    virtual void getLabels(
        const int row,
        const int col,
        uint8_t& labels
        );

    virtual void unsetLabel(const int row, const int col, uint8_t label_idx);

    void unsetAll(
        const int row,
        const int col,
        ] uint8_t label_idx
        );

    virtual bool checkLabel(const int row, const int col, uint8_t label_idx) const;
    int checkLabelNameExistence(const std::string& name) const;
    virtual void unsetAll(const int row, const int col, uint8_t label_idx) = 0;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<TPixelLabelInfoBase> Ptr;
    typedef std::map<uint32_t, std::string> TMapLabelID2Name;

    //
methods

    const std::string& getLabelName(unsigned int label_idx) const;
    void setLabelName(unsigned int label_idx, const std::string& name);
    virtual void setSize(const int NROWS, const int NCOLS) = 0;
    virtual void setLabel(const int row, const int col, uint8_t label_idx) = 0;
    virtual void getLabels(const int row, const int col, uint8_t& labels) = 0;
    virtual void unsetLabel(const int row, const int col, uint8_t label_idx) = 0;
    virtual bool checkLabel(const int row, const int col, uint8_t label_idx) const = 0;
    void writeToStream(mrpt::serialization::CArchive& out) const;
    static TPixelLabelInfoBase* readAndBuildFromStream(mrpt::serialization::CArchive& in);

Typedefs

typedef typename mrpt::uint_select_by_bytecount<BYTES_REQUIRED>::type bitmask_t

Automatically-determined integer type of the proper size such that all labels fit as one bit (max: 64)

typedef mrpt::math::CMatrixDynamic<bitmask_t> TPixelLabelMatrix

Each pixel may be assigned between 0 and MAX_NUM_LABELS-1 ‘labels’ by setting to 1 the corresponding i’th bit [0,MAX_NUM_LABELS-1] in the byte in pixelLabels(r,c).

That is, each pixel is assigned an 8*BITFIELD_BYTES bit-wide bitfield of possible categories.

See also:

hasPixelLabels

Fields

TMapLabelID2Name pixelLabelNames

The ‘semantic’ or human-friendly name of the i’th bit in pixelLabels(r,c) can be found in pixelLabelNames[i] as a std::string.

const uint8_t BITFIELD_BYTES

Minimum number of bytes required to hold MAX_NUM_DIFFERENT_LABELS bits.

Methods

virtual void setSize(const int NROWS, const int NCOLS)

Resizes the matrix pixelLabels to the given size, setting all bitfields to zero (that is, all pixels are assigned NONE category).

virtual void setLabel(const int row, const int col, uint8_t label_idx)

Mark the pixel(row,col) as classified in the category label_idx, which may be in the range 0 to MAX_NUM_LABELS-1 Note that 0 is a valid label index, it does not mean “no label”.

See also:

unsetLabel, unsetAll

virtual void unsetLabel(const int row, const int col, uint8_t label_idx)

For the pixel(row,col), removes its classification into the category label_idx, which may be in the range 0 to 7 Note that 0 is a valid label index, it does not mean “no label”.

See also:

setLabel, unsetAll

virtual bool checkLabel(const int row, const int col, uint8_t label_idx) const

Checks whether pixel(row,col) has been clasified into category label_idx, which may be in the range 0 to 7.

See also:

unsetLabel, unsetAll

int checkLabelNameExistence(const std::string& name) const

Check the existence of a label by returning its associated index.

-1 if it does not exist.

virtual void unsetAll(const int row, const int col, uint8_t label_idx) = 0

Removes all categories for pixel(row,col)

See also:

setLabel, unsetLabel