import wrap

# 1. Loading Basemesh
print "Loading basemesh..."
basemeshFileName = wrap.openFileDialog("Select Basemesh",
                                       filter="OBJ-file (*.obj)",
                                       dir=wrap.demoModelsPath)
basemesh = wrap.Geom(basemeshFileName)
print "OK"

# 2. Loading Scan
print "Loading scan..."
scanFileName = wrap.openFileDialog("Select Scan",
                                   filter="OBJ-file (*.obj)",
                                   dir=wrap.demoModelsPath)
scaleFactor = 1000
scan = wrap.Geom(scanFileName, scaleFactor=scaleFactor)
scan.wireframe = False
print "OK"

print "Loading texture..."
textureFileName = wrap.openFileDialog("Select Scan\'s Texture",
                                      filter="Image (*.jpg *.png *.bmp *.tga)",
                                      dir=wrap.demoModelsPath)
if textureFileName is not None:
    scan.texture = wrap.Image(textureFileName)
    scan.texture.show()
    print "OK"
else:
    print "No texture set"
Esempio n. 2
0
import wrap
import sys, os
import datetime

sys.path.append(os.getcwd())
import ParseConfig
reload(ParseConfig)

print "Select config file"
configFile = wrap.openFileDialog("Select config file",
                                 filter="Text Files (*.txt)")
print "Config file is '%s'" % configFile

tasks = ParseConfig.parseConfig(configFile, 'DefaultSettings_2_Wrapping.txt')

tasksCount = len(tasks)
for taskNum, task in enumerate(tasks):

    print "Task %d of %d" % (taskNum + 1, tasksCount)
    print "Loading scan '%s'..." % task['scanFileName']
    scan = wrap.Geom(task['scanFileName'], fitToView=False)
    scan.wireframe = False
    scaleFactor = 100.0 / scan.boundingBoxSize[0]
    scan.scale(scaleFactor)
    wrap.fitToView()
    print "OK"

    if 'textureFileName' in task:
        print "Loading texture '%s'" % task['textureFileName']
        scan.texture = wrap.Image(task['textureFileName'])
        print "OK"
import wrap
import sys,os

sys.path.append(os.getcwd())
import ParseConfig; reload(ParseConfig)

print "Select config file"
configFile = wrap.openFileDialog("Select config file",filter="Text Files (*.txt)")
print "Config file is '%s'" %  configFile

tasks = ParseConfig.parseConfig(configFile, "DefaultSettings_3_PostProcessing.txt")

for taskNum, task in enumerate(tasks):

    if 'wrapped' in locals(): del wrapped
    if 'scan' in locals(): del scan

    print "Task %d of %d" % (taskNum + 1, len(tasks))
    print "Loading scan '%s'..." % task['scanFileName']
    scan = wrap.Geom(task['scanFileName'], fitToView = False)
    scan.wireframe = False
    scaleFactor = 100.0 / scan.boundingBoxSize[0]
    scan.scale(scaleFactor)
    wrap.fitToView()
    print "OK"

    if 'textureFileName' in task:
        print "Loading texture '%s'" % task['textureFileName']
        scan.texture = wrap.Image(task['textureFileName'])
        print "OK"
    else:
import wrap
import os


path = wrap.openFileDialog()
target_scan_dir = os.path.dirname(path) + "/"
print 'choosed dir - ' + target_scan_dir

#target_scan_dir = 'd:/Cthulhu/3d_scanning/Leha_phomens/neutral_uni_nonrigid_generate/'
neutral_name = 'neutral_uni'

def get_file_path(name, mesh_list, type = 'obj'):  
    for mesh_name in mesh_list:  
        if name + '.' + type in mesh_name:  
            print 'got ' + name + '.' + type  
            return mesh_name  
 
def generate_points_name(name, target_scan_dir, prefix='_nonrigid'):  
    file_name = target_scan_dir + name + prefix + '.points'
    return file_name

