I’m trying to figure out (using the simpleWrap example) how to load a set of control points for the baseMesh from a file and then manually set the corresponding points for a scan. My goal is to wrap the same hand pose base mesh to several differently posed hand scans.
I made a little script to set and save the base mesh points, and I can load them in, but I don’t know how to have it show me the split window so I have the visual reference to place the scan points.
Here’s my hacked script so far (no, I’m not much of a coder at all
). I’ve commented out the sections I don’t need at the moment.
Thanks for any help!
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"
# 3. Rigid Alignment
print "Rigid alignment..."
(pointsScan, pointsBasemesh) = wrap.selectPoints(scan,basemesh)
rigidTransformation = wrap.rigidAlignment(basemesh,pointsBasemesh,scan,pointsScan,matchScale = True)
basemesh.transform(rigidTransformation)
basemesh.fitToView()
print "OK"
# 4. Non-rigid Registration
# print "Non-rigid Registration..."
# (controlPointsScan,controlPointsBasemesh) = wrap.selectPoints(scan,basemesh)
# freePolygonsBasemesh = wrap.selectPolygons(basemesh)
# basemesh = wrap.nonRigidRegistration(basemesh,scan,controlPointsBasemesh,controlPointsScan,freePolygonsBasemesh,minNodes = 15,initialRadiusMultiplier = 1.0,smoothnessFinal = 0.1,maxIterations = 20)
# print "OK"
# 4a. Load base control points from file - ja
print "Load base control points from file..."
fileName = wrap.openFileDialog("Open base control points file", filter = "TXT-file (*.txt)")
(controlPointsBasemesh) = wrap.loadPoints(fileName)
# 4b. Non-rigid Registration - ja
print "Non-rigid Registration..."
(controlPointsScan) = wrap.selectPoints(scan)
freePolygonsBasemesh = wrap.selectPolygons(basemesh)
basemesh = wrap.nonRigidRegistration(basemesh,scan,controlPointsBasemesh,controlPointsScan,freePolygonsBasemesh,minNodes = 15,initialRadiusMultiplier = 1.0,smoothnessFinal = 0.1,maxIterations = 20)
print "OK"
# 5. Subdivision
# print "Subdivision..."
# basemesh = wrap.subdivide(basemesh)
# print "OK"
# 6. Projection
print "Projection..."
disabledPolygons = wrap.selectPolygons(basemesh)
basemesh = wrap.projectMesh(basemesh,scan,maxRelativeDist = 1,disabledPolygonIndicesSrc = disabledPolygons)
print "OK"
# 7. Texture Transfer
# print "Texture transfer..."
# if scan.texture is not None:
# basemesh.texture = wrap.transferTexture(scan,scan.texture,basemesh,(2048,2048),maxRelativeDist = 3)
# basemesh.texture.extrapolate()
# print "OK"
# 8. Saving Result
print "Saving result..."
fileName = wrap.saveFileDialog("Save resulting model",filter = "OBJ-file (*.obj)")
basemesh.save(fileName,scaleFactor = 1.0 / scaleFactor)
if scan.texture is not None:
textureFileName = wrap.saveFileDialog("Save resulting texture",filter = "Image (*.jpg *.png *.bmp *.tga)")
basemesh.texture.save(textureFileName)
print "OK"