Import scans into numpy

Starting with BlenSor 1.0.18 RC3 the scans can be saved in a format readable by numpy.loadtxt. This makes it very easy to process scans via python.

To save a scan in numpy format select "Save to File" in the scanner menu.

To select the numpy format use .numpy as the file extension, or .numpy.gz to save it as a compressed numpy file.

To import the data into python simply use the numpy.loadtxt method.

As of BlenSor 1.0.18 RC3 the columns in the array are as follows:

timestamp 
yaw, pitch
distance,distance_noise
x,y,z
x_noise,y_noise,z_noise
object_id
255*color[0]
255*color[1]
255*color[2]
idx

Below is an example, that reads a scan and filters the points based on the distance along the Y-coordinate

import numpy as np

scan = np.loadtxt("/tmp/data/samplescan00000.numpy")

print ("Points {0} / Values per point {1}".format(
        scan.shape[0],
        scan.shape[1]))

#Filter all points with a distance along the z coordinate greater than 3.98
filtered = scan[scan[:,7] > -3.98]

print ("Points {0} / Values per point {1}".format(
    filtered.shape[0],
    filtered.shape[1]))


"""Output:
Points 6952 / Values per point 16
Points 3508 / Values per point 16
"""
Uni Salzburg

social