US-12627881-B2 - Shooting method and electronic device
Abstract
This application provides a shooting method and an electronic device. The method includes: The electronic device enables a camera application; and after detecting a video recording operation, the electronic device displays a preview image on a recording interface and highlights a subject image of a target shot subject, where the preview image and the subject image are obtained through processing based on a raw image, the target shot subject is at a target position on the subject image, and a viewfinder range of the subject image is within a viewfinder range of the preview image. In this way, a user only needs to keep the target shot subject within the viewfinder range of the preview image, so that video recording can be performed without requiring real-time and precise adjustment of a position of the target shot subject.
Inventors
- Ning Wang
- Rongyue XU
- Zhiqi Li
- Zhixiang HAO
- Daiting CHEN
Assignees
- HONOR DEVICE CO., LTD.
Dates
- Publication Date
- 20260512
- Application Date
- 20230419
- Priority Date
- 20220527
Claims (17)
- 1 . A shooting method, applied to an electronic device, wherein the electronic device comprises a camera, the camera is configured to collect a raw image, and the method comprises: enabling a camera application; and detecting a first position information of a target shot subject from a ith frame of the second image, the ith frame of the second image is obtained through processing based on the ith frame of raw image, wherein i is a positive integer greater than 1; mapping the first position information of the target shot subject to the ith frame of first output image, to obtain the second position information of the target shot subject in the ith frame of first output image; the ith frame of first output image is obtained through performing jitter displacement compensation processing on the ith frame of raw image; performing smoothing processing on the second position information of the ith frame of first output image based on second position information of the target shot subject in an (i−1)th frame of first output image, to obtain third position information of the target shot subject; cropping the ith frame of first output image based on the third position information, to obtain the ith frame of subject image corresponding to the target shot subject; after a video recording operation is detected, displaying the ith frame of preview image on a recording interface and highlighting the ith frame of subject image of a target shot subject, wherein the ith frame of preview image is obtained through processing based on the raw image, the target shot subject is at a target position on the ith frame of subject image, and a viewfinder range of the ith frame of subject image is within a viewfinder range of the preview image.
- 2 . The method according to claim 1 , wherein in a moving process of the target shot subject, the target shot subject remains at the target position on the subject image.
- 3 . The method according to claim 1 , wherein in the moving process of the target shot subject, smoothness of a background change of the target shot subject in the subject image is greater than smoothness of a background change of the target shot subject in the preview image.
- 4 . The method according to claim 1 , wherein there is at least one target shot subject, there is at least one subject image, one target shot subject corresponds to one subject image, or one target shot subject corresponds to a plurality of subject images, and the subject image is located outside an area of the preview image or partially overlaps the area of the preview image.
- 5 . The method according to claim 1 , wherein the target shot subject and/or the target position are determined in response to indication operations of a user or are automatically determined by the electronic device, and the method further comprises: detecting an operation of switching a target shot subject, and displaying a subject image corresponding to a switched-to target shot subject on the recording interface; and/or detecting an operation of switching a target position, and displaying, on the recording interface, the subject image corresponding to the target shot subject located at a switched-to target position.
- 6 . The method according to claim 1 , wherein the performing smoothing processing on the second position information of the ith frame of first output image based on second position information of the target shot subject in an (i−1)th frame of first output image, to obtain third position information of the target shot subject comprises: obtaining a first position difference between the second position information of the target shot subject in the (i−1)th frame of first output image and the second position information of the target shot subject in the ith frame of first output image; and determining, based on the first position difference, to perform smoothing processing on the second position information in the ith frame of first output image based on the second position information of the target shot subject in the (i−1)th frame of first output image, to obtain the third position information of the target shot subject, wherein a second position difference between the third position information and the second position information in the (i−1)th frame of first output image is less than or equal to the first position difference.
- 7 . The method according to claim 6 , wherein the way comprises: performing format processing on the ith frame of raw image to obtain an ith frame of first image, wherein the ith frame of first image is the ith frame of preview image; or performing jitter displacement compensation processing on the ith frame of first image to obtain an ith frame of first output image, wherein the ith frame of first output image is the ith frame of preview image.
- 8 . The method according to claim 7 , wherein the performing jitter displacement compensation processing on the ith frame of first image to obtain an ith frame of first output image comprises: obtaining picture jitter displacement information of the ith frame of first image relative to any one or more frames of first images before the ith frame of first image; and performing jitter displacement compensation processing on a picture in the ith frame of first image based on the picture jitter displacement information, to obtain the ith frame of first output image.
- 9 . The method according to claim 8 , wherein the obtaining picture jitter displacement information of the ith frame of first image relative to any one or more frames of first images before the ith frame of first image comprises: detecting a jitter amplitude of the electronic device; and determining the picture jitter displacement information based on the jitter amplitude, wherein the picture jitter displacement information comprises an offset of each pixel in the ith frame of first image relative to a corresponding pixel in the any one or more frames of first images before the ith frame.
- 10 . The method according to claim 7 , wherein the method further comprises: performing downsampling processing on the ith frame of first image to obtain an ith frame of second image.
- 11 . The method according to claim 1 , wherein the cropping of the ith frame of first output image based on the third position information, to obtain the ith frame of subject image corresponding to the target shot subject comprises: determining a minimum bounding rectangular box of the target shot subject based on the third position information; determining a cropping area based on the minimum bounding rectangular box, wherein the cropping area comprises the minimum bounding rectangular box; and obtaining an image corresponding to the cropping area in the ith frame of first output image image, to obtain the ith frame of subject image corresponding to the target shot subject.
- 12 . The method according to claim 11 , wherein after the obtaining an image corresponding to the cropping area in the ith frame of first output image, the method further comprises: zooming out or zooming in the image corresponding to the cropping area, to obtain the ith frame of subject image corresponding to the target shot subject and with a preset display specification, wherein the preset display specification is a preset screen-to-body ratio of the electronic device.
- 13 . The method according to claim 1 , wherein the target position comprises a middle position or a position of a golden section ratio.
- 14 . The method according to claim 1 , wherein the method further comprises: detecting an end recording operation; and generating the video file, wherein the video file comprises the subject image and/or the preview image.
- 15 . The method according to claim 1 , wherein the method further comprises: displaying a shooting preview interface after the camera application is enabled, wherein the shooting preview interface comprises the preview image, or the shooting preview interface comprises the preview image and the subject image.
- 16 . An electronic device, comprising: a camera, configured to collect an image; a screen, configured to display an interface; one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, the one or more computer programs comprise instructions, and when the instructions are executed by the electronic device, the electronic device is enabled to perform the method according to claim 1 .
- 17 . A non-transitory computer-readable storage medium, comprising computer instructions, wherein when the computer instructions are run on an electronic device, the electronic device is enabled to perform the method according to claim 1 .
Description
CROSS-REFERENCE TO RELATED APPLICATIONS This application is a national stage of International Application No. PCT/CN2023/089350, filed on Apr. 19, 2023, which claims priority to Chinese Patent Application No. 202210594819.X, filed on May 27, 2022 and Chinese Patent Application No. 202210871133.0, filed Jul. 22, 2022, all of which are incorporated herein by reference in their entireties. TECHNICAL FIELD This application relates to the field of image processing technologies, and in particular, to a shooting method and an electronic device. BACKGROUND When recording a video or a video log (video log, vlog), a user usually pays more attention to a shot subject, and expects the shot subject is always at an optimal visual position (for example, a center of an image or a position of a golden section ratio). However, when the shot subject moves, a position of the shot subject changes, and an effect expected by the user that the shot subject is always at the optimal visual position cannot be implemented in a recorded video or vlog. Consequently, a presentation effect of the video or vlog is poor, affecting shooting and viewing experience of the user. SUMMARY This application provides a shooting method and an electronic device, to track a shot subject in a video, so that the shot subject is always at a target position such as an optimal visual position, to highlight the shot subject and shot content. According to a first aspect, this application provides a shooting method, and the method may be applied to an electronic device. The electronic device includes a camera, and the camera is configured to collect a raw image. In the method, the electronic device enables a camera application. After detecting a video recording operation, the electronic device displays a preview image on a recording interface and highlights a subject image of a target shot subject, where the preview image and the subject image are obtained through processing based on the raw image, the target shot subject is at a target position on the subject image, and a viewfinder range of the subject image is within a viewfinder range of the preview image. In this application, the electronic device displays both the preview image and the subject image on the recording interface. The preview image is an image with a relatively large viewfinder range that is actually collected by the camera, and therefore, picture content is richer. The viewfinder range of the subject image is within the viewfinder range of the preview image, that is, the subject image is an image with a relatively small viewfinder range. In this case, the subject image displays some picture content in the preview image. In this way, the target shot subject and shot content related to the target shot subject can be highlighted by using the subject image. The subject image may be used to generate a static picture, or may be used to generate a video file. The target shot subject is at an optimal visual position in the static picture. In this case, composition of a shot image is more beautiful, and the target shot subject can be highlighted, presenting an optimal visual display effect. The target shot subject always remains at the target position in the video file. In this way, a user only needs to keep the target shot subject within the viewfinder range of the preview image, so that video recording can be performed without requiring real-time and precise adjustment of a position of the target shot subject. Therefore, a shooting difficulty is reduced, and shooting experience of the user is improved. With reference to the first aspect, in a possible design manner, in a moving process of the target shot subject, the target shot subject remains at the target position on the subject image. In this design manner, the user does not need to perform precise adjustment, and when the target shot subject moves, the target shot subject is always located at the optimal visual position and is highlighted. Therefore, a shooting difficulty is reduced, and shooting experience of the user is improved. With reference to the first aspect, in a possible design manner, in the moving process of the target shot subject, smoothness of a background change of the target shot subject in the subject image is greater than smoothness of a background change of the target shot subject in the preview image. In this design manner, smoothness of a background in the subject image is greater, which means that background transition is smoother. Then, in comparison with the preview image, the background in the subject image other than the target shot subject does not sharply change when there is a sudden change at a center point of the target shot subject due to movement of the target shot subject, in particular, violent movement. In this way, ghosting is not prone to occur on the background, and the background is clearer. In addition, a background change span of adjacent frames of subject images is small, and jumping and flashing in