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(pointpainting_fusion): enable cloud display on image #9813

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
Original file line number Diff line number Diff line change
Expand Up @@ -316,54 +316,56 @@
// iterate points
// Requires 'OMP_NUM_THREADS=N'
omp_set_num_threads(omp_num_threads_);
#pragma omp parallel for
for (int i = 0; i < iterations; i++) {
int stride = p_step * i;
unsigned char * data = &painted_pointcloud_msg.data[0];
unsigned char * output = &painted_pointcloud_msg.data[0];
// cppcheck-suppress-begin invalidPointerCast
float p_x = *reinterpret_cast<const float *>(&data[stride + x_offset]);
float p_y = *reinterpret_cast<const float *>(&data[stride + y_offset]);
float p_z = *reinterpret_cast<const float *>(&data[stride + z_offset]);
// cppcheck-suppress-end invalidPointerCast
point_lidar << p_x, p_y, p_z;
point_camera = lidar2cam_affine * point_lidar;
p_x = point_camera.x();
p_y = point_camera.y();
p_z = point_camera.z();

if (camera_projectors_[image_id].isOutsideHorizontalView(p_x, p_z)) {
continue;
}
std::vector<std::vector<Eigen::Vector2d>> local_vectors(omp_num_threads_);
#pragma omp parallel

Check warning on line 320 in perception/autoware_image_projection_based_fusion/src/pointpainting_fusion/node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/pointpainting_fusion/node.cpp#L319-L320

Added lines #L319 - L320 were not covered by tests
{
#pragma omp for
for (int i = 0; i < iterations; i++) {
int stride = p_step * i;
unsigned char * data = &painted_pointcloud_msg.data[0];
unsigned char * output = &painted_pointcloud_msg.data[0];
// cppcheck-suppress-begin invalidPointerCast
float p_x = *reinterpret_cast<const float *>(&data[stride + x_offset]);
float p_y = *reinterpret_cast<const float *>(&data[stride + y_offset]);
float p_z = *reinterpret_cast<const float *>(&data[stride + z_offset]);
// cppcheck-suppress-end invalidPointerCast
point_lidar << p_x, p_y, p_z;
point_camera = lidar2cam_affine * point_lidar;
p_x = point_camera.x();
p_y = point_camera.y();
p_z = point_camera.z();

if (camera_projectors_[image_id].isOutsideHorizontalView(p_x, p_z)) {
continue;
}

// project
Eigen::Vector2d projected_point;
if (camera_projectors_[image_id].calcImageProjectedPoint(
cv::Point3d(p_x, p_y, p_z), projected_point)) {
// iterate 2d bbox
for (const auto & feature_object : objects) {
sensor_msgs::msg::RegionOfInterest roi = feature_object.feature.roi;
// paint current point if it is inside bbox
int label2d = feature_object.object.classification.front().label;
if (
!isUnknown(label2d) && isInsideBbox(projected_point.x(), projected_point.y(), roi, 1.0)) {
// cppcheck-suppress invalidPointerCast
auto p_class = reinterpret_cast<float *>(&output[stride + class_offset]);
for (const auto & cls : isClassTable_) {
// add up the class values if the point belongs to multiple classes
*p_class = cls.second(label2d) ? (class_index_[cls.first] + *p_class) : *p_class;
// project
Eigen::Vector2d projected_point;
if (camera_projectors_[image_id].calcImageProjectedPoint(
cv::Point3d(p_x, p_y, p_z), projected_point)) {
// iterate 2d bbox
for (const auto & feature_object : objects) {
sensor_msgs::msg::RegionOfInterest roi = feature_object.feature.roi;
// paint current point if it is inside bbox
int label2d = feature_object.object.classification.front().label;
if (
!isUnknown(label2d) &&
isInsideBbox(projected_point.x(), projected_point.y(), roi, 1.0)) {
// cppcheck-suppress invalidPointerCast
auto p_class = reinterpret_cast<float *>(&output[stride + class_offset]);
for (const auto & cls : isClassTable_) {
// add up the class values if the point belongs to multiple classes
*p_class = cls.second(label2d) ? (class_index_[cls.first] + *p_class) : *p_class;
}
}
}
if (debugger_) {
int thread_id = omp_get_thread_num();
local_vectors[thread_id].push_back(projected_point);
}
}
#if 0
// Parallelizing loop don't support push_back
if (debugger_) {
debug_image_points.push_back(projected_point);
}
#endif
}
}

if (debugger_) {
std::unique_ptr<ScopedTimeTrack> inner_st_ptr;
if (time_keeper_)
Expand All @@ -373,6 +375,10 @@
debug_image_rois.push_back(feature_object.feature.roi);
}

for (const auto & local_vec : local_vectors) {
debug_image_points.insert(debug_image_points.end(), local_vec.begin(), local_vec.end());

Check warning on line 379 in perception/autoware_image_projection_based_fusion/src/pointpainting_fusion/node.cpp

View check run for this annotation

Codecov / codecov/patch

perception/autoware_image_projection_based_fusion/src/pointpainting_fusion/node.cpp#L379

Added line #L379 was not covered by tests
}

debugger_->image_rois_ = debug_image_rois;
debugger_->obstacle_points_ = debug_image_points;
debugger_->publishImage(image_id, input_roi_msg.header.stamp);
Expand Down
Loading