A photographing method, wherein the method is applied to an electronic device, and the method comprises:
- obtaining N frames of images in response to a first operation, wherein the first operation is an operation performed on a photographing control, the N frames of images are N frames of images in a preview picture that are collected by using a camera, and N is a positive integer;
- and
- determining a target image as an output raw image in a process of sequentially obtaining jitter amounts of each frame of the N frames of images, wherein the output raw image is an image obtained by the electronic device by using a sensor of the camera, and the target image is an image that meets a jitter amount requirement and that is determined from the N frames of images based on the jitter amounts, wherein the determining the target image as the output raw image comprises:
- extracting a first image from the N frames of images;
- obtaining a jitter amount of the first image;
- based on the jitter amount of the first image being less than or equal to a preset threshold, determining the first image as the target image;
- based on the jitter amount of the first image being greater than the preset threshold, extracting a next frame of the N frames of images as a new first image, and performing the step of obtaining the jitter amount of the new first image;
- and
- based on the jitter amounts of each frame the N frames of images being greater than the preset threshold, determining an image with a minimum jitter amount in the N frames of images as the target image;
- wherein the obtaining the jitter amount of the first image comprises:
- obtaining gyro data of M lines in the first image, wherein M is a positive integer, and M is less than or equal to a quantity of pixel lines of the first image;
- and
- determining the jitter amount of the first image based on the gyro data of the M lines;
- and
- wherein the obtaining the gyro data of the M lines in the first image comprises:
- obtaining exposure time information of the M lines in the first image, wherein the exposure time information comprises start moments and end moments of exposure of the M lines;
- obtaining timestamp information and corresponding gyro data, wherein the timestamp information is information about time of collecting the corresponding gyro data;
- and
- based on the timestamp information being in exposure time information of a corresponding line in the M lines, obtaining gyro data in the exposure time information of the corresponding line.