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(bytetrack): fix uninteded roi value error due to casting int to uint #5589

Merged
merged 2 commits into from
Nov 21, 2023
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
16 changes: 12 additions & 4 deletions perception/bytetrack/src/bytetrack_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,18 @@
bytetrack::ObjectArray objects = bytetrack_->update_tracker(object_array);
for (const auto & tracked_object : objects) {
tier4_perception_msgs::msg::DetectedObjectWithFeature object;
object.feature.roi.x_offset = tracked_object.x_offset;
object.feature.roi.y_offset = tracked_object.y_offset;
object.feature.roi.width = tracked_object.width;
object.feature.roi.height = tracked_object.height;
// fit xy offset to 0 if roi is outside of image
const int outside_x = std::max(-tracked_object.x_offset, 0);
const int outside_y = std::max(-tracked_object.y_offset, 0);
const int32_t output_x = std::max(tracked_object.x_offset, 0);
const int32_t output_y = std::max(tracked_object.y_offset, 0);
const int32_t output_width = tracked_object.width - outside_x;
const int32_t output_height = tracked_object.height - outside_y;

Check warning on line 92 in perception/bytetrack/src/bytetrack_node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/bytetrack/src/bytetrack_node.cpp#L87-L92

Added lines #L87 - L92 were not covered by tests
// convert int32 to uint32
object.feature.roi.x_offset = static_cast<uint32_t>(output_x);
object.feature.roi.y_offset = static_cast<uint32_t>(output_y);
object.feature.roi.width = static_cast<uint32_t>(output_width);
object.feature.roi.height = static_cast<uint32_t>(output_height);

Check warning on line 97 in perception/bytetrack/src/bytetrack_node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/bytetrack/src/bytetrack_node.cpp#L94-L97

Added lines #L94 - L97 were not covered by tests
object.object.existence_probability = tracked_object.score;
object.object.classification.emplace_back(
autoware_auto_perception_msgs::build<Label>().label(tracked_object.type).probability(1.0f));
Expand Down
Loading