|
26 | 26 | # Their basis is unit norm: np.linalg.norm(shape_pca_basis[:,0]) == 1.0 |
27 | 27 | # And the basis vectors are orthogonal: np.dot(shape_pca_basis[:,0], shape_pca_basis[:,0]) == 1.0 |
28 | 28 | # np.dot(shape_pca_basis[:,0], shape_pca_basis[:,1]) == 1e-08 |
29 | | -shape_pca_standard_deviations = bfm2009['shapeEV'] # These are standard deviations, not eigenvalues! |
| 29 | +shape_pca_standard_deviations = bfm2009['shapeEV'] # These are standard deviations, not eigenvalues! |
30 | 30 | shape_pca_eigenvalues = np.square(shape_pca_standard_deviations) |
31 | | -triangle_list = bfm2009['tl'] - 1 # Convert from 1-based Matlab indexing to 0-based C++ indexing |
| 31 | +triangle_list = bfm2009['tl'] - 1 # Convert from 1-based Matlab indexing to 0-based C++ indexing |
32 | 32 | # The BFM has front-facing triangles defined the wrong way round (not in accordance with OpenGL) - we swap the indices: |
33 | 33 | for t in triangle_list: |
34 | 34 | t[1], t[2] = t[2], t[1] |
35 | | -shape_model = eos.morphablemodel.PcaModel(shape_mean, shape_orthogonal_pca_basis, shape_pca_eigenvalues, triangle_list.tolist()) |
| 35 | +shape_model = eos.morphablemodel.PcaModel(shape_mean, shape_orthogonal_pca_basis, shape_pca_eigenvalues, |
| 36 | + triangle_list.tolist()) |
36 | 37 |
|
37 | 38 | # PCA colour model: |
38 | 39 | color_mean = bfm2009['texMU'] |
39 | 40 | # The BFM2009's colour data is in the range [0, 255], while the SFM is in [0, 1], so we divide by 255: |
40 | 41 | color_mean /= 255 |
41 | 42 | color_orthogonal_pca_basis = bfm2009['texPC'] |
42 | | -color_pca_standard_deviations = bfm2009['texEV'] # Again, these are standard deviations, not eigenvalues |
43 | | -color_pca_standard_deviations /= 255 # Divide the standard deviations by the same amount as the mean |
| 43 | +color_pca_standard_deviations = bfm2009['texEV'] # Again, these are standard deviations, not eigenvalues |
| 44 | +color_pca_standard_deviations /= 255 # Divide the standard deviations by the same amount as the mean |
44 | 45 | color_pca_eigenvalues = np.square(color_pca_standard_deviations) |
45 | 46 |
|
46 | | -color_model = eos.morphablemodel.PcaModel(color_mean, color_orthogonal_pca_basis, color_pca_eigenvalues, triangle_list.tolist()) |
| 47 | +color_model = eos.morphablemodel.PcaModel(color_mean, color_orthogonal_pca_basis, color_pca_eigenvalues, |
| 48 | + triangle_list.tolist()) |
47 | 49 |
|
48 | 50 | # Construct and save the BFM2009 model in the eos format: |
49 | 51 | model = eos.morphablemodel.MorphableModel(shape_model, color_model, vertex_definitions=None, |
|
0 commit comments