18 #ifndef DS3D_DATAFILTER_SENSOR_FUSIOIN_CONFIG_H
19 #define DS3D_DATAFILTER_SENSOR_FUSIOIN_CONFIG_H
21 #include <ds3d/common/common.h>
22 #include <ds3d/common/func_utils.h>
24 #include "ds3d/common/hpp/yaml_config.hpp"
26 #include <unordered_set>
28 namespace ds3d {
namespace impl {
namespace filter {
57 parseConfig(
const std::string& content,
const std::string& path, Config& config)
61 "parse dataloader component content failed");
62 YAML::Node node = YAML::Load(config.compConfig.configBody);
63 auto yInput2DBbox = node[
"2d_objects_input_key"];
64 auto yInput3Dbbox = node[
"3d_objects_input_key"];
65 auto y2dInputColor = node[
"2d_color_image_input_key"];
66 auto yMatchClasses = node[
"match_classes"];
67 auto yCamInt = node[
"cam_intrinsics_mat_key"];
68 auto yCamIntParam = node[
"cam_intrinsics_param_key"];
69 auto yLidar2CamExt = node[
"lidar_to_cam_extrinsics_mat_key"];
70 auto yIouThreshold = node[
"iou_threshold"];
71 auto yOutputFusedKey = node[
"output_fused_detection_key"];
72 auto yOutputFusedRenderKey = node[
"output_fused_3d_bbox_key"];
75 yMatchClasses,
ErrCode::kConfig,
"<match_classes> list is required in sensorfusion config");
77 std::unordered_set<std::string> labelsCheck;
78 for (std::size_t i = 0; i < yMatchClasses.size(); i++) {
79 const YAML::Node& kvs = yMatchClasses[i];
80 for (
const auto& kv : kvs) {
81 auto yMatch = kv.second;
82 auto y2D = yMatch[
"label_2d"];
83 auto y3D = yMatch[
"label_3d"];
84 auto yColor = yMatch[
"color"];
87 match.newLabel = kv.first.as<std::string>();
88 match.label2D = y2D.as<std::string>();
89 match.label3D = y3D.as<std::string>();
91 auto color = yColor.as<std::vector<float>>();
92 size_t size = (color.size() < 3 ? color.size() : 3);
93 for (
size_t i = 0; i <
size; ++i) {
94 match.color.data[i] = color[i] / 255.0f;
97 if (labelsCheck.count(match.newLabel)) {
99 "new label: %s exist multiple times in sensor fusion config, it might match "
101 match.newLabel.c_str());
103 labelsCheck.insert(match.newLabel);
106 config.fusionLabels.emplace_back(match);
111 config.input2DBboxKey = yInput2DBbox.as<std::string>();
114 config.input3DbboxKey = yInput3Dbbox.as<std::string>();
117 config.input2DImageKey = y2dInputColor.as<std::string>();
120 config.camIntrinsicsKey = yCamInt.as<std::string>();
123 config.camIntrinsicsParamKey = yCamIntParam.as<std::string>();
126 config.lidar2CamExtrinsicsKey = yLidar2CamExt.as<std::string>();
129 config.iouThreshold = yIouThreshold.as<
float>();
131 if (yOutputFusedKey) {
132 config.outputFusedKey = yOutputFusedKey.as<std::string>();
134 if (yOutputFusedRenderKey) {
135 config.outputFusedBboxRenderKey = yOutputFusedRenderKey.as<std::string>();
138 LOG_DEBUG(
"fusion config, 2d_objects_input_key: %s", config.input2DBboxKey.c_str());
139 LOG_DEBUG(
"fusion config, 3d_objects_input_key: %s", config.input3DbboxKey.c_str());
140 std::stringstream ssKeys;
141 for (
const auto& label : config.fusionLabels) {
142 ssKeys <<
" " << label.newLabel <<
",";
144 LOG_DEBUG(
"fusion config, 2d_input_key:%s", ssKeys.str().c_str());
151 #endif // DS3D_DATAFILTER_SENSOR_FUSIOIN_CONFIG_H