Here, wsize is the total size of the normalized training image, which is the sum of the patch size and the search region size. As just mentioned, that the top-left (2 x 2) block of the similarity transform from the reference shape to the annotated shape pt, which corresponds to the scale and rotation component of the transformation, is preserved in the affine transform passed to OpenCV's warpAffine function. The last column of the affine transform A is an adjustment that will render the i'th facial feature location centered in the normalized image after warping (that is, the normalizing translation). Finally, the cv::warpAffine function has the default setting of warping from the image to the reference frame. Since the similarity transform was computed for transforming the reference shape to the image-space annotations pt, the WARP_INVERSE_MAP flag needs to be set to ensure the function applies the warp in the desired direction. Exactly the same procedure is performed in the patch_models::calc_peaks function, with the additional step that the computed similarity transform between the reference and the current shape in the image-frame is re-used to un-normalize the detected facial features, placing them appropriately in the image: