import numpy as np import menpo from menpo.transform.piecewiseaffine.base import PythonPWA, CachedPWA, CythonPWA b = menpo.io.import_builtin_asset('breakingbad.jpg') b.crop_to_landmarks_proportion_inplace(0.1) b.constrain_mask_to_landmarks() points = b.mask.true_indices src = b.landmarks['PTS'][None] tgt = src.copy() python_pwa = PythonPWA(src, tgt) cached_pwa = CachedPWA(src, tgt) cython_pwa = CythonPWA(src, tgt) %matplotlib inline b.view() %time x = python_pwa.apply(points) %time x = cached_pwa.apply(points) %time x = cython_pwa.apply(points) %timeit python_pwa.apply(points) %timeit cached_pwa.apply(points) %timeit cython_pwa.apply(points) np.all(cython_pwa.apply(points) == cached_pwa.apply(points)) np.all(python_pwa.apply(points) == cached_pwa.apply(points))