45 throw std::runtime_error(
"Error: label index has no defined name");
56 std::map<uint32_t, std::string>::const_iterator it;
58 if (it->second == name)
return it->first;
65 virtual void setSize(
const int NROWS,
const int NCOLS) = 0;
70 virtual void setLabel(
const int row,
const int col, uint8_t label_idx) = 0;
71 virtual void getLabels(
const int row,
const int col, uint8_t& labels) = 0;
77 const int row,
const int col, uint8_t label_idx) = 0;
80 virtual void unsetAll(
const int row,
const int col, uint8_t label_idx) = 0;
85 const int row,
const int col, uint8_t label_idx)
const = 0;
107 virtual void Print(std::ostream&)
const = 0;
115 template <
unsigned int BYTES_REQUIRED_>
137 void setSize(
const int NROWS,
const int NCOLS)
override 141 void setLabel(
const int row,
const int col, uint8_t label_idx)
override 145 void getLabels(
const int row,
const int col, uint8_t& labels)
override 150 void unsetLabel(
const int row,
const int col, uint8_t label_idx)
override 155 const int row,
const int col,
156 [[maybe_unused]] uint8_t label_idx)
override 161 const int row,
const int col, uint8_t label_idx)
const override 164 (static_cast<bitmask_t>(1) << label_idx)) != 0;
174 void Print(std::ostream&
out)
const override;
Virtual interface to all pixel-label semantic information structs.
void writeToStream(mrpt::serialization::CArchive &out) const
virtual ~TPixelLabelInfoBase()
void setSize(const int NROWS, const int NCOLS) override
Resizes the matrix pixelLabels to the given size, setting all bitfields to zero (that is...
TPixelLabelInfoBase(unsigned int BITFIELD_BYTES_)
std::map< uint32_t, std::string > TMapLabelID2Name
virtual void setSize(const int NROWS, const int NCOLS)=0
Resizes the matrix pixelLabels to the given size, setting all bitfields to zero (that is...
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...
static constexpr unsigned int BYTES_REQUIRED
virtual void Print(std::ostream &) const =0
const std::string & getLabelName(unsigned int label_idx) const
Usage: uint_select_by_bytecount<N>::type var; allows defining var as a unsigned integer with...
void internal_writeToStream(mrpt::serialization::CArchive &out) const override
virtual void internal_readFromStream(mrpt::serialization::CArchive &in)=0
int checkLabelNameExistence(const std::string &name) const
Check the existence of a label by returning its associated index.
void Print(std::ostream &out) const override
TPixelLabelMatrix pixelLabels
static TPixelLabelInfoBase * readAndBuildFromStream(mrpt::serialization::CArchive &in)
const uint8_t BITFIELD_BYTES
Minimum number of bytes required to hold MAX_NUM_DIFFERENT_LABELS bits.
This namespace contains representation of robot actions and observations.
TMapLabelID2Name pixelLabelNames
The 'semantic' or human-friendly name of the i'th bit in pixelLabels(r,c) can be found in pixelLabelN...
friend std::ostream & operator<<(std::ostream &out, const TPixelLabelInfoBase &obj)
std stream interface
void setLabelName(unsigned int label_idx, const std::string &name)
virtual void getLabels(const int row, const int col, uint8_t &labels)=0
void unsetLabel(const int row, const int col, uint8_t label_idx) override
For the pixel(row,col), removes its classification into the category label_idx, which may be in the r...
virtual void unsetLabel(const int row, const int col, uint8_t label_idx)=0
For the pixel(row,col), removes its classification into the category label_idx, which may be in the r...
void unsetAll(const int row, const int col, [[maybe_unused]] uint8_t label_idx) override
void internal_readFromStream(mrpt::serialization::CArchive &in) override
Virtual base class for "archives": classes abstracting I/O streams.
bool checkLabel(const int row, const int col, uint8_t label_idx) const override
Checks whether pixel(row,col) has been clasified into category label_idx, which may be in the range 0...
virtual void setLabel(const int row, const int col, uint8_t label_idx)=0
Mark the pixel(row,col) as classified in the category label_idx, which may be in the range 0 to MAX_N...
virtual void internal_writeToStream(mrpt::serialization::CArchive &out) const =0
mrpt::vision::TStereoCalibResults out
Pixel-wise semantic label struct.
void getLabels(const int row, const int col, uint8_t &labels) override
virtual bool checkLabel(const int row, const int col, uint8_t label_idx) const =0
Checks whether pixel(row,col) has been clasified into category label_idx, which may be in the range 0...
void setLabel(const int row, const int col, uint8_t label_idx) override
Mark the pixel(row,col) as classified in the category label_idx, which may be in the range 0 to MAX_N...
virtual void unsetAll(const int row, const int col, uint8_t label_idx)=0
Removes all categories for pixel(row,col)