This project was developed under a previous phase of the Yale Digital Humanities Lab. Now a part of Yale Library’s Computational Methods and Data department, the Lab no longer includes this project in its scope of work. As such, it will receive no further updates.
Extract fixed-size vertex data from .obj and .jpg files
pip install vertices
To extract 3D vertices from an .obj file:
from vertices import ObjParser
# parse an object file
obj = ObjParser('bunny.obj')
# get the default vertices in the loaded obj file
verts = obj.vertices
# get a specified number of vertices from the obj file
verts = obj.get_n_vertices(10000)
This process will recursively subdivide faces until the desired number of vertices are accumulated.
The returned object will be a numpy array with shape (10000, 3).
To extract 2D vertices from a .jpg file:
from vertices import ImgParser
# parse an input image file
img = ImgParser('dylan.jpg')
# get the default number of vertices identified in the image file
verts = img.vertices
# get a specified number of vertices from the jpg file
verts = img.get_n_vertices(10000)
The returned object will be a numpy array with shape (10000, 2).