AAM Module

class aam.AAMPoints(normalized_flattened_points_list=None, points_list=None, actual_shape=())[source]

Object to store AAM points / landmarks. Tries to keep the scaling of these points transparent.

calculate_bounding_box()[source]

Calculate bounding box in the scaled points list The empasis on on scaled because the convexHull does not support small values, the normalized_flattened_points_list does not work.

Use get_scaled_points first, with a shape that is needed. The shape should be the dimensions of the out image, example (480, 640), ie., (height, width)

get_bounding_box()[source]

Get the bounding box around the points.

Returns:
OpenCV rectangle:
x, y, w, h
get_scaled_points(width_height_dimensions, rescale=False)[source]

Scale the normalized flattened points list to a scale given by ‘shape’. The x and y values should be scaled to the width and height of the image.

Args:
shape(tuple): (height, width) rescal(boolean): flag if we should rescale or not because if we already scaled, we are not going to do it again by default.
Returns:
ndarray scaled to ‘shape’ width and height.
aam.build_shape_feature_vectors(files, get_points, flattened=False)[source]

Gets the aam points from the files and appends them seperately to one array.

Args:
files (list): list files get_points(function): function that gets the points/landmarks given a list of files.
Returns:
list. List of feature vectors
aam.build_texture_feature_vectors(files, get_image_with_points, mean_points, triangles)[source]
Args:
files (list): list files get_image_with_points (function): That can return the image together with the location. mean_points(AAMPoints): AAMPoints object
Returns:
list: list of feature vectors
aam.get_mean(vector)[source]

Construct a mean from a matrix of x,y values

Args:
points(numpy array) that follows the following structure:
Returns:
mean_values (numpy array)
Example:
Input observations:
  1. [[x_0_0, y_0_0], ... , [x_0_m, y_0_m]],

  2. [[x_1_0, y_1_0], ... , [x_1_m, y_1_m]],

  3. [[x_2_0, y_2_0], ... , [x_2_m, y_2_m]],

  4. [[x_3_0, y_3_0], ... , [x_3_m, y_3_m]]

    .... .... .....

  1. [[x_4_0, y_4_0], ... , [x_n_m, y_n_m]]
This vector containts the mean values of the corresponding column, like so:
  1. [[x_0_0, y_0_0], ... , [x_0_k, y_0_k]],

  2. [[x_1_0, y_1_0], ... , [x_1_k, y_1_k]],

  3. [[x_2_0, y_2_0], ... , [x_2_k, y_2_k]],

  4. [[x_3_0, y_3_0], ... , [x_3_k, y_3_k]]

    .... .... .....

  1. [[x_4_0, y_4_0], ... , [x_n_k, y_n_k]]

mean. [[x_mean_0, y_mean_0], ... [x_mean_n, y_mean_n]]

aam.get_pixel_values(image, points)[source]

deprecated

aam.get_triangles(x_vector, y_vector)[source]

Perform triangulation between two 2d vectors

Args:
x_vector(ndarray): list of x locations y_vector(ndarray): list of y locations
aam.sample_from_triangles(src, points2d_src, points2d_dst, triangles, dst)[source]

Get pixels from within the triangles [[p1, p2, p3]_0, .. [p1, p2, p3]_n].

Args:

src(ndarray, dtype=uint8): input image

points2d_src(ndarray, dtype=np.int32): shape array [[x, y], ... [x, y]]

points2d_dst(ndarray, dtype=np.int32): shape array [[x, y], ... [x, y]]

triangles(ndarray, ndim=3, dtype=np.int32): shape array [[p1, p2, p3]_0, .. [p1, p2, p3]_n].