A facial recognition method, wherein the method is performed by an electronic device, the electronic device comprises an infrared projector, a first camera, and a second camera, and a distance between the first camera and the second camera is a first length; and the method comprises: receiving, by the electronic device, a first instruction of a user, wherein the first instruction is used to trigger the electronic device to perform facial recognition on a first object; in response to the first instruction, emitting, by the electronic device, infrared light with a light spot by using the infrared projector, collecting first image information of the first object by using the first camera, and collecting second image information of the first object by using the second camera, wherein the first image information and the second image information each comprise a feature of the first object and a texture feature formed when the infrared light with the light spot is irradiated onto the first object; calculating, by the electronic device, depth information of the first object based on the first image information, the second image information, the first length, a lens focal length of the first camera, and a lens focal length of the second camera; performing, by the electronic device, user identity verification on the first object by using the first image information and the depth information of the first object, comprising: comparing, by the electronic device, the first image information with an original image, wherein the original image is a two-dimensional image that is stored in the electronic device and that is used to perform the user identity verification; determining, by the electronic device, whether the depth information of the first object has a depth feature of a real face; determining, by the electronic device, whether both the feature and the texture feature in the first image information match a feature of the real face in infrared light; and if the first image information matches the original image, the depth information of the first object has the depth feature of the real face, and both the feature and the texture feature in the first image information match the feature of the real face in infrared light, determining, by the electronic device, that the user identity verification succeeds. receiving, by the electronic device, a first instruction of a user, wherein the first instruction is used to trigger the electronic device to perform facial recognition on a first object; in response to the first instruction, emitting, by the electronic device, infrared light with a light spot by using the infrared projector, collecting first image information of the first object by using the first camera, and collecting second image information of the first object by using the second camera, wherein the first image information and the second image information each comprise a feature of the first object and a texture feature formed when the infrared light with the light spot is irradiated onto the first object; calculating, by the electronic device, depth information of the first object based on the first image information, the second image information, the first length, a lens focal length of the first camera, and a lens focal length of the second camera; performing, by the electronic device, user identity verification on the first object by using the first image information and the depth information of the first object, comprising: comparing, by the electronic device, the first image information with an original image, wherein the original image is a two-dimensional image that is stored in the electronic device and that is used to perform the user identity verification; determining, by the electronic device, whether the depth information of the first object has a depth feature of a real face; determining, by the electronic device, whether both the feature and the texture feature in the first image information match a feature of the real face in infrared light; and if the first image information matches the original image, the depth information of the first object has the depth feature of the real face, and both the feature and the texture feature in the first image information match the feature of the real face in infrared light, determining, by the electronic device, that the user identity verification succeeds. comparing, by the electronic device, the first image information with an original image, wherein the original image is a two-dimensional image that is stored in the electronic device and that is used to perform the user identity verification; determining, by the electronic device, whether the depth information of the first object has a depth feature of a real face; determining, by the electronic device, whether both the feature and the texture feature in the first image information match a feature of the real face in infrared light; and if the first image information matches the original image, the depth information of the first object has the depth feature of the real face, and both the feature and the texture feature in the first image information match the feature of the real face in infrared light, determining, by the electronic device, that the user identity verification succeeds.