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

feat(traffic_light_fine_detector): add const in util function #7172

Closed
wants to merge 2 commits into from
Closed
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
14 changes: 8 additions & 6 deletions perception/traffic_light_fine_detector/src/nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
float calWeightedIou(
const sensor_msgs::msg::RegionOfInterest & bbox1, const tensorrt_yolox::Object & bbox2)
{
int x1 = std::max(static_cast<int>(bbox1.x_offset), bbox2.x_offset);
int x2 = std::min(static_cast<int>(bbox1.x_offset + bbox1.width), bbox2.x_offset + bbox2.width);
int y1 = std::max(static_cast<int>(bbox1.y_offset), bbox2.y_offset);
int y2 = std::min(static_cast<int>(bbox1.y_offset + bbox1.height), bbox2.y_offset + bbox2.height);
int area1 = std::max(x2 - x1, 0) * std::max(y2 - y1, 0);
int area2 = bbox1.width * bbox1.height + bbox2.width * bbox2.height - area1;
const int x1 = std::max(static_cast<int>(bbox1.x_offset), bbox2.x_offset);

Check warning on line 35 in perception/traffic_light_fine_detector/src/nodelet.cpp

View check run for this annotation

Codecov / codecov/patch

perception/traffic_light_fine_detector/src/nodelet.cpp#L35

Added line #L35 was not covered by tests
const int x2 =
std::min(static_cast<int>(bbox1.x_offset + bbox1.width), bbox2.x_offset + bbox2.width);
const int y1 = std::max(static_cast<int>(bbox1.y_offset), bbox2.y_offset);

Check warning on line 38 in perception/traffic_light_fine_detector/src/nodelet.cpp

View check run for this annotation

Codecov / codecov/patch

perception/traffic_light_fine_detector/src/nodelet.cpp#L37-L38

Added lines #L37 - L38 were not covered by tests
const int y2 =
std::min(static_cast<int>(bbox1.y_offset + bbox1.height), bbox2.y_offset + bbox2.height);
const int area1 = std::max(x2 - x1, 0) * std::max(y2 - y1, 0);
const int area2 = bbox1.width * bbox1.height + bbox2.width * bbox2.height - area1;

Check warning on line 42 in perception/traffic_light_fine_detector/src/nodelet.cpp

View check run for this annotation

Codecov / codecov/patch

perception/traffic_light_fine_detector/src/nodelet.cpp#L40-L42

Added lines #L40 - L42 were not covered by tests
if (area2 == 0) {
return 0.0;
}
Expand Down
Loading