Skip to content

Commit

Permalink
keep index to set box color
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada committed Dec 11, 2024
1 parent dd79753 commit 60dda87
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jsk_rviz_plugins/src/bounding_box_display_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ namespace jsk_rviz_plugins
float min_value = DBL_MAX;
float max_value = -DBL_MAX;
// filter boxes before drawing
std::vector<int> box_indices;
std::vector<jsk_recognition_msgs::BoundingBox> boxes;
for (size_t i = 0; i < msg->boxes.size(); i++) {
jsk_recognition_msgs::BoundingBox box = msg->boxes[i];
Expand All @@ -222,6 +223,7 @@ namespace jsk_rviz_plugins
continue;
}
boxes.push_back(box);
box_indices.push_back(i);
min_value = std::min(min_value, msg->boxes[i].value);
max_value = std::max(max_value, msg->boxes[i].value);
}
Expand Down Expand Up @@ -264,7 +266,7 @@ namespace jsk_rviz_plugins
dimensions[1] = box.dimensions.y;
dimensions[2] = box.dimensions.z;
shape->setScale(dimensions);
QColor color = getColor(i, box, min_value, max_value);
QColor color = getColor(box_indices[i], box, min_value, max_value);
shape->setColor(color.red() / 255.0,
color.green() / 255.0,
color.blue() / 255.0,
Expand All @@ -279,6 +281,7 @@ namespace jsk_rviz_plugins
float min_value = DBL_MAX;
float max_value = -DBL_MAX;
// filter boxes before drawing
std::vector<int> box_indices;
std::vector<jsk_recognition_msgs::BoundingBox> boxes;
for (size_t i = 0; i < msg->boxes.size(); i++) {
jsk_recognition_msgs::BoundingBox box = msg->boxes[i];
Expand All @@ -287,6 +290,7 @@ namespace jsk_rviz_plugins
continue;
}
boxes.push_back(box);
box_indices.push_back(i);
min_value = std::min(min_value, msg->boxes[i].value);
max_value = std::max(max_value, msg->boxes[i].value);
}
Expand Down Expand Up @@ -324,7 +328,7 @@ namespace jsk_rviz_plugins
edge->setMaxPointsPerLine(2);
edge->setNumLines(12);
edge->setLineWidth(line_width_);
QColor color = getColor(i, box, min_value, max_value);
QColor color = getColor(box_indices[i], box, min_value, max_value);
edge->setColor(color.red() / 255.0,
color.green() / 255.0,
color.blue() / 255.0,
Expand Down

0 comments on commit 60dda87

Please sign in to comment.