MCPcopy Create free account
hub / github.com/KumarRobotics/sloam / _mask

Method _mask

sloam/src/segmentation/inference.cpp:275–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275void Segmentation::_mask(const float* output, const std::vector<size_t>& invalid_idxs, cv::Mat& maskImg){
276 size_t channel_offset = _img_w * _img_h;
277 unsigned char _n_classes = 3;
278 std::vector<unsigned char> max;
279
280 for (int pixel_id = 0; pixel_id < channel_offset; pixel_id++){
281 int max_idx = pixel_id;
282 unsigned char out_idx = 0;
283 for (unsigned char i = 1; i < _n_classes; i++) {
284 int buffer_idx = channel_offset * i + pixel_id;
285 // if(output[max_idx] < output[buffer_idx] && output[buffer_idx] > 0.8){
286 if(output[max_idx] < output[buffer_idx]){
287 max_idx = buffer_idx;
288 out_idx = static_cast<unsigned char>(i);
289 }
290 }
291 if(out_idx == 2) out_idx = 255;
292 max.push_back(out_idx);
293 }
294
295 for(const int idx : invalid_idxs){
296 max[idx] = 0;
297 }
298
299 memcpy(maskImg.data, max.data(), max.size()*sizeof(unsigned char));
300}
301
302void Segmentation::_preProcessRange(const cv::Mat& img, cv::Mat& pImg, float maxDist) {
303 std::vector<cv::Mat> channels(2);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected