示例#1
0
# from assist import marker

frontal_pic_name = '00029ba010_960521'
profile_pic_name = '00029pr010_940128'
frontal_img = cv2.imread(os.path.join(r'..\data', frontal_pic_name + '.tif'))
profile_img = cv2.imread(os.path.join(r'..\data', profile_pic_name + '.tif'))
width = np.shape(frontal_img)[1]
height = np.shape(frontal_img)[0]
# marker.frontal_face_marker(os.path.join(r'..\data', frontal_pic_name + '.tif'))

# s = 2
s = 2000 / height if height >= width else 2000 / width
scale_param = 900 / height if height >= width else 900 / width
# scale_param = 1

morphable_model = MorphableModel.load_model(
    r"..\py_share\py_sfm_shape_3448.bin")
blendshapes = Blendshape.load_blendshapes(
    r"..\py_share\py_expression_blendshapes_3448.bin")
landmark_mapper = LandmarkMapper.LandmarkMapper(r'..\py_share\ibug_to_sfm.txt')
edge_topology = EdgeTopology.load_edge_topology(
    r'..\py_share\py_sfm_3448_edge_topology.json')
contour_landmarks = contour_correspondence.ContourLandmarks()
contour_landmarks.load(r'..\py_share\ibug_to_sfm.txt')
model_contour = contour_correspondence.ModelContour()
model_contour.load(r'..\py_share\sfm_model_contours.json')
profile_landmark_mapper = LandmarkMapper.ProfileLandmarkMapper(
    r'..\py_share\profile_to_sfm.txt')

frontal_landmarks = []
landmark_ids = list(map(str, range(
    1, 69)))  # generates the numbers 1 to 68, as strings
示例#2
0
shape_orthonormal_pca_basis = shape_model.get_orthonormal_pca_basis()
shape_eigenvalues = shape_model.get_eigenvalues()
shape_triangle_list = shape_model.get_triangle_list()
py_shape_model = PcaModel.PcaModel(shape_mean, shape_orthonormal_pca_basis,
                                   shape_eigenvalues, shape_triangle_list)

color_mean = color_model.get_mean()
color_orthonormal_pca_basis = color_model.get_orthonormal_pca_basis()
color_eigenvalues = color_model.get_eigenvalues()
color_triangle_list = color_model.get_triangle_list()
py_color_model = PcaModel.PcaModel(color_mean, color_orthonormal_pca_basis,
                                   color_eigenvalues, color_triangle_list)

py_texture_coordinates = model.get_texture_coordinates()

py_model = MorphableModel.MorphableModel(py_shape_model, py_color_model,
                                         py_texture_coordinates)

MorphableModel.save_model(py_model, 'py_share/py_sfm_shape_3448.bin')

py_blendshapes = []
for blendshape in blendshapes:
    py_blendshape = Blendshape.Blendshape(blendshape.name,
                                          blendshape.deformation)
    py_blendshapes.append(py_blendshape)

o = open('py_share/py_expression_blendshapes_3448.bin', 'wb', -1)
pickle.dump(py_blendshapes, o)
o.close()

# 转换share/sfm_3448_edge_topology.json文件
file = open('share/sfm_3448_edge_topology.json', 'r')