I am currently doing the following (all via bpy in Python):
- Load a triangle mesh in Blender, and convert it to quads. The mesh is a flat object (like a bent piece of pape).
- Add a texture to the mesh.
- Adjust the camera to a fixed position looking center straight down on the mesh.
- Render the image.
- Export the quad mesh to an .obj file.
So now I have the quad mesh in an obj file and a rendered 2D image. I would like to find the alignment / mapping of each vertex in the mesh to its location on the 2D image, via bpy if possible.
Thanks!
Update: I got this to work:
Here is the image shown, with a scatter plot of the 2d coordinates lain on top: 
Here is the render code:
bpy.data.scenes['Scene'].render.resolution_x = 448
bpy.data.scenes['Scene'].render.resolution_y = 448
bpy.data.scenes['Scene'].render.resolution_percentage = 100
render_scale = scene.render.resolution_percentage / 100
render_size = (
int(scene.render.resolution_x * render_scale),
int(scene.render.resolution_y * render_scale),
)
verts = list((mesh.matrix_world @ vert.co for vert in mesh.data.vertices))
coords_2d = [world_to_camera_view(scene, camera, coord).to_tuple()[:2] for coord in verts]
adjusted_coords_2d = [(render_size[0] * (u), render_size[1] * (1 - v)) for u, v in coords_2d]
pk.dump(adjusted_coords_2d, open(inds_output_path, 'wb'))
Here is the display code:
image = plt.imread(img_path)
inds = pk.load(open(inds_path, 'rb'))
inds_a = np.array(inds)
plt.figure()
plt.imshow(image)
plt.scatter(inds_a[:, 0], inds_a[:, 1])
plt.show()

