Twin blogs

Wednesday, 5 December 2012

Georeferncing 3D pointclouds with open source tools


Hi all,
since every pointcloud created with Structure-from-Motion comes in its own, relative coordinate system, you often need to georeference the pointclouds in order to use it for archaeological purposes.

I would like to post some notes about a pretty easy way to georeference 3D pointclouds.
In GRASS GIS 7  there are now the modules v.in.ply, v.rectify and v.ply.out available (thanks to Markus Metz of the GRASS Team and TOPOI Berlin) that allow to georeference pointclouds. There will be soon a module that does all – import, transformation and export for the use of the pointcloud in other applications as Meshlab or CAD systems in one step (v.ply.rectify).  These modules can be easily installed under Install extensions from addons.

To accomplish the transformation of the coordinates you need to create a simple .txt file containing the coordinates from the pointcloud, and the real coordinates.
For this it is useful, beforehand in the field, to put at least four (more is better) markers into or near the object you want to model with SfM. The control points need to be visible in the point cloud, so it can help to use a distinctive color for the targets. After taking the photos, don´t forget to take the measurements of the control points!
If you have your pointclouds and the measured coordinates, open the point cloud with Cloud Compare, click on it and open “point list picking”.
Pick the control points one after the other and save the list (xyz) as .txt with the same name as the .ply file in the same folder. Remember the right order (or put numbers on it)!

Picking control points in Cloud Compare 
Then open the .txt and add the coordinates taken in the field to the picked coordinates in the following order:
xyz (from the pointcloud) – xyz (real coordinates) – 0 or 1
The coordinates have to be separated by a space. Use a decimal for the 1000 separator.
For example:
0.215062 -0.873330 -5.366510 323249.970 5907123.953 91.777 1
0.118612 -0.559895 -5.421750 323249.566 5907123.228 92.772 0
0.174586 -0.641221 -5.727870 323248.603 5907123.008 91.996 1

The 0 or 1 at the end of each line indicates whether the coordinates in this line are used for transformation (1) or not (0). At least four lines have to be active!
Save the .txt-file with the same name as your point cloud.
After importing the pointcloud with v.in.ply into GRASS, open v.rectify and add the point cloud in the required field. You have to check Perform 3D transformation and load the .txt-file in the appropriate filed under the optional flag. By checking the Print RMS errors Box you can see the errors of the single control points and choose the best ones (by changing 0 and 1 in the .txt-file) before the actual computation (you have to uncheck the RMS-Box then).

GRASS GIS
When the transformation is done, you can export the georeferenced 3D pointcloud again with v.out.ply. Here you should enter red,green,blue,alpha (without space) in the Name of attribute columns to be exported - field to conserve the color of the pointcloud.
In some cases you want to edit the coordinates so you can use the pointcloud in a graphic software like Mehslab, or in an CAD environment. For using the real coordinates in Meshlab, you have to cut the first couple of digits, which can easily be done in GRASS GIS with v.transform.

All in all, using some SfM-Kit, Meshlab, Cloud Compare and GRASS GIS offers the possibility to create nice, georeferenced 3D models that can be used for archaeological purposes.
Maybe this is useful for anyone, some more information is provided in the GRASS Manuals or here.

Three archaeological layers as original SfM output (left) and georeferenced (right, moved only in height)




No comments:

Post a Comment