-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured files and added new installation instructions. Created setup files.
- Loading branch information
Showing
14 changed files
with
236 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
v1.0 | ||
---- | ||
- Generated setup files to install package. | ||
- Bumped version to 1.0 as it's completely operational. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ pc2graph | |
General Information | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
This is a Python script that converts a numpy.ndarray containing a point cloud | ||
This is a Python (2.7x) script that converts a numpy.ndarray containing a point cloud | ||
(x, y, z) into a NetworkX graph. | ||
|
||
The code also includes a function to extract shortest path information from a | ||
|
@@ -19,3 +19,27 @@ and Scientific Development (10.13039/501100003593) – Brazil (Process number 23 | |
|
||
Any questions or suggestions, feel free to contact me using one of the | ||
following e-mails: [email protected] or [email protected] | ||
|
||
|
||
Installation | ||
~~~~~~~~~~~~ | ||
|
||
To install this package use the command: | ||
|
||
.. code-block:: python | ||
python setup.py install | ||
or: | ||
|
||
.. code-block:: python | ||
pip install pc2graph | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
../data/point_cloud_example.txt | ||
../../data/point_cloud_example.txt |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2018-2019, Matheus Boni Vicari, pc2graph | ||
# All rights reserved. | ||
# | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
__author__ = "Matheus Boni Vicari" | ||
__copyright__ = "Copyright 2018-2019" | ||
__credits__ = ["Matheus Boni Vicari"] | ||
__license__ = "GPL3" | ||
__version__ = "1.0" | ||
__maintainer__ = "Matheus Boni Vicari" | ||
__email__ = "[email protected]" | ||
__status__ = "Development" | ||
|
||
|
||
__all__ = ['downsampling', 'shortpath'] | ||
|
||
import downsampling | ||
import shortpath | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2017, Matheus Boni Vicari, TLSeparation Project | ||
# Copyright (c) 2018-2019, Matheus Boni Vicari, pc2graph | ||
# All rights reserved. | ||
# | ||
# | ||
|
@@ -16,10 +16,10 @@ | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
__author__ = "Matheus Boni Vicari" | ||
__copyright__ = "Copyright 2017" | ||
__copyright__ = "Copyright 2018-2019" | ||
__credits__ = ["Matheus Boni Vicari"] | ||
__license__ = "GPL3" | ||
__version__ = "0.1" | ||
__version__ = "1.0" | ||
__maintainer__ = "Matheus Boni Vicari" | ||
__email__ = "[email protected]" | ||
__status__ = "Development" | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2017, Matheus Boni Vicari, TLSeparation Project | ||
# Copyright (c) 2018-2019, Matheus Boni Vicari, pc2graph | ||
# All rights reserved. | ||
# | ||
# | ||
|
@@ -16,10 +16,10 @@ | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
__author__ = "Matheus Boni Vicari" | ||
__copyright__ = "Copyright 2017" | ||
__copyright__ = "Copyright 2018-2019" | ||
__credits__ = ["Matheus Boni Vicari"] | ||
__license__ = "GPL3" | ||
__version__ = "0.1" | ||
__version__ = "1.0" | ||
__maintainer__ = "Matheus Boni Vicari" | ||
__email__ = "[email protected]" | ||
__status__ = "Development" | ||
|
@@ -32,9 +32,9 @@ | |
|
||
if __name__ == '__main__': | ||
|
||
# Declaring list of files to process and output folder. | ||
filelist = '../data/batch/files.txt' | ||
out_folder = '../data/batch/' | ||
# Declaring list of files to process and output directory. | ||
filelist = '../../data/batch/files.txt' | ||
out_dir = '../../data/batch/' | ||
|
||
# Declaring downsample size of 10 cm. | ||
downsample_size = 0.1 | ||
|
@@ -112,4 +112,4 @@ | |
# Stacking all variables and exporting. | ||
out_cloud = np.hstack((upscale_cloud, upscale_distance.reshape(-1, 1), | ||
diff.reshape(-1, 1))) | ||
np.savetxt('%s%s.txt' % (out_folder, fname), out_cloud, fmt='%1.3f') | ||
np.savetxt('%s%s.txt' % (out_dir, fname), out_cloud, fmt='%1.3f') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Copyright (c) 2018-2019, Matheus Boni Vicari, pc2graph | ||
# All rights reserved. | ||
# | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
__author__ = "Matheus Boni Vicari" | ||
__copyright__ = "Copyright 2018-2019" | ||
__credits__ = ["Matheus Boni Vicari"] | ||
__license__ = "GPL3" | ||
__version__ = "1.0" | ||
__maintainer__ = "Matheus Boni Vicari" | ||
__email__ = "[email protected]" | ||
__status__ = "Development" | ||
|
||
from downsampling import downsample_cloud | ||
from shortpath import array_to_graph | ||
import numpy as np | ||
import glob | ||
import os | ||
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
|
||
try: | ||
import mayavi.mlab as mlab | ||
|
||
# Setting up where to save the data. | ||
out_dir = '../../data/test_gif/' | ||
out_file = 'test' | ||
layer_delay = 2 | ||
|
||
# Setting up parameters to generate the graph. | ||
point_cloud = np.loadtxt('../../data/point_cloud_example.txt') | ||
downsample_dist = 0.05 | ||
kpairs = 3 | ||
knn = 100 | ||
nbr_dist_threshold = downsample_dist * 1.5 | ||
nbr_dist_threshold_step = 0.03 | ||
downsample_cloud = downsample_cloud(point_cloud, downsample_dist) | ||
|
||
# Obtaining base id (lowest point in the cloud). | ||
base_id = np.argmin(downsample_cloud[:, 2]) | ||
|
||
# Generating graph with option to return the step_register as True. | ||
G, step_register = array_to_graph(downsample_cloud, base_id, kpairs, | ||
knn, nbr_dist_threshold, | ||
nbr_dist_threshold_step, | ||
return_step=True) | ||
|
||
|
||
# Starts the iterative plotting. This will require the Mayavi package. | ||
iteration = 0 | ||
mlab.figure(bgcolor=(1, 1, 1), fgcolor=(0, 0, 0)) | ||
mlab.points3d(downsample_cloud[:, 0], downsample_cloud[:, 1], | ||
downsample_cloud[:, 2], color=(0.3, 0.3, 0.3), mode='point') | ||
for s in np.unique(step_register): | ||
mask = step_register == s | ||
mlab.points3d(downsample_cloud[mask, 0], downsample_cloud[mask, 1], | ||
downsample_cloud[mask, 2], color=(1, 0, 0), mode='point') | ||
mlab.savefig(out_dir + '%s.png' % iteration) | ||
iteration += 1 | ||
mlab.close() | ||
|
||
# Generating the list of step images to join in a gif later. | ||
file_list = glob.glob('%s*.png' % out_dir) | ||
file_list = [os.path.basename(f) for f in file_list] | ||
list.sort(file_list, key=lambda x: int(os.path.basename(x).split('.png')[0])) | ||
with open('%simage_list.txt' % out_dir, 'w') as file: | ||
for item in file_list: | ||
file.write("%s\n" % item) | ||
|
||
# Changing directory and using ImageMagik to join all images into a gif. | ||
# Then, delets all unnecessary files.In the end, returns to initial | ||
# directory. | ||
cwd = os.getcwd() | ||
os.chdir(out_dir) | ||
os.system('convert -loop 0 -delay %s @image_list.txt %s.gif' % (layer_delay, out_file)) | ||
os.remove('image_list.txt') | ||
for f in file_list: | ||
os.remove(f) | ||
os.chdir(cwd) | ||
|
||
except: | ||
print('Mayavi not installed, this example cannot run!') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2017, Matheus Boni Vicari, TLSeparation Project | ||
# Copyright (c) 2018-2019, Matheus Boni Vicari, pc2graph | ||
# All rights reserved. | ||
# | ||
# | ||
|
@@ -16,10 +16,10 @@ | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
__author__ = "Matheus Boni Vicari" | ||
__copyright__ = "Copyright 2017" | ||
__copyright__ = "Copyright 2018-2019" | ||
__credits__ = ["Matheus Boni Vicari"] | ||
__license__ = "GPL3" | ||
__version__ = "0.1" | ||
__version__ = "1.0" | ||
__maintainer__ = "Matheus Boni Vicari" | ||
__email__ = "[email protected]" | ||
__status__ = "Development" | ||
|
@@ -31,7 +31,7 @@ | |
if __name__ == "__main__": | ||
|
||
# Loads point cloud into a numpy.ndarray (n_points x dimensions). | ||
point_cloud = np.loadtxt('../data/point_cloud_example.txt') | ||
point_cloud = np.loadtxt('../../data/point_cloud_example.txt') | ||
|
||
# Growth factor. Each point adds 3 new points to graph. | ||
kpairs = 3 | ||
|
@@ -64,4 +64,4 @@ | |
# Preparing output point cloud. | ||
distance = np.asarray(distance).reshape(-1, 1) | ||
out_cloud = np.hstack((nodes, distance)) | ||
np.savetxt('../data/output_point_cloud.txt', out_cloud, fmt='%1.3f') | ||
np.savetxt('../../data/output_point_cloud.txt', out_cloud, fmt='%1.3f') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2017, Matheus Boni Vicari, TLSeparation Project | ||
# Copyright (c) 2018-2019, Matheus Boni Vicari, pc2graph | ||
# All rights reserved. | ||
# | ||
# | ||
|
@@ -16,10 +16,10 @@ | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
__author__ = "Matheus Boni Vicari" | ||
__copyright__ = "Copyright 2017" | ||
__copyright__ = "Copyright 2018-2019" | ||
__credits__ = ["Matheus Boni Vicari"] | ||
__license__ = "GPL3" | ||
__version__ = "0.1" | ||
__version__ = "1.0" | ||
__maintainer__ = "Matheus Boni Vicari" | ||
__email__ = "[email protected]" | ||
__status__ = "Development" | ||
|
Oops, something went wrong.