get started with point clouds - acfr/snark GitHub Wiki
Once you have snark installed, download datasets below (or use your own) and try the commands and pipelines of this tutorial.
The examples are for Linux. On Windows, it all should work in cygwin and many things in the command prompt.
Below is a single Riegl lidar scan of the courtyard in front of Australian Centre for Field Robotics (ACFR). The ground and non-ground were algorithmically extracted and put in separate files:
- http://perception.acfr.usyd.edu.au/data/samples/riegl/rose.st/rose.st.nonground.csv.gz
- http://perception.acfr.usyd.edu.au/data/samples/riegl/rose.st/rose.st.ground.csv.gz
gunzip rose.st.nonground.csv.gz head rose.st.nonground.csv
The files contain rgb-coloured cartesian points in csv format: x,y,z,r,g,b.
view uncoloured points
cat rose.st.nonground.csv | view-points cat rose.st.nonground.csv | view-points --colour=blue
view coloured points
cat rose.st.nonground.csv | view-points --fields=x,y,z,r,g,b
by the way, view without unpacking
zcat rose.st.nonground.csv.gz | view-points --fields=x,y,z,r,g,b
view both ground and non-ground
cat rose.st.ground.csv rose.st.nonground.csv | view-points --fields=x,y,z,r,g,b
or better
view-points --fields=x,y,z,r,g,b rose.st.ground.csv rose.st.nonground.csv
view both files with one fed on stdin
cat rose.st.ground.csv | view-points --fields=x,y,z,r,g,b rose.st.nonground.csv
specify properties for stdin data ("-" conventionally stands for stdin)
cat rose.st.ground.csv | view-points "-;colour=magenta" "rose.st.nonground.csv;fields=x,y,z,r,g,b"
colour only non-ground (fields=x,y,z is default)
view-points rose.st.ground.csv "rose.st.nonground.csv;fields=x,y,z,r,g,b"
Notice that the csv file does not contain field names or any header or meta-information. It is the user who renders meaning to the data.
comma and snark utilities obviously will work even if you chop part of the file or process a stream of data (e.g. a live lidar feed), which by definition cannot have a header.
And you can reinterpret the meaning of the fields the way you like. For example, try to swap red and green colour channels on ground data:
view-points "rose.st.ground.csv;fields=x,y,z,g,r,b" "rose.st.nonground.csv;fields=x,y,z,r,g,b"
or swap y and z in one of the files:
view-points "rose.st.ground.csv;fields=x,z,y,r,g,b" "rose.st.nonground.csv;fields=x,y,z,r,g,b"
to be continued...
As you can see, loading such large files takes time, mostly because handling ASCII data is slow. Let us convert them into a simple binary format and see how it affects the performance.
You are unlikely to worry about the binary representation of your data, but here it is:
The binary format in comma and snark is the csv counterpart. It is simple and homogeneous, having several types, which have endianness of your system (i.e. mostly they are little-endian):
- byte, char
- signed and unsigned 2-, 4-, and 8-byte integer
- 4-byte float, 8-byte double
- 8-byte time in microseconds since Linux epoch (midnight of 1 January 1970)
- fixed string
convert a csv file into binary as 3 doubles followed by 3 unsigned bytes for colour
cat rose.st.nonground.csv | csv-to-bin 3d,3ub > rose.st.nonground.bin cat rose.st.ground.csv | csv-to-bin 3d,3ub > rose.st.ground.bin
convert back to csv
cat rose.st.ground.bin | csv-from-bin 3d,3ub > rose.st.ground.csv
or just take a look what is inside
cat rose.st.ground.bin | csv-from-bin 3d,3ub | head cat rose.st.ground.bin | csv-from-bin 3d,3ub | less
view binary files
view-points --fields=x,y,z,r,g,b --binary=3d,3ub rose.st.ground.bin rose.st.nonground.bin
view a binary and a csv file
view-points --fields=x,y,z,r,g,b rose.st.ground.csv "rose.st.nonground.bin;binary=3d,3ub"
convert to binary and view on the fly
cat rose.st.nonground.csv | csv-to-bin 3d,3ub | view-points --fields=x,y,z,r,g,b --binary=3d,3ub
- Left press and hold rotates the scene around the centre
- Right press and hold translates the scene
- Double left click changes the centre of the scene
- Double right click outputs to stdout the coordinates of the clicked point
rm -rf pipe && mkfifo pipe && cat pipe | view-points "rose.st.ground.csv;fields=x,y,z,r,g,b" "-;colour=sky;weight=10" --orthographic > pipe
publish a real time playback of georeferenced velodyne data on port 12345, visualise the data in real time and show points selected with a double right click
cat velodyne-georeferenced.bin | csv-play --binary t,3d,ui | io-publish --size $( csv-size t,3d,ui ) -m 10000 tcp:12345 rm -rf pipe && mkfifo pipe && cat pipe | view-points "tcp:localhost:12345;binary=t,3d,ui;fields=,x,y,z,block" "-;fields=x,y,z;colour=sky;weight=10" > pipe
similar to above but uses different colours for the shown points and adds labels next to the points indicating the click order
cat velodyne-georeferenced.bin | csv-play --binary t,3d,ui | io-publish --size $( csv-size t,3d,ui ) -m 10000 tcp:12345 rm -rf pipe && mkfifo pipe && cat pipe | view-points "tcp:localhost:12345;binary=t,3d,ui;fields=,x,y,z,block" "-;fields=x,y,z,id,label;weight=10" | csv-paste "-" line-number line-number > pipe
note: to make georeferenced data, run the following command on raw velodyne and novatel data
cat novatel-raw.bin | novatel-to-csv --binary > novatel.bin velodyne_offset="0.0215,0.0026,-0.8822,-0.0014,0.0087,3.1143" cat velodyne-raw.bin | velodyne-to-csv -q --fields=t,x,y,z,scan --binary | points-frame --fields=t,x,y,z --binary=t,3d,ui --from $velodyne_offset --from "novatel.bin;binary=t,6d" | csv-from-bin t,3d,ui > velodyne-georeferenced.bin
to be continued...