Commit be4ae8da authored by Richard Torenvliet's avatar Richard Torenvliet

Fixed the code that generated the texture PCA model

parent 31abc3e9
...@@ -195,6 +195,10 @@ def build_texture_feature_vectors(files, get_image_with_points, MeanPoints, tria ...@@ -195,6 +195,10 @@ def build_texture_feature_vectors(files, get_image_with_points, MeanPoints, tria
list: list of feature vectors list: list of feature vectors
""" """
mean_texture = [] mean_texture = []
image, points = get_image_with_points(files[0])
MeanPoints.get_scaled_points(image.shape)
x, y, w_slice, h_slice = MeanPoints.get_bounding_box() x, y, w_slice, h_slice = MeanPoints.get_bounding_box()
for i, f in enumerate(files): for i, f in enumerate(files):
...@@ -211,7 +215,7 @@ def build_texture_feature_vectors(files, get_image_with_points, MeanPoints, tria ...@@ -211,7 +215,7 @@ def build_texture_feature_vectors(files, get_image_with_points, MeanPoints, tria
sample_from_triangles( sample_from_triangles(
image, image,
Points.get_scaled_points(image.shape), Points.get_scaled_points(image.shape),
MeanPoints(image.shape), MeanPoints.get_scaled_points(image.shape),
triangles, triangles,
dst dst
) )
......
...@@ -96,21 +96,32 @@ def save_pca_model_texture(args): ...@@ -96,21 +96,32 @@ def save_pca_model_texture(args):
assert args.model_shape_file, '--model_texture_file needs to be provided to save the pca model' assert args.model_shape_file, '--model_texture_file needs to be provided to save the pca model'
assert args.model_texture_file, '--model_texture_file needs to be provided to save the pca model' assert args.model_texture_file, '--model_texture_file needs to be provided to save the pca model'
Vt, s, n_components, mean_shape, triangles = pca.load(args.model_shape_file) shape_model = pca.PcaModel(args.model_shape_file)
MeanPoints = aam.AAMPoints( mean_points = imm.IMMPoints(points_list=shape_model.mean_values)
normalized_flattened_points_list=mean_value_points,
actual_shape=(58, 2) #reconstruction.reconstruct_texture(
) # input_image, # src image
# input_image, # dst image
# texture_model,
# input_points, # shape points input
# mean_points, # shape points mean
#)
# old
#Vt, s, n_components, mean_shape, triangles = pca.load(args.model_shape_file)
textures = aam.build_texture_feature_vectors( textures = aam.build_texture_feature_vectors(
args.files, imm.get_imm_image_with_landmarks, MeanPoints, triangles args.files,
imm.get_imm_image_with_landmarks,
mean_points,
shape_model.triangles
) )
mean_texture = aam.get_mean(textures) mean_texture = aam.get_mean(textures)
_, s, Vt, n_components = pca.pca(textures, mean_texture) _, s, Vt, n_components = pca.pca(textures, mean_texture)
pca.save(Vt, s, n_components, mean_texture, triangles, args.model_texture_file) pca.save(Vt, s, n_components, mean_texture, shape_model.triangles, args.model_texture_file)
logger.info('texture pca model saved in %s', args.model_texture_file) logger.info('texture pca model saved in %s', args.model_texture_file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment