world2cam = np.linalg.inv(np.matmul(Ry,cam2world)).astype('float32')


	    # the actual rendering process
	    render.render(context, world2cam)

	    # get depth information
	    depth = render.getDepth(info)

	    # get information of mesh rendering
	    # vindices represents 3 vertices related to pixels
	    # vweights represents barycentric weights of the 3 vertices
	    # findices represents the triangle index related to pixels
	    vindices, vweights, findices = render.getVMap(context, info)
	    mask = np.unique(vindices)
	    if len(mask) == 1:
	    	print(file)


	    output_path = os.path.join(os.getcwd(), "data_output_train")
	    if not os.path.exists(output_path):
	        os.makedirs(output_path)

	    out_name = file[:-4] + "_" + str(i_ang)
	    np.savez(os.path.join(output_path, out_name), mask=mask)
	    
	render.Clear()
	gc.collect()

	print(f"time: {time.time() - t}")
예제 #2
0
# the actual rendering process
render.render(context, world2cam)

# get depth information
depth = render.getDepth(info)

# get information of mesh rendering
# vindices represents 3 vertices related to pixels
# vweights represents barycentric weights of the 3 vertices
# findices represents the triangle index related to pixels
vindices, vweights, findices = render.getVMap(context, info)
print(findices.shape)
vis_face = findices.astype('float32') / np.max(findices)
sio.imsave('face.png',vis_face)
sio.imsave('vertex.png',vweights)
'''
#Example: render texture based on the info, loop in python is inefficient, consider move to cpp
uv = np.zeros((findices.shape[0], findices.shape[1], 3), dtype='float32')
for j in range(2):
	uv[:,:,j] = 0
	for k in range(3):
		vind = FT[findices][:,:,k]
		uv_ind = VT[vind][:,:,j]
		uv[:,:,j] += vweights[:,:,k] * uv_ind

mask = np.sum(vweights, axis=2) > 0
mat = face_mat[findices]
diffuse = np.zeros((findices.shape[0],findices.shape[1],3), dtype='uint8')
for i in range(findices.shape[0]):
	for j in range(findices.shape[1]):
		if mask[i,j] == 0: