1

I am trying to use the PCL library (which I am new to) to get an image out of an unorganized point cloud obtained from a .las file which is later on translated into a .pcd file for the PCL library to use. For visualizing the point cloud I made use of the sample code found here: https://github.com/UnaNancyOwen/Tutorials/blob/master/tutorials/range_image_border_extraction/range_image_border_extraction.cpp

The point cloud can be retrieved from: https://senseflycom.s3.amazonaws.com/datasets/concrete-bridge/concrete-bridge-column_densified_point_cloud.las

For .las to .pcd I used https://github.com/murtiad/las2pcd

The camera position is not right by default (I would need to interact with the visualizer with the mouse to reach the correct positioning) but the quality is correct and I am capable of dumping a photo by using the saveScreenshot method.

I would appreciate any advice, I am running Ubuntu 18.04 and pcl 1.8. Have also gone through every example and existing post I have been able to find on pcl-users.org. I have already tried OpenCV but its quality is not good for unorganized point clouds as far as I can tell.

The situation I am facing is:

a. If I modify the slightest of the camera parameters by calling any (or all) of these functions, the quality drops and it seems like unfocused:

  pcl::visualization::PCLVisualizer viewer ("3D Viewer");
  viewer.setBackgroundColor (1, 1, 1);
  viewer.addCoordinateSystem (1.0f, "reference");
  /* Evil functions */
  viewer.initCameraParameters();
  viewer.setCameraPosition(0, -30, 0,    0, 0, 0,   0, 0, 1);
  viewer.setCameraFieldOfView(0.523599);
  viewer.setCameraClipDistances(0.00522511, 50);

b. If I don't modify any of the parameters, quality remains but I need to interact with the mouse which I intend to avoid.

c. Even after interacting with the mouse and modifying the view, camera parameters remain unchanged (actually used this post on the loop PCL: Visualize a point cloud ):

    viewer.getCameras(cam);
    //--------------------
    // -----Main loop-----
    //--------------------
    while (!viewer.wasStopped()) {
        //    range_image_borders_widget->spinOnce ();
        viewer.spinOnce();
        pcl_sleep(0.5);
        cout << "Cam: " << endl
             << " - pos: (" << cam[0].pos[0] << ", " << cam[0].pos[1] << ", " << cam[0].pos[2] << ")" << endl
             << " - view: (" << cam[0].view[0] << ", " << cam[0].view[1] << ", " << cam[0].view[2] << ")" << endl
             << " - focal: (" << cam[0].focal[0] << ", " << cam[0].focal[1] << ", " << cam[0].focal[2] << ")" << endl
             << " - fovy: (" << cam[0].fovy << " - clip: (" << cam[0].clip[0] << " , " << cam[0].clip[1] << ")" << endl;
    }
Milan
  • 1,743
  • 2
  • 13
  • 36
  • For point c: You are getting the camera values before entering the spin loop. Put the call `viewer.getCameras(cam);` into the while loop. – serkan.tuerker Mar 25 '19 at 23:06
  • 1
    Thanks @kanstar, that fixed that. I was expecting to get a reference as the API indicated a vector reference but that wasnt the case obviously – Hector Hernandez Mar 26 '19 at 13:07

1 Answers1

0

The problem was positioning the camera 180º and having and ordered point cloud which led to height = 1 and in effect same colors and shape from both angles.

Effectively modifying the "Evil Code" to this code below , "fixed the issue":

 viewer.initCameraParameters();
 viewer.setCameraPosition(0, 30, 0,    0, 0, 0,   0, 0, 1);
 viewer.setCameraFieldOfView(0.523599);
 viewer.setCameraClipDistances(0.00522511, 50);