Exemplo n.º 1
0
 def ds_from_subsampling(Dataset,
                         n,
                         subsamplingmethod='FPS',
                         seed=empty([0, 0])):
     meshes = Dataset.meshes
     subsampled_meshes = []
     if (subsamplingmethod == 'GPL'):
         for i in meshes:
             subsampled_meshes.append(Subsample.gpl_subsample(
                 mesh, n, seed))
     elif (subsamplingmethod == 'FPS'):
         for i in meshes:
             subsampled_meshes.append(
                 Subsample.far_point_subsample(mesh, n, seed))
     else:
         msg = 'The subsampling method needs to be either GPL or FPS.'
         raise OSError(msg)
     mesheslist.append(subsampled_meshes)
     return (DatasetCollection(datasets=mesheslist))
Exemplo n.º 2
0
 def subsample(Auto3dgmData, list_of_pts, meshes):
     from auto3dgm_nazar.mesh.subsample import Subsample
     ss = Subsample(pointNumber=list_of_pts,
                    meshes=meshes,
                    seed={},
                    center_scale=True)
     for point in list_of_pts:
         names = []
         meshes = []
         for key in ss.ret[point]['output']['output']:
             mesh = ss.ret[point]['output']['output'][key]
             meshes.append(mesh)
         dataset = {}
         dataset[point] = meshes
         Auto3dgmData.datasetCollection.add_dataset(dataset, point)
     return (Auto3dgmData)
Exemplo n.º 3
0
 def subsample(Auto3dgmData, list_of_pts, meshes):
     print(list_of_pts)
     for mesh in meshes:
         print(len(mesh.vertices))
     ss = Subsample(pointNumber=list_of_pts,
                    meshes=meshes,
                    seed={},
                    center_scale=True)
     for point in list_of_pts:
         names = []
         meshes = []
         for key in ss.ret[point]['output']['output']:
             mesh = ss.ret[point]['output']['output'][key]
             meshes.append(mesh)
         dataset = {}
         dataset[point] = meshes
         Auto3dgmData.datasetCollection.add_dataset(dataset, point)
     return (Auto3dgmData)
Exemplo n.º 4
0
    def start(self):
        ### INITIAL STEPS ###

        # check parameters look good before proceeding
        self.validate_parameters()

        self.__write_output_dirs()

        ### DATA LOAD AND SUBSAMPLE
        #TODO: No ftype param
        self.dataset = DatasetFactory.ds_from_dir(self.mesh_dir, ftype='ply')

        # need to get both sets of subsample results
        ss_points = [self.ss_points_i, self.ss_points_f]
        #TODO: Should use named parameters as the constructor for Subsample, I'm not sure what ss_type refers to.
        #TODO: init doesn't return anything, so I've encoded the results dictionary in subsample_res.ret
        subsample_res = Subsample(
            self.dataset['mesh'], ss_points, self.ss_type
        )  # dataset class should eventually support multiple named mesh sets and should be dict-style callable like this for mesh TODO: Currently does not support multiple named mesh sets, and the param is dataset.meshes
        ss_meshes_i = subsample_res[ss_points[0]]['output'][
            'results']  #TODO: Results isnt a list of meshes, its a dict
        ss_meshes_f = subsample_res[ss_points[1]]['output']['results']

        #TODO: Add mesh set doesnt exist as a method. Self.dataset isnt a dataset, its a data set collection, maybe create a method to instantiate a new data set, and add it to the Dataset COllection? THis naming is kind of bad
        self.dataset.add_mesh_set(self.ss_label_i, ss_meshes_i)
        self.dataset.add_mesh_set(self.ss_label_f, ss_meshes_f)

        ### INITIAL SUBSAMPLE POINTS ANALYSIS ###
        ss_i_correspondence_res = Correspondence(  # Correspondence should take an initial alignment object with d, p, and r arrays; also correspondence should handle bundling pairwise results into a single data structure
            meshes=self.dataset[self.ss_label_i],
            initial_alignment=None,
            globalize=True,
            mirror=self.allow_reflection)
        # Correspondence data structure should be an object with the following attributes: local_align with d, p, and r arrays, mst with minimum spanning tree, and global_align with d, p, and r arrays

        self.dataset.add_analysis_set(self.ss_label_i, ss_i_correspondence_res)

        ### FINAL SUBSAMPLE POINTS ANALYSIS ###
        ss_f_correspondence_res = Correspondence(  # Correspondence should take an initial alignment object with d, p, and r arrays; also correspondence should handle bundling pairwise results into a single data structure
            meshes=self.dataset[self.ss_label_f],
            initial_alignment=self.dataset.analysis_set[
                self.ss_label_i].global_align,
            globalize=True,
            mirror=self.allow_reflection)
Exemplo n.º 5
0
from auto3dgm_nazar.mesh.subsample import Subsample
from auto3dgm_nazar.analysis.correspondence import Correspondence
import os

cwd=os.getcwd()
mesh_dir = cwd+"/input/"

# Create a DatasetCollection with meshes from a sample directory 
dc = DatasetFactory.ds_from_dir(dir_path=mesh_dir, center_scale=True)
print(dc)
print(dc.datasets)
print(dc.analysis_sets) # Why is the initial dataset copied as an analysis_set?

# Generate two sets of subsamples with 100 and 200 points each
subsample_points = [100, 200]
subsample_results = Subsample(dc.datasets[0], subsample_points, 'FPS') # this absolutely does not work

# Add these results as additional datasets to our DatasetCollection
dc.add_dataset(subsample_results[100]['output']['results'], 'ss100')
dc.add_dataset(subsample_results[200]['output']['results'], 'ss200')

# Generate Correspondence results for first (100) subsample points dataset
# Correspondence data structure should be an object with the following attributes: local_align with d, p, and r arrays, mst with minimum spanning tree, and global_align with d, p, and r arrays
ss_100_correspondence_res = Correspondence( 
	meshes=dc.datasets['ss100'],
	initial_alignment=None, 
	globalize=True,
	mirror=True)
dc.add_analysis_set(ss_100_correspondence_res, 'ss100')

# Generate Correspondence results for second (200) subsample points dataset
Exemplo n.º 6
0
from auto3dgm_nazar.mesh.meshfactory import MeshFactory
from auto3dgm_nazar.mesh.subsample import Subsample
from numpy import array

vertices = array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [2, 2, 1]])
seed = vertices[[1, 4]]

mesh = MeshFactory.mesh_from_data(vertices)

submesh_noseed = Subsample.far_point_subsample(mesh, 4)
print(submesh_noseed)
print(submesh_noseed.vertices)
print(submesh_noseed.faces)

submesh_seed = Subsample.far_point_subsample(mesh, 4, seed)
print(submesh_seed)
print(submesh_seed.vertices)
print(submesh_seed.faces)
"""

Print results for first set will be random, but second set will be stable

Print results should look something like this:
<auto3dgm.mesh.mesh.Mesh object at 0x117cd5518>
[[0 0 0]
 [2 2 1]
 [1 1 0]
 [1 0 0]]
[]
<auto3dgm.mesh.mesh.Mesh object at 0x10f5e31d0>
[[1 0 0]