@@ -122,11 +122,13 @@ void LabelSubscriber::fillInput(const Image& img, ImageInputPacket& packet) cons
122122 }
123123}
124124
125- ColormappedLabelSubscriber::ColormappedLabelSubscriber () : colormap_(nullptr ) {}
125+ ColormappedLabelSubscriber::ColormappedLabelSubscriber ()
126+ : default_label_(-1 ), colormap_(nullptr ) {}
126127
127128ColormappedLabelSubscriber::ColormappedLabelSubscriber (ianvs::NodeHandle nh,
128129 uint32_t queue_size)
129- : colormap_(nullptr ),
130+ : default_label_(-1 ),
131+ colormap_ (nullptr ),
130132 impl_(std::make_shared<FilterSub<Image>>(nh, " semantic/image_raw" , queue_size)) {}
131133
132134ColormappedLabelSubscriber::~ColormappedLabelSubscriber () = default ;
@@ -135,8 +137,10 @@ ColormappedLabelSubscriber::Filter& ColormappedLabelSubscriber::getFilter() cons
135137 return *CHECK_NOTNULL (impl_);
136138}
137139
138- void ColormappedLabelSubscriber::setColormap (const SemanticColorMap* colormap) {
140+ void ColormappedLabelSubscriber::setColormap (const SemanticColorMap* colormap,
141+ int32_t default_label) {
139142 colormap_ = colormap;
143+ default_label_ = default_label;
140144}
141145
142146void ColormappedLabelSubscriber::fillInput (const Image& img,
@@ -164,9 +168,8 @@ void ColormappedLabelSubscriber::fillInput(const Image& img,
164168 for (int c = 0 ; c < colors.cols ; ++c) {
165169 const auto & pixel = colors.at <cv::Vec3b>(r, c);
166170 const spark_dsg::Color color (pixel[0 ], pixel[1 ], pixel[2 ]);
167- // this is lazy, but works out to the same invalid label we normally use
168171 packet.labels .at <int32_t >(r, c) =
169- colormap_->getLabelFromColor (color).value_or (- 1 );
172+ colormap_->getLabelFromColor (color).value_or (default_label_ );
170173 }
171174 }
172175}
@@ -262,7 +265,7 @@ ColormappedLabelImageReceiver::ColormappedLabelImageReceiver(const Config& confi
262265bool ColormappedLabelImageReceiver::initImpl () {
263266 using Base = ImageReceiverImpl<ColormappedLabelSubscriber>;
264267 const auto ret = Base::initImpl ();
265- semantic_sub_.setColormap (colormap_.get ());
268+ semantic_sub_.setColormap (colormap_.get (), config. default_label );
266269 return ret;
267270}
268271
@@ -271,6 +274,7 @@ void declare_config(ColormappedLabelImageReceiver::Config& config) {
271274 name (" ColormappedLabelImageReceiver::Config" );
272275 base<hydra::RosDataReceiver::Config>(config);
273276 field<Path::Absolute>(config.colormap_path , " colormap_path" );
277+ field (config.default_label , " default_label" );
274278 check<Path::Exists>(config.colormap_path , " colormap_path" );
275279}
276280
0 commit comments