def get_rigid_aligned_name(file_path, type = 'obj'):  
    file_path_list = file_path.split('.obj')
    aligned_path = file_path_list[0] + '_aligned.obj'  
    return aligned_path  
  
def get_scan_names(scan_files_list, neutral = True):  
    scan_names_list = []  
    split_names_list = []  
    for path in scan_files_list:
        if '.obj' in path:
Esempio n. 5
0
        tmpDirectory, wrappedResultsDirectory, postprocResultsDirectory
]:
    if not os.path.exists(directory):
        #print "Creating directory '%s'" % directory
        os.makedirs(directory)

print "Select scans..."
scanFileNames = wrap.openFilesDialog("Select scans", filter="Files (*.obj)")
if not scanFileNames:
    raise ValueError("Scan filename list cannot be empty")

for scanFileName in scanFileNames:
    print "\t", scanFileName

print "Select basemesh..."
basemeshFileName = wrap.openFileDialog("Select basemesh",
                                       filter="Files (*.obj)")
if not basemeshFileName:
    raise ValueError("Basemesh filename cannot be empty")

print "\t", basemeshFileName

# Generating config
pairs = []
for scanFileName in scanFileNames:
    pairs.append(subprocess.list2cmdline([scanFileName, basemeshFileName]))

configFileName = os.path.join(outputDirectory, "Config_Scans_Basemeshes.txt")
with open(configFileName, "wb") as file:
    file.write(os.linesep.join(pairs))

# Generating args to skip stages if thy set to False
for directory in [tmpDirectory,wrappedResultsDirectory,postprocResultsDirectory]:
    if not os.path.exists(directory):
        #print "Creating directory '%s'" % directory
        os.makedirs(directory)


print "Select scans..."
scanFileNames = wrap.openFilesDialog("Select scans",filter="Files (*.obj)")
if not scanFileNames:
    raise ValueError("Scan filename list cannot be empty")

for scanFileName in scanFileNames:
    print "\t", scanFileName

print "Select basemesh..."
basemeshFileName = wrap.openFileDialog("Select basemesh",filter="Files (*.obj)")
if not basemeshFileName:
    raise ValueError("Basemesh filename cannot be empty")

print "\t", basemeshFileName

# Generating config
pairs = []
for scanFileName in scanFileNames:
    pairs.append(subprocess.list2cmdline([scanFileName,basemeshFileName]))

configFileName = os.path.join(outputDirectory,"Config_Scans_Basemeshes.txt")
with open(configFileName,"wb") as file:
    file.write(os.linesep.join(pairs))

import wrap

# 1. Loading Basemesh
print "Loading basemesh..."
basemeshFileName = wrap.openFileDialog("Select Basemesh",filter = "OBJ-file (*.obj)",dir = wrap.demoModelsPath)
basemesh = wrap.Geom(basemeshFileName)
print "OK"

# 2. Loading Scan
print "Loading scan..."
scanFileName = wrap.openFileDialog("Select Scan",filter = "OBJ-file (*.obj)",dir = wrap.demoModelsPath)
scaleFactor = 1000
scan = wrap.Geom(scanFileName,scaleFactor = scaleFactor)
scan.wireframe = False
print "OK"

print "Loading texture..."
textureFileName = wrap.openFileDialog("Select Scan\'s Texture",filter = "Image (*.jpg *.png *.bmp *.tga)",dir = wrap.demoModelsPath)
if textureFileName is not None:
    scan.texture = wrap.Image(textureFileName)
    scan.texture.show()
    print "OK"
else:
    print "No texture set"

print "Quick navigation: \n\tZoom: Scroll OR Alt + Right Click\n\tRotate: Alt + Left Click\n\tTranslate:Alt + Scroll Click"

# 3. Rigid Alignment: pick three points on the face to align the models
print "Rigid alignment... pick three points to match up on the models' faces"
(pointsScan, pointsBasemesh) = wrap.selectPoints(scan,basemesh)
rigidTransformation = wrap.rigidAlignment(basemesh,pointsBasemesh,scan,pointsScan,matchScale = True)