This application discloses a
fingerprint recognition method and an electronic device, and relates to the terminal field. The method includes: obtaining, by an electronic device,
fingerprint images in response to a press operation performed by a user on a
fingerprint collection region of the electronic device, and determining image types of the fingerprint images, where the image types include a first type of images, and the first type of images are fingerprint images including a pattern of a
foreign matter; and marking the first type of images when it is determined that the fingerprint images include the first type of images, and updating a first type of marked images to a fingerprint
template library of the electronic device. In this solution, when determining that the fingerprint images are the first type of images including the pattern of the
foreign matter, the electronic device marks the first type of images before being stored into the fingerprint
library, thereby increasing a capability of recognizing the fingerprint images in which the pattern of the
foreign matter exists, where the marking is to clear the pattern of the foreign matter. The pattern of the foreign matter in the first type of images stored into the fingerprint
library does not affect matching of fingerprint templates, thereby increasing a
fingerprint recognition rate of the electronic device.