Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autoware_image_projection_based_fusion): roi cluster fusion has no existence probability update #8864

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,64 +166,48 @@
int index = -1;
bool associated = false;
double max_iou = 0.0;
bool is_roi_label_known =
const bool is_roi_label_known =
feature_obj.object.classification.front().label != ObjectClassification::UNKNOWN;
for (const auto & cluster_map : m_cluster_roi) {
double iou(0.0);
bool is_use_non_trust_object_iou_mode = is_far_enough(
input_cluster_msg.feature_objects.at(cluster_map.first), trust_object_distance_);
auto image_roi = feature_obj.feature.roi;
auto cluster_roi = cluster_map.second;
sanitizeROI(image_roi, camera_info.width, camera_info.height);
sanitizeROI(cluster_roi, camera_info.width, camera_info.height);
if (is_use_non_trust_object_iou_mode || is_roi_label_known) {
iou = cal_iou_by_mode(cluster_roi, image_roi, non_trust_object_iou_mode_);
} else {
iou = cal_iou_by_mode(cluster_roi, image_roi, trust_object_iou_mode_);
}

const bool passed_inside_cluster_gate =
only_allow_inside_cluster_ ? is_inside(image_roi, cluster_roi, roi_scale_factor_) : true;
if (max_iou < iou && passed_inside_cluster_gate) {
index = cluster_map.first;
max_iou = iou;
associated = true;
}
}

if (!associated) {
continue;
}

if (!output_cluster_msg.feature_objects.empty()) {
bool is_roi_existence_prob_higher =
output_cluster_msg.feature_objects.at(index).object.existence_probability <=
feature_obj.object.existence_probability;
if (iou_threshold_ < max_iou && is_roi_existence_prob_higher && is_roi_label_known) {
output_cluster_msg.feature_objects.at(index).object.classification =
feature_obj.object.classification;

// Update existence_probability for fused objects
if (
output_cluster_msg.feature_objects.at(index).object.existence_probability <
min_roi_existence_prob_) {
output_cluster_msg.feature_objects.at(index).object.existence_probability =
min_roi_existence_prob_;
}
}

// fuse with unknown roi

if (unknown_iou_threshold_ < max_iou && is_roi_existence_prob_higher && !is_roi_label_known) {
output_cluster_msg.feature_objects.at(index).object.classification =
feature_obj.object.classification;
auto & fused_object = output_cluster_msg.feature_objects.at(index).object;
const bool is_roi_existence_prob_higher =
fused_object.existence_probability <= feature_obj.object.existence_probability;

Check warning on line 201 in perception/autoware_image_projection_based_fusion/src/roi_cluster_fusion/node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/roi_cluster_fusion/node.cpp#L200-L201

Added lines #L200 - L201 were not covered by tests
const bool is_roi_iou_over_threshold =
(is_roi_label_known && iou_threshold_ < max_iou) ||
(!is_roi_label_known && unknown_iou_threshold_ < max_iou);

if (is_roi_iou_over_threshold && is_roi_existence_prob_higher) {

Check notice on line 206 in perception/autoware_image_projection_based_fusion/src/roi_cluster_fusion/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Conditional

RoiClusterFusionNode::fuseOnSingleImage decreases from 3 complex conditionals with 7 branches to 1 complex conditionals with 3 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
fused_object.classification = feature_obj.object.classification;
// Update existence_probability for fused objects
if (
output_cluster_msg.feature_objects.at(index).object.existence_probability <
min_roi_existence_prob_) {
output_cluster_msg.feature_objects.at(index).object.existence_probability =
min_roi_existence_prob_;
}
fused_object.existence_probability =

Check warning on line 209 in perception/autoware_image_projection_based_fusion/src/roi_cluster_fusion/node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/roi_cluster_fusion/node.cpp#L209

Added line #L209 was not covered by tests
std::clamp(feature_obj.object.existence_probability, min_roi_existence_prob_, 1.0f);

Check notice on line 210 in perception/autoware_image_projection_based_fusion/src/roi_cluster_fusion/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

RoiClusterFusionNode::fuseOnSingleImage decreases in cyclomatic complexity from 43 to 40, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check notice on line 210 in perception/autoware_image_projection_based_fusion/src/roi_cluster_fusion/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Bumpy Road Ahead

RoiClusterFusionNode::fuseOnSingleImage decreases from 6 to 5 logical blocks with deeply nested code, threshold is one single block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
}
}
if (debugger_) debugger_->image_rois_.push_back(feature_obj.feature.roi);
Expand Down
Loading