Skip to content

Commit 4cf13af

Browse files
committed
Warn on mask resize
1 parent 83adf73 commit 4cf13af

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

include/ouster_ros/os_ros.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ uint64_t ulround(T value) {
185185
return static_cast<uint64_t>(rounded_value);
186186
}
187187

188+
void warn_mask_resized(int image_cols, int image_rows,
189+
int scan_height, int scan_width);
190+
188191
template <typename pixel_type>
189192
ouster::img_t<pixel_type> load_mask(const std::string& mask_path,
190193
size_t height, size_t width) {
@@ -196,6 +199,7 @@ ouster::img_t<pixel_type> load_mask(const std::string& mask_path,
196199
}
197200

198201
if (image.rows != static_cast<int>(height) || image.cols != static_cast<int>(width)) {
202+
warn_mask_resized(image.cols, image.rows, static_cast<int>(height), static_cast<int>(width));
199203
cv::Mat resized;
200204
cv::resize(image, resized, cv::Size(width, height), 0, 0, cv::INTER_NEAREST);
201205
image = resized;

src/os_ros.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ouster_ros/os_ros.h"
1313
// clang-format on
1414

15+
#include <ros/console.h>
1516
#include <tf2/LinearMath/Transform.h>
1617

1718
#include <tf2_eigen/tf2_eigen.h>
@@ -150,6 +151,13 @@ version parse_version(const std::string& fw_rev) {
150151
}
151152
}
152153

154+
void warn_mask_resized(int image_cols, int image_rows,
155+
int scan_height, int scan_width) {
156+
ROS_WARN_STREAM("Mask image has size (" << image_cols << "x" << image_rows << ")"
157+
<< " but incoming scans has size (" << scan_height << "x" << scan_width << ")."
158+
<< " Resizing mask to match the scans size.");
159+
}
160+
153161
} // namespace impl
154162

155163
geometry_msgs::TransformStamped transform_to_tf_msg(

0 commit comments

Comments
 (0)