unsigned int width {};
unsigned int height {};
unsigned int pixel_size {};
- std::vector<char> _labels;
+ std::vector<const char *> _labels;
const unsigned char *_segment_map {};
std::shared_ptr<BaseResultType> clone() override
ret = mv_semantic_segmentation_get_result(_handle, &_output_data.width, &_output_data.height, &_output_data.pixel_size, &_output_data._segment_map);
if (ret != MEDIA_VISION_ERROR_NONE)
throw runtime_error("Fail to get semantic segmentation label.");
+
+ unsigned int num_labels {};
+ ret = mv_semantic_segmentation_get_label_count(_handle, &num_labels);
+ if (ret != MEDIA_VISION_ERROR_NONE)
+ throw runtime_error("Fail to get semantic segmentation label count.");
+
+ for (unsigned int idx = 0; idx < num_labels; ++idx) {
+ const char *label {};
+
+ ret = mv_semantic_segmentation_get_label(_handle, idx, &label);
+ if (ret != MEDIA_VISION_ERROR_NO_DATA && ret != MEDIA_VISION_ERROR_NONE)
+ throw runtime_error("Fail to get a label.");
+
+ // If there is no label, it means that the model does not provide a label. In this case, we do not push the label.
+ if (ret != MEDIA_VISION_ERROR_NO_DATA)
+ _output_data._labels.push_back(label);
+ }
}
return _output_data;
_result.semantic_segmentation_result.height = dynamic_cast<SsResultType &>(*output).height;
_result.semantic_segmentation_result.pixel_size = dynamic_cast<SsResultType &>(*output).pixel_size;
+ for (auto &label : dynamic_cast<SsResultType &>(*output)._labels)
+ _result.semantic_segmentation_result.labels.push_back(label);
+
auto *segment_map = dynamic_cast<SsResultType &>(*output)._segment_map;
size_t seg_map_size = _result.semantic_segmentation_result.width *
_result.semantic_segmentation_result.height *