US-12627900-B2 - Method for switching cameras and electronic device
Abstract
This application relates to the field of terminals, and provides a method for switching cameras and an electronic device. The method is applicable to an electronic device, the electronic device includes a camera module, the camera module includes a first camera and a second camera, and the method includes: running a camera application in the electronic device; displaying a first image; determining whether a first distance and a second distance meet a first preset condition, where the first distance and the second distance indicate an object distance between the electronic device and a to-be-photographed object, the first distance is an object distance that is obtained based on a parameter of the first camera, and the second distance is an object distance that is obtained based on a parameter of the second camera; and displaying a second image when the first distance and the second distance meet the first preset condition.
Inventors
- Chunlin Tian
- Wenbo Wang
- Yonghua Wang
- Shiyu Zhu
- Dongmiao Xi
- Congchao Zhu
Assignees
- HONOR DEVICE CO., LTD.
Dates
- Publication Date
- 20260512
- Application Date
- 20230811
- Priority Date
- 20221024
Claims (20)
- 1 . A method for switching cameras, applicable to an electronic device, wherein the electronic device comprises a camera module, the camera module comprises a first camera and a second camera, and the method comprises: starting a camera application in the electronic device; displaying a first image, wherein the first image is an image collected by the first camera; obtaining a first distance based on a parameter of the first camera, and obtaining a second distance based on a parameter of the second camera, wherein the first distance and the second distance indicate an object distance between the electronic device and a to-be-photographed object; and displaying a second image when the first distance is greater than a first preset threshold, and the second distance is greater than a second preset threshold, wherein the second image is an image collected by the second camera; the first preset threshold is different from the second preset threshold; the first preset threshold is a threshold obtained based on a focus parameter of the first camera; the second preset threshold is a threshold obtained based on a focus parameter of the second camera; the focus parameter of the first camera is a focus distance range [X1, X2], and the first preset threshold is greater than or equal to X1; and the focus parameter of the second camera is a focus distance range [X3, X4], and the second preset threshold is greater than or equal to X3.
- 2 . The method according to claim 1 , further comprising: determining whether a brightness parameter of a photographing scene in which the electronic device is located is less than or equal to a first brightness threshold when the first distance is less than or equal to the first preset threshold, and/or the second distance is less than or equal to the second preset threshold; and displaying the second image when the brightness parameter is less than or equal to the first brightness threshold, wherein the first brightness threshold is a preset threshold obtained based on a first brightness range, and the first brightness range is used to represent an effective brightness range in which the first camera performs focusing.
- 3 . The method according to claim 2 , wherein a zoom ratio corresponding to a case that the electronic device displays the first image is a first zoom ratio, a current zoom ratio of the electronic device is a second zoom ratio, and the method further comprises: determining whether the second zoom ratio is the same as the first zoom ratio when the brightness parameter is greater than the first brightness threshold; and displaying the second image when the second zoom ratio is different from the first zoom ratio.
- 4 . The method according to claim 1 , wherein the displaying a first image comprises: displaying the first image when a brightness parameter of a photographing environment in which the electronic device is located is greater than a second brightness threshold, and the second distance is less than or equal to a third preset threshold.
- 5 . The method according to claim 4 , wherein the second brightness threshold is a preset threshold that is obtained based on a second brightness range, and the second brightness range is used to represent an effective brightness range in which the second camera performs focusing.
- 6 . The method according to claim 1 , wherein when the first camera comprises an open loop motor, the method further comprises: obtaining the parameter of the first camera; performing compensation processing on the parameter of the first camera based on a calibration value of the first camera, to obtain a processed parameter; and obtaining the first distance based on the processed parameter.
- 7 . The method according to claim 1 , wherein the displaying a first image comprises: displaying the first image when the electronic device is in a super macro mode.
- 8 . The method according to claim 7 , wherein the displaying the first image when the electronic device is in a super macro mode comprises: displaying the first image on a first display interface of the electronic device, wherein the first display interface further comprises a first icon, and the first icon indicates the super macro mode.
- 9 . The method according to claim 8 , wherein the first icon comprises a first control, and the method further comprises: detecting a first operation on the first control; and exiting, by the electronic device, the super macro mode in response to the first operation.
- 10 . The method according to claim 7 , wherein the displaying a second image comprises: displaying the second image when the electronic device exits the super macro mode.
- 11 . The method according to claim 1 , wherein the first camera comprises an ultra wide-angle camera, and the second camera comprises a wide-angle camera; or the first camera comprises a wide-angle camera, and the second camera comprises a telephoto camera.
- 12 . The method according to claim 1 , wherein the electronic device is at a same position when the electronic device displays the first image and the second image.
- 13 . The method according to claim 1 , wherein the first image comprises a first to-be-photographed object, the second image comprises a second to-be-photographed object, the first to-be-photographed object and the second to-be-photographed object are at a same position, a distance between the first to-be-photographed object and the electronic device is a third distance, a distance between the second to-be-photographed object and the electronic device is a fourth distance, and the third distance is less than the fourth distance.
- 14 . The method according to claim 1 , wherein the first image and the second image comprise a third to-be-photographed object, and the third to-be-photographed object is at a same position when the first image and the second image are displayed; a distance between the third to-be-photographed object and the electronic device is a fifth distance when the first image is collected; and a distance between the third to-be-photographed object and the electronic device is a sixth distance when the second image is collected, and the fifth distance is less than the sixth distance.
- 15 . An electronic device, comprising: one or more processors and a memory, wherein the memory is coupled to the one or more processors, the memory is configured to store computer program code, the computer program code comprises computer instructions, and the one or more processors invoke the computer instructions to enable the electronic device to: start a camera application in the electronic device; display a first image, wherein the first image is an image collected by a first camera; obtain a first distance based on a parameter of the first camera, and obtaining a second distance based on a parameter of a second camera, wherein the first distance and the second distance indicate an object distance between the electronic device and a to-be-photographed object; and display a second image when the first distance is greater than a first preset threshold, and the second distance is greater than a second preset threshold, wherein the second image is an image collected by the second camera; the first preset threshold is different from the second preset threshold; the first preset threshold is a threshold obtained based on a focus parameter of the first camera; the second preset threshold is a threshold obtained based on a focus parameter of the second camera; the focus parameter of the first camera is a focus distance range [X1, X2], and the first preset threshold is greater than or equal to X1; and the focus parameter of the second camera is a focus distance range [X3, X4], and the second preset threshold is greater than or equal to X3.
- 16 . The electronic device according to claim 15 , wherein the processors are configured to invoke computer instructions to enable the electronic device further to: determine whether a brightness parameter of a photographing scene in which the electronic device is located is less than or equal to a first brightness threshold when the first distance is less than or equal to the first preset threshold, and/or the second distance is less than or equal to the second preset threshold; and display the second image when the brightness parameter is less than or equal to the first brightness threshold, wherein the first brightness threshold is a preset threshold obtained based on a first brightness range, and the first brightness range is used to represent an effective brightness range in which the first camera performs focusing.
- 17 . The electronic device according to claim 16 , wherein a zoom ratio corresponding to a case that the electronic device displays the first image is a first zoom ratio, a current zoom ratio of the electronic device is a second zoom ratio, and wherein the processors are configured to invoke computer instructions to enable the electronic device further to: determine whether the second zoom ratio is the same as the first zoom ratio when the brightness parameter is greater than the first brightness threshold; and display the second image when the second zoom ratio is different from the first zoom ratio.
- 18 . A chip system, wherein the chip system is applicable to an electronic device, and the chip system comprises one or more processors, wherein the processors are configured to invoke computer instructions to enable the electronic device to: start a camera application in the electronic device; display a first image, wherein the first image is an image collected by a first camera; obtain a first distance based on a parameter of the first camera, and obtaining a second distance based on a parameter of a second camera, wherein the first distance and the second distance indicate an object distance between the electronic device and a to-be-photographed object; and display a second image when the first distance is greater than a first preset threshold, and the second distance is greater than a second preset threshold, wherein the second image is an image collected by the second camera; the first preset threshold is different from the second preset threshold; the first preset threshold is a threshold obtained based on a focus parameter of the first camera; the second preset threshold is a threshold obtained based on a focus parameter of the second camera; the focus parameter of the first camera is a focus distance range [X1, X2], and the first preset threshold is greater than or equal to X1; and the focus parameter of the second camera is a focus distance range [X3, X4], and the second preset threshold is greater than or equal to X3.
- 19 . The chip system according to claim 18 , wherein the processors are configured to invoke computer instructions to enable the electronic device further to: determine whether a brightness parameter of a photographing scene in which the electronic device is located is less than or equal to a first brightness threshold when the first distance is less than or equal to the first preset threshold, and/or the second distance is less than or equal to the second preset threshold; and display the second image when the brightness parameter is less than or equal to the first brightness threshold, wherein the first brightness threshold is a preset threshold obtained based on a first brightness range, and the first brightness range is used to represent an effective brightness range in which the first camera performs focusing.
- 20 . The chip system according to claim 19 , wherein a zoom ratio corresponding to a case that the electronic device displays the first image is a first zoom ratio, a current zoom ratio of the electronic device is a second zoom ratio, and wherein the processors are configured to invoke computer instructions to enable the electronic device further to: determine whether the second zoom ratio is the same as the first zoom ratio when the brightness parameter is greater than the first brightness threshold; and display the second image when the second zoom ratio is different from the first zoom ratio.
Description
CROSS-REFERECNE TO RELATED APPLICATIONS This application is a national stage of International Application No. PCT/CN2023/112634, filed on Aug. 11, 2023, which claims priority to Chinese Patent Application No. 202211303569.6, filed on Oct. 24, 2022. The disclosures of both of the aforementioned applications are hereby incorporated by reference in their entireties. TECHNICAL FIELD This application relates to the field of terminals, and specifically, to a method for switching cameras and an electronic device. BACKGROUND When shooting, an electronic device often faces the need to automatically switch cameras to collect a clear image; for example, when shooting distant scenery, the electronic device may switch to a telephoto camera; and when shooting close-up scenery, the electronic device may switch to an ultra wide-angle camera. When the electronic device does not include a laser sensor, the electronic device may automatically switch between different cameras based on a parameter of a wide-angle camera; for example, when identifying, based on the parameter of the wide-angle camera, that a distance between the electronic device and a to-be-photographed object is less, the electronic device may automatically switch to the ultra wide-angle camera and use the ultra wide-angle camera as a main camera, to enter a super macro mode; but when the distance between the electronic device and the to-be-photographed object is less, the distance between the electronic device and the to-be-photographed object is less than an effective distance for the wide-angle camera that performs focusing. As a result, accuracy of the parameter of the wide-angle camera is reduced, causing a problem that the electronic device may automatically exits when shooting in the super macro mode, and resulting in poor stability of the super macro mode. Therefore, how to improve stability of a photographing mode (for example, the super macro mode or a super long shot mode) in the electronic device has become an urgent problem that needs to be resolved. SUMMARY This application provides a method for switching cameras and an electronic device, to improve stability of a photographing mode (for example, a super macro mode) in the electronic device and improve shooting experience of a user. According to a first aspect, a method for switching cameras is provided, applicable to an electronic device, where the electronic device includes a camera module, the camera module includes a first camera and a second camera, and the method includes: running a camera application in the electronic device;displaying a first image, where the first image is obtained by collecting an image by using the first camera as a main camera;determining whether a first distance and a second distance meet a first preset condition, where the first distance and the second distance indicate an object distance between the electronic device and a to-be-photographed object, the first distance is an object distance that is obtained based on a parameter of the first camera, and the second distance is an object distance that is obtained based on a parameter of the second camera; anddisplaying a second image when the first distance and the second distance meet the first preset condition, where the second image is obtained by collecting an image by using the second camera as the main camera. In embodiments of this application, the second image is displayed when the first distance and the second distance meet the first preset condition, where the electronic device switches to the second camera and uses the second camera as the main camera; because the first distance is the object distance that is obtained based on the parameter of the first camera, the second distance is the object distance that is obtained based on the parameter of the second camera; therefore, in embodiments of this application, when it is determined whether to switch to the second camera and use the second camera as the main camera, it is determined whether to switch cameras based on a double-restriction condition; and compared with an existing solution, which determines whether to switch cameras based only on the parameter of the second camera, the method for switching cameras provided in embodiments of this application is more accurate, to be specific, stability of a photographing mode in the electronic device is better. With reference to the first aspect, in some implementations of the first aspect, the first distance and the second distance meet the first preset condition, including: determining that the first distance is greater than a first preset threshold, and the second distance is greater than a second preset threshold, where the first preset threshold is different from the second preset threshold. With reference to the first aspect, in some implementations of the first aspect, the first preset threshold is a preset threshold that is obtained based on a first distance range, and the first distance range is used to re