Skip to content

Commit 0d21936

Browse files
committed
lut idea
1 parent b6414f2 commit 0d21936

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

projected_point_cloud_transport/src/projected_subscriber.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ void ProjectedPublisher::deprojectPlaneToCloud(const cv::Mat& projected_pointclo
9393
size_t valid_points = 0;
9494

9595
// if the pointcloud is NOT already organized, we need to apply the projection
96-
for () {
97-
for () {
96+
for (int row = 0; row < projected_pointcloud_image.rows; row++) {
97+
for (int col = 0; col < projected_pointcloud_image.cols; col++) {
9898
const uint16_t& depth = projected_pointcloud_image.at<uint16_t>(row, col);
9999

100100
if(depth == 0){
@@ -140,18 +140,16 @@ void ProjectedSubscriber::deprojectSphereToCloud(){
140140
{
141141
for(int col = 0; col < spherical_image.cols; col++)
142142
{
143-
uint16_t cell = spherical_image.at<uint16_t>(row, col);
143+
const uint16_t cell = spherical_image.at<uint16_t>(row, col);
144144
if(cell == 0)
145145
{
146146
continue;
147147
}
148148
// convert the spherical image pixel to a point cloud point
149-
double rho = static_cast<double>(cell) / 1000.0; // meters
150-
double phi = (row - phi_bins / 2.0) / phi_resolution;
151-
double theta = (col - theta_bins / 2.0) / theta_resolution;
152-
pcl_itr[0] = rho * std::sin(phi) * std::cos(theta);
153-
pcl_itr[1] = rho * std::sin(phi) * std::sin(theta);
154-
pcl_itr[2] = rho * std::cos(phi);
149+
const double rho = static_cast<double>(cell) / 1000.0; // meters
150+
pcl_itr[0] = rho * sinPhi(row, col) * cosTheta(row, col);
151+
pcl_itr[1] = rho * sinPhi(row, col) * sinTheta(row, col);
152+
pcl_itr[2] = rho * cosPhi(row, col);
155153
++pcl_itr;
156154
valid_points++;
157155
}

0 commit comments

Comments
 (0)