1. A computer-implemented method comprising: detecting a facial image in an input image, the input image received by a detection module; calculating a distance between the input image and a reference image, the reference image retrieved from a reference image database and the reference image containing a known facial image for aiding recognizing detected facial images; executing, in response to determining the distance calculated is within a predetermined threshold, a motion aligned distance calculation comprising: identifying a center point for each of the input image and the reference image; splitting the input image and the reference image into blocks based on the center point of the input image and the center point of the reference image, respectively; determining a motion field for aligning the input image with the reference image, the motion field comprising, for a pair of corresponding blocks of the input image and the reference image, at least one vector corresponding to a modification of a portion of the facial image within a first block in the pair of corresponding blocks to shift the portion of the facial image within the first block to align with a corresponding portion of the facial image within a second block in the pair of corresponding blocks; and aligning the input image with the reference image based on the motion field; calculating a motion aligned distance between the input image and the reference image based on the motion field; and providing, in response to the motion aligned distance calculated, a recognition result for the input image.