1. A computer-implemented method comprising: detecting a facial image in an input image; calculating a distance between the input image and a reference image, 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 aligning the input image with the reference image, splitting the input image and the reference image into blocks based on the center point, determining a motion field for aligning the input image with the reference image, the motion field comprising, for a pair of corresponding blocks between the input image and the reference image, a vector corresponding to a modification of a portion of the facial image within a first block in the pair of corresponding blocks to align a first block with the 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 a reference image based on the motion field; and providing, in response to the motion aligned distance calculated, a recognition result for the input image.