Skip to content

Commit

Permalink
style(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jun 14, 2024
1 parent 401ea64 commit 0ec18b4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ struct Histogram
void add(const cv::Vec3b & rgb)
{
for (int ch = 0; ch < 3; ++ch) {
int index =
std::clamp(
static_cast<int>(static_cast<float>(rgb[ch]) * static_cast<float>(bin) / 255.f),
0,
bin - 1
);
int index = std::clamp(
static_cast<int>(static_cast<float>(rgb[ch]) * static_cast<float>(bin) / 255.f), 0,
bin - 1);
data(ch, index) += 1.0f;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LineSegmentDetector : public rclcpp::Node
cv::Ptr<cv::LineSegmentDetector> line_segment_detector_;

static std::vector<cv::Mat> remove_too_outer_elements(
const cv::Mat & lines, const cv::Size & size) ;
const cv::Mat & lines, const cv::Size & size);
void on_image(const sensor_msgs::msg::Image & msg);
void execute(const cv::Mat & image, const rclcpp::Time & stamp);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ GraphSegment::GraphSegment(const rclcpp::NodeOptions & options)
: Node("graph_segment", options),
target_height_ratio_(static_cast<float>(declare_parameter<float>("target_height_ratio"))),
target_candidate_box_width_(
static_cast<int>(declare_parameter<int>("target_candidate_box_width"))
)
static_cast<int>(declare_parameter<int>("target_candidate_box_width")))
{
using std::placeholders::_1;

Expand All @@ -47,9 +46,7 @@ GraphSegment::GraphSegment(const rclcpp::NodeOptions & options)
// additional area pickup module
if (declare_parameter<bool>("pickup_additional_areas", true)) {
similar_area_searcher_ =
std::make_unique<SimilarAreaSearcher>(
declare_parameter<float>("similarity_score_threshold")
);
std::make_unique<SimilarAreaSearcher>(declare_parameter<float>("similarity_score_threshold"));
}
}

Expand All @@ -59,9 +56,7 @@ cv::Vec3b random_hsv(int index)
auto base = static_cast<double>(index);
return {
static_cast<unsigned char>(std::fmod(base * 0.7, 1.0) * 180),
static_cast<unsigned char>(0.7 * 255),
static_cast<unsigned char>(0.5 * 255)
};
static_cast<unsigned char>(0.7 * 255), static_cast<unsigned char>(0.5 * 255)};
};

int GraphSegment::search_most_road_like_class(const cv::Mat & segmented) const
Expand All @@ -70,8 +65,7 @@ int GraphSegment::search_most_road_like_class(const cv::Mat & segmented) const
const float r = target_height_ratio_;
cv::Point2i target_px(
static_cast<int>(static_cast<float>(segmented.cols) * 0.5),
static_cast<int>(static_cast<float>(segmented.rows) * r)
);
static_cast<int>(static_cast<float>(segmented.rows) * r));
cv::Rect2i rect(target_px + cv::Point2i(-bw, -bw), target_px + cv::Point2i(bw, bw));

std::unordered_map<int, int> areas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void Lanelet2Overlay::on_image(const sensor_msgs::msg::Image & msg)
// Search synchronized pose
float min_abs_dt = std::numeric_limits<float>::max();
std::optional<Pose> synched_pose{std::nullopt};
for (const auto& pose : pose_buffer_) {
for (const auto & pose : pose_buffer_) {
auto dt = (rclcpp::Time(pose.header.stamp) - stamp);
auto abs_dt = std::abs(dt.seconds());
if (abs_dt < min_abs_dt) {
Expand All @@ -93,7 +93,7 @@ void Lanelet2Overlay::on_line_segments(const PointCloud2 & msg)
// Search synchronized pose
float min_dt = std::numeric_limits<float>::max();
geometry_msgs::msg::PoseStamped synched_pose;
for (const auto& pose : pose_buffer_) {
for (const auto & pose : pose_buffer_) {
auto dt = (rclcpp::Time(pose.header.stamp) - stamp);
auto abs_dt = std::abs(dt.seconds());
if (abs_dt < min_dt) {
Expand Down Expand Up @@ -160,8 +160,9 @@ void Lanelet2Overlay::draw_overlay_line_segments(
if (p2_is_visible) uv2 = from_camera2 / from_camera2.z();

if ((p1_is_visible) && (p2_is_visible))
return {true, cv::Point2i(static_cast<int>(uv1.x()), static_cast<int>(uv1.y())),
cv::Point2i(static_cast<int>(uv2.x()), static_cast<int>(uv2.y()))};
return {
true, cv::Point2i(static_cast<int>(uv1.x()), static_cast<int>(uv1.y())),
cv::Point2i(static_cast<int>(uv2.x()), static_cast<int>(uv2.y()))};

Eigen::Vector3f tangent = from_camera2 - from_camera1;
float mu = (epsilon - from_camera1.z()) / (tangent.z());
Expand All @@ -173,8 +174,9 @@ void Lanelet2Overlay::draw_overlay_line_segments(
from_camera2 = from_camera1 + mu * tangent;
uv2 = from_camera2 / from_camera2.z();
}
return {true, cv::Point2i(static_cast<int>(uv1.x()), static_cast<int>(uv1.y())),
cv::Point2i(static_cast<int>(uv2.x()), static_cast<int>(uv2.y()))};
return {
true, cv::Point2i(static_cast<int>(uv1.x()), static_cast<int>(uv1.y())),
cv::Point2i(static_cast<int>(uv2.x()), static_cast<int>(uv2.y()))};
};

for (const pcl::PointNormal & pn : near_segments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ void LineSegmentsOverlay::on_line_segments(const PointCloud2::ConstSharedPtr & l
color = cv::Scalar(0, 0, 255); // Red
}

cv::line(image, cv::Point(static_cast<int>(xy1(0)), static_cast<int>(xy1(1))),
cv::line(
image, cv::Point(static_cast<int>(xy1(0)), static_cast<int>(xy1(1))),
cv::Point(static_cast<int>(xy2(0)), static_cast<int>(xy2(1))), color, 2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ SegmentFilter::SegmentFilter(const rclcpp::NodeOptions & options)
cv::Point2i SegmentFilter::to_cv_point(const Eigen::Vector3f & v) const
{
cv::Point2i pt;
pt.x = static_cast<int>(-v.y() / max_range_ * static_cast<float>(image_size_) * 0.5f +
pt.x = static_cast<int>(
-v.y() / max_range_ * static_cast<float>(image_size_) * 0.5f +
static_cast<float>(image_size_) / 2.0);
pt.y = static_cast<int>(-v.x() / max_range_ * static_cast<float>(image_size_) * 0.5f +
static_cast<float>(image_size_));
pt.y = static_cast<int>(
-v.x() / max_range_ * static_cast<float>(image_size_) * 0.5f + static_cast<float>(image_size_));
return pt;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ class UndistortNode : public rclcpp::Node
cv::Size new_size = size;
if (OUTPUT_WIDTH_ > 0)
// set new_size along with aspect ratio
new_size = cv::Size(OUTPUT_WIDTH_,
static_cast<int>(static_cast<float>(OUTPUT_WIDTH_) *
(static_cast<float>(size.height) / static_cast<float>(size.width))));
new_size = cv::Size(
OUTPUT_WIDTH_, static_cast<int>(
static_cast<float>(OUTPUT_WIDTH_) *
(static_cast<float>(size.height) / static_cast<float>(size.width))));

cv::Mat new_k = cv::getOptimalNewCameraMatrix(k, d, size, 0, new_size);

Expand Down

0 comments on commit 0ec18b4

Please sign in to comment.