Monday, April 30, 2018

Better point cloud visualization in Cloud Compare with Eye Dome Lighting shading

Typically, LiDAR point clouds are displayed as a mass of colored points without perception of depth in a viewer. This can be hard to visualize objects or find your orientation in the point cloud. CloudCompare has a shading filter called the Eye Dome Lighting or EDL for short that can be used to apply a sort of depth outline around objects in the point cloud.

To use the EDL shader, do the following:
  1. In CloudCompare, load a point cloud file.

    The point cloud is displayed.
  2. Optional. To color the cloud, select the menu option Edit | Colors | Height Ramp.

    The Gradient color dialog box appears.


  3. Accept the default settings and click OK.

    The cloud is displayed with a default height ramp from blue (lowest) to red (highest).
  4. Now improve the display by applying the EDL Shader. In the menu, select Display | Shaders and Filters | E.D.L. (Shader).

    The shading is applied to the point cloud.

Monday, March 26, 2018

Resolving Maven "trustAnchors parameter must be non-empty" error

I encountered this Maven error on a new Ubuntu 18.04 system while trying to perform a mvn build on a Google AppEngine project. A screenshot of the error message is shown below.


It seems to be complaining about some "java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty" error.

After trying out some suggestions about regenerating Java security certificates, which didn't work, I managed to resolve the problem by creating a Maven  settings.xml file under a hidden folder .m2 underneath the user's home directory.

An example settings.xml file is shown below.

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0                            http://maven.apache.org/xsd/settings-1.0.0.xsd">
   <localRepository>/home/yourname/.m2/repository</localRepository>
   <interactiveMode />
   <usePluginRegistry />
   <offline />
   <pluginGroups />
   <servers />
   <mirrors />
   <proxies>
      <!-- 
               <proxy>
      <id>default</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy-host</host>
      <port>8080</port>
      <username>user</username>
      <password>password123</password>
      <nonProxyHosts>localhost,127.0.0.1</nonProxyHosts>
    </proxy> -->
   </proxies>
   <activeProfiles>
      <!--make the profile active all the time -->
      <activeProfile>securecentral</activeProfile>
   </activeProfiles>
   <profiles>
      <profile>
         <id>securecentral</id>
         <!--Override the repository (and pluginRepository) "central" from the
                     Maven Super POM -->
         <repositories>
            <repository>
               <id>central</id>
               <url>http://repo1.maven.apache.org/maven2/</url>
               <releases>
                  <enabled>true</enabled>
               </releases>
            </repository>
         </repositories>
         <pluginRepositories>
            <pluginRepository>
               <id>central</id>
               <url>http://repo1.maven.apache.org/maven2/</url>
               <releases>
                  <enabled>true</enabled>
               </releases>
            </pluginRepository>
         </pluginRepositories>
      </profile>
   </profiles>
</settings>
Change the localRepository tag from /home/yourname/.m2/repository to correct location of your Maven repository.

Then place this the settings.xml file in the following location /home/your_user_id/.m2/

Now when running Maven build commands, the error messages no longer appear.


Wednesday, March 7, 2018

Fixing "Cannot resolve symbol Theme" error in Android Studio

If you have ever encountered unusual "cannot resolve symbol" messages with regards to Android resource XML files (an example is the screenshot below), which cannot be resolved by running Android Studio's Build | Clean Project or Build | Rebuild Project menu commands, then fixing the issue is very simple.


To resolve the problem, click on the Sync Project with Gradle Files icon in Android Studio, as shown in the screenshot below, or select Tools | Android | Sync Project with Gradle Files. 

Processing files will appear and at the end of it, the error messages no longer appear, as shown below.

Monday, February 26, 2018

Use PDAL to register a point cloud to control points

Sometimes, some 3D LiDAR point cloud data are not at the correct location or they are not aligned with other point clouds. When this happens, at least 3 control points from the point cloud and the reference need to be identified and a transformation matrix (usually a 4x4 homogeneous matrix) be calculated.

Once the matrix has been calculated, PDAL's transformation filter can then be used to perform the registration or transformation of the point cloud to the reference.

While PDAL can apply the transformation, it does not have a tool for calculating the matrix. This has to be done externally. This post uses a simple WebApp calculator at this site https://dominoc925-pages.appspot.com/webapp/calc_transf3d/default.html to calculate a rigid 4x4 transformation matrix given 2 corresponding sets of 3 or more control points.

Identifying 2 sets of corresponding control points

  1. Using a point cloud viewer such as FugroViewer, identify 3 or more source control points from the unregistered point cloud., e.g. p1, p2, p3 and p4.




  2. Using a GPS receiver or from a database, identify the corresponding points from the destination reference system.



Calculating the 4x4 transformation matrix
  1. Open up url https://dominoc925-pages.appspot.com/webapp/calc_transf3d/default.html in an Internet browser.
  2. In the Source 3D points field, type or paste in the source control point coordinates from the previous section.


  3. In the Destination 3D points field, type or paste in the corresponding control points from the destination reference system from the previous section.
  4. Click Calculate.

    The 4x4 transformation matrix and root mean square error is calculated.


    Note: if the RMSE is large, then there may be some error in the input coordinates.
  5. Using a text editor, create a PDAL pipeline JSON file which specifies the input, filter, and output. Copy and paste the 4x4 transformation matrix into the matrix field in the JSON file as shown below. Replace the commas with blanks. 
{
  "pipeline":[
    "input.laz",
    {
      "type":"filters.transformation",
      "matrix":"
0.21095277662308629 0.9774781497556848 -0.00594918357528593 23238.318780198064 
-0.9774332258657229 0.21100438075203337 0.01007175640974158 30100.055196603218 
0.011100225616467532 0.0036902647131527543 0.9999315811282344 32.53070599039722 
0 0 0 1"
    },
    {
      "type":"writers.las",
   "compression": "laszip",
      "filename":"output.laz"
    }
  ]
}

Running the transformation

  1. In Windows, open up the OSGeo4W command prompt.

    The Administrator: OSGeo4W Shell appears.


  2. In the Command Prompt, type in the following and press RETURN:

    C:> pdal pipeline transform_pipeline.json

    where transform_pipeline.json is the JSON file created in the previous section.

    The point cloud is transformed.

Monday, February 19, 2018

WebApp for calculating the 4x4 transformation matrix between 2 corresponding sets of 3D points

In working with 3D point clouds, one of the task may be to register or transform the point cloud to known ground control points (GCPs) on the ground with corresponding control points in the point cloud. For instance, the screen shot below shows the point cloud with four control points p1, p2, p3, and p4.

Note: At least 3 corresponding set of points are needed to calculate a rigid transformation matrix.

From the point cloud, the from-control points can be measured:

On the ground, the actual ground control points can be obtained, perhaps from a GPS receiver:


With the measured points from the point cloud and the corresponding control points on the ground, a 4x4 homogeneous transformation matrix can be calculated and used to rigidly transform the point cloud to the actual ground coordinate system. 

This WebApp calculator at https://dominoc925-pages.appspot.com/webapp/calc_transf3d/default.html can be used to calculate the 4x4 transformation matrix, as well as the root mean square error (RMSE) as an indicator of the quality of the control points i.e. the smaller the RMSE, the better they are. The WebApp uses the Numeric Javascript matrix library from http://www.numericjs.com/ for performing the required SVD decomposition to calculate the transformation matrix. Note that the library has some unfixed bugs in the SVD decomposition for certain cases and I may probably replace this with an alternative solution in future.  
  1. Paste the "from control points" into the Source Points text area field. 

  2. Paste the ground control point values into the Destination Points text area field.
  3. Click the Calculate button.



    The resultant transformation matrix appears in the 4x4 Transformation Matrix field. The RMSE for the calculation is displayed in the RMSE field.

Monday, February 12, 2018

Displaying WKT geometry string in QGIS with getWKT plugin

If you want to display the Well Known Text (WKT) string of a selected geometry in QGIS, there is a plug-in getWKT that can be used for this purpose. The screen shot below shows the Plug-in Manager's description of the getWKT plug-in.
 
 To use the getWKT plug-in, do the following:
  1. In QGIS, click the Select Features by area of single click button. Using the mouse, click on a feature.

    A feature is selected and highlighted in yellow.
  2. Then click the getWKT icon in the tool bar.



    The GetWKT dialog box appears with the WKT string of the selected geometry.

Monday, February 5, 2018

Find the 3x3 transformation matrix given a set of 3D points using Octave

I have 2 corresponding pair of 3 measured 3D points - one original coordinates (let's call as X) and the other destination or reference coordinates (say Y) . I wanted to find the transformation matrix (say A) that can transform the original coordinates to the destination coordinates.

Octave (an open source software alternative to Matlab. See https://www.gnu.org/software/octave/) has the tools to determine the 3x3 transformation matrix. This post shows how to perform the calculation.

Given the 3 original measured 3D points X:
x1 = (2, -1, 2)
x2 = (-1, 2, 2)
x3 = (2, 2, -1)

And the 3 measured destination 3D points Y:
y1 = (-2, -9, -30)
y2 = (-23, 12, 9)
y3 = (13, 6, -6)

  1. First, write out the transformation and coordinates in the following form

    AX=Y

    where A is the unknown transformation matrix,
    X is a matrix of the original coordinates formed by concatenating the points as column vectors X = [x1, x2, x3]
    Y is a matrix of the destination coordinates formed by concatenating the points as column vectors Y = [y1, y2, y3]
  2. Run Octave. In the command prompt, enter the X matrix values:

    $> X = [2 -1 2; -1 2 2; 2 2 -1]
  3. In the prompt, enter the Y matrix values:

    $> Y = [-2 -23 13; -9 12 6; -30 9 -6]
  4. Now calculate the inverse of X by typing the following into the prompt.

    $> IX = inv(X)
  5. The transformation matrix A can be calculated by simply multiplying the matrix Y with the inverse of X. Type in the following at the prompt:

    $> A = Y * IX
  6. Optional. Use the calculated matrix A and multiply with the original coordinates X and check whether the resultant values matches the measured Y coordinates.