File size: 3,225 Bytes
7f585cf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
from mayavi import mlab
import argparse
import sys
import numpy as np
from EMS.utilities import read_ply, showPoints
from EMS.EMS_recovery import EMS_recovery
import timeit
def main(argv):
parser = argparse.ArgumentParser(
description='Probabilistic Recovery of a superquadric surface from a point cloud file *.ply.')
parser.add_argument(
'path_to_data',
# default = '~/EMS-probabilistic_superquadric_fitting/MATLAB/example_scripts/data/noisy_pointCloud_example_1.ply',
help='Path to the directory containing the point cloud file *.ply.'
)
parser.add_argument(
'--visualize',
action = 'store_true',
help='Visualize the recoverd superquadric and the input point cloud.'
)
parser.add_argument(
'--runtime',
action = 'store_true',
help='Show the runtime.'
)
parser.add_argument(
'--result',
action = 'store_true',
help='Print the recovered superquadric parameter.'
)
parser.add_argument(
'--outlierRatio',
type = float,
default = 0.2,
help='Set the prior outlier ratio. Default is 0.2.'
)
parser.add_argument(
'--adaptiveUpperBound',
action = 'store_true',
help='Implemet addaptive upper bound to limit the volume of the superquadric.'
)
parser.add_argument(
'--arcLength',
type = float,
default = 0.2,
help='Set the arclength (resolution) for rendering the superquadric. Default is 0.2.'
)
parser.add_argument(
'--pointSize',
type = float,
default = 0.1,
help='Set the point size for plotting the point cloud. Default is 0.2.'
)
args = parser.parse_args(argv)
print('----------------------------------------------------')
print('Loading point cloud from: ', args.path_to_data, '...')
point = read_ply(args.path_to_data)
print('Point cloud loaded.')
print('----------------------------------------------------')
# first run to eliminate jit compiling time
sq_recovered, p = EMS_recovery(point)
start = timeit.default_timer()
sq_recovered, p = EMS_recovery(point,
OutlierRatio=args.outlierRatio,
AdaptiveUpperBound=args.adaptiveUpperBound
)
stop = timeit.default_timer()
print('Superquadric Recovered.')
if args.runtime is True:
print('Runtime: ', (stop - start) * 1000, 'ms')
print('----------------------------------------------------')
if args.result is True:
print('shape =', sq_recovered.shape)
print('scale =', sq_recovered.scale)
print('euler =', sq_recovered.euler)
print('translation =', sq_recovered.translation)
print('----------------------------------------------------')
if args.visualize is True:
fig = mlab.figure(size=(400, 400), bgcolor=(1, 1, 1))
sq_recovered.showSuperquadric(arclength = args.arcLength)
showPoints(point, scale_factor=args.pointSize)
mlab.show()
if __name__ == "__main__":
main(sys.argv[1:]) |