Camera switching method, device, storage medium and electronic device

By analyzing the focal plane area ratio of camera images to predict the target camera and pre-initializing it, the problem of slow switching speed of multi-camera devices is solved, and more efficient camera switching is achieved.

CN112887602BActive Publication Date: 2024-11-19GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110105787.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-26
Publication Date
2024-11-19
Estimated Expiration
2041-01-26

AI Technical Summary

Technical Problem

In existing technologies, multi-camera devices have a slow camera switching speed when adjusting zoom levels, which cannot meet users' needs for rapid switching.

Method used

By analyzing the image output by the current camera, the focal plane area and its proportion in the image are determined, the target camera to be switched is predicted, and it is initialized before the switching conditions arrive, so as to achieve seamless switching.

Benefits of technology

It improves the efficiency and smoothness of camera switching, reduces switching time, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112887602B_ABST
    Figure CN112887602B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a camera switching method, device, storage medium and electronic device, wherein the embodiment of the present application obtains a first image obtained by shooting a target scene with the current camera; determines the focus area of ​​the first image, and determines the focal plane area of ​​the first image based on the focus area; calculates a first proportion of the focal plane area in the first image; determines a target camera to be switched from multiple cameras based on the first proportion, and initializes the target camera. Based on this scheme, the target camera to be switched is predicted based on the image data output by the current camera, and the target camera is initialized in advance. When the switching conditions are met, the current camera can be directly switched to the target camera, thereby improving the efficiency of camera switching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of electronic equipment, and in particular to a camera switching method, device, storage medium and electronic equipment. Background Art

[0002] With the continuous development of smart terminal technology, the use of electronic devices (such as smart phones, tablet computers, etc.) is becoming more and more popular. Most electronic devices have built-in cameras, and with the enhancement of mobile terminal processing capabilities and the development of camera technology, users have higher and higher requirements for the quality of captured images.

[0003] For example, more and more electronic devices are now equipped with multiple cameras, and these multiple cameras generally support different zoom ratios. At present, the switching solution between multiple cameras generally determines the timing of camera switching and the target camera to be switched based on the user's adjustment of the zoom ratio. This method is to switch the camera when the zoom ratio selected by the user exceeds the zoom range supported by the current camera, but this switching method has a slow switching speed. Summary of the invention

[0004] The embodiments of the present application provide a camera switching method, device, storage medium and electronic device, which can predict the camera to be switched and perform initialization post-processing in advance to increase the camera switching speed.

[0005] In a first aspect, an embodiment of the present application provides a camera switching method, comprising:

[0006] Obtain the first image of the target scene captured by the current camera;

[0007] Determining a focus area of ​​the first image, and determining a focal plane area of ​​the first image according to the focus area;

[0008] Calculating a first ratio of the focal plane area in the first image;

[0009] A target camera to be switched is determined from a plurality of cameras according to the first ratio, and the target camera is initialized.

[0010] In a second aspect, an embodiment of the present application further provides a camera switching device, comprising:

[0011] An image acquisition module is used to acquire a first image obtained by shooting a target scene with a current camera;

[0012] A focal plane determination module, used to determine a focus area of ​​the first image, and determine a focal plane area of ​​the first image according to the focus area;

[0013] a ratio calculation module, used for calculating a first ratio of the focal plane area in the first image;

[0014] A switching control module is used to determine a target camera to be switched from a plurality of cameras according to the first ratio, and initialize the target camera.

[0015] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is run on a computer, the computer executes a camera switching method provided in any embodiment of the present application.

[0016] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising a processor and a memory, wherein the memory has a computer program, and the processor is used to execute a camera switching method provided in any embodiment of the present application by calling the computer program.

[0017] The technical solution provided in the embodiment of the present application determines the focal plane area of ​​the first image output by the current camera, predicts the target camera to be switched based on the first proportion of the focal plane area in the first image, and initializes the target camera in advance. When the switching conditions are met, the current camera can be directly switched to the target camera, thereby improving the efficiency of camera switching. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 A first flow chart of the camera switching method provided in an embodiment of the present application.

[0020] Figure 2 A first schematic diagram of an electronic device provided in an embodiment of the present application.

[0021] Figure 3 A schematic diagram of a first application scenario of the camera switching method provided in an embodiment of the present application.

[0022] Figure 4 A schematic diagram of a second application scenario of the camera switching method provided in an embodiment of the present application.

[0023] Figure 5 Schematic diagram of a method for determining a first distance in a camera switching method provided in an embodiment of the present application.

[0024] Figure 6 Schematic diagram of reference feature points in the camera switching method provided in an embodiment of the present application.

[0025] Figure 7 A schematic diagram of the structure of a camera switching device provided in an embodiment of the present application.

[0026] Figure 8 A first structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0027] Fig. 9 A second structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0029] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0030] The embodiment of the present application provides a camera switching method, and the execution subject of the camera switching method can be a camera switching device provided in the embodiment of the present application, or an electronic device integrated with the camera switching device, wherein the camera switching device can be implemented in hardware or software. The electronic device can be a smart phone, a tablet computer, a PDA, a laptop computer, or a desktop computer.

[0031] See also Figure 1 , Figure 1 This is a schematic diagram of a first process flow of the camera switching method provided in the embodiment of the present application. The specific process flow of the camera switching method provided in the embodiment of the present application may be as follows:

[0032] 101. Obtain a first image obtained by photographing a target scene with a current camera.

[0033] The embodiment of the present application can be used for an electronic device provided with two or more cameras with different focal lengths. In order to facilitate the description of the present solution, the electronic device is taken as an example including three cameras with different focal lengths. Figure 2 , Figure 2 A first schematic diagram of an electronic device provided in an embodiment of the present application. The electronic device is provided with three cameras, namely a wide-angle camera S1, a main camera S2, and a telephoto camera S3. Among them, the focal length of the wide-angle camera S1 is smaller than the focal length of the main camera S2, and the focal length of the main camera S2 is smaller than the focal length of the telephoto camera S3. For example, in one embodiment, the equivalent focal length of the main camera S2 is 26mm, which realizes 1x zoom, and is generally represented as 1X in the shooting interface; the equivalent focal length of the wide-angle camera S1 is 16mm, which can realize 0.6x zoom, and is generally represented as 0.6X in the shooting interface; the equivalent focal length of the telephoto camera S3 is 130mm, which can realize 5x zoom, and is generally represented as 5X in the shooting interface.

[0034] The main camera S2 of most electronic devices such as smartphones is generally a wide-angle lens equivalent to about 28mm. The images captured by the main camera are very close to what the human eye sees, and the images captured by the main camera are relatively "realistic". The wide-angle camera S1 can have a wider field of view than the main camera S2, with a larger viewing range, suitable for taking pictures of scenery and buildings, and can obtain an impactful sense of picture, which can reflect the depth and sense of space of the picture. The telephoto camera S3 can shoot distant objects, can effectively blur the background to highlight the subject, shorten the distance between the foreground and background, and enhance the relationship between the foreground and background.

[0035] The solution of the embodiment of the present application analyzes the image output by the current camera in real time to determine whether the user wants to zoom in or wants a larger field of view, and then determines the target camera to be switched.

[0036] 102. Determine a focus area of ​​the first image, and determine a focal plane area of ​​the first image according to the focus area.

[0037] Assuming that the current camera is the main camera S2, the main camera S2 will expose the shooting scene according to the shooting frame rate and output continuous first images, and these multiple frames of continuous first images constitute an image frame sequence. After obtaining the first image output by the current camera, it is displayed on the preview interface.

[0038] The first image output by the current camera is obtained, and the focus area of ​​the first image is determined. The focus area here refers to the area where the focus frame on the display interface is located when the focus is automatically focused or the user manually focuses. After the focus area is determined, the focal plane area of ​​the first image is determined according to the focus area.

[0039] Exemplarily, in one embodiment, the step of determining the focus area of ​​the first image and determining the focal plane area of ​​the first image based on the focus area includes: determining the focus area of ​​the first image and calculating the depth information of the first image; determining the depth value of the focus area based on the depth information; and determining the area where the pixels having the depth value in the first image are located as the focal plane area of ​​the first image.

[0040] The depth information of the image includes the distance of each pixel from the camera. According to the depth information of the first image, the depth value from the focus area to the camera can be obtained, and the depth value represents the distance from the focal plane to the camera, wherein the focal plane is the plane where the focus area is located and is perpendicular to the main axis of the camera.

[0041] After the depth value from the focus area to the camera is determined, the area where the pixels having the depth value in the first image are located is determined as the focus plane area of ​​the first image.

[0042] In some embodiments, the focus area and an area consisting of pixels connected to the focus area and having depth values ​​are determined as the focus plane area of ​​the first image.

[0043] The area that users usually pay most attention to when taking photos is the focus area, and the focus area is generally located in the center of the first image. Some pixels in the first image that are far away from the focus area may also have the same depth value as the focus area, but the distance between the objects corresponding to these pixels and the objects corresponding to the focus area may be far, for example, they are located at the edge of the image, so even if they have the same depth value as the focus area, they are not the objects that the user pays attention to. Therefore, in this embodiment, when determining the focal plane area, these pixels can be excluded, and only the focus area and the area composed of pixels connected to the focus area and having depth values ​​are determined as the focal plane area of ​​the first image. For example, there is an object A in the shooting scene, and all parts of the object A are almost on the same plane. When focusing, only a part of the area on the object A is focused. Then, after determining the focal plane area in the above manner, the entire area where the object A is located can be determined as the focal plane area, and the object that is far away from the object A and is located on the same plane as the object A will not be determined as the focal plane area.

[0044] Of course, it is understandable that in some other embodiments, all pixel points in the first image having the same depth value as the focus area may be determined as the focus plane area.

[0045] 103. Calculate a first ratio of the focal plane area in the first image.

[0046] When shooting, users may be most concerned about the shooting effect of the focal plane area. When the focus area remains unchanged, since the image resolution remains unchanged, when the framing range is large, the focal plane area occupies a smaller proportion of the entire image and contains fewer pixels. When the framing range gradually decreases, the focal plane area occupies a larger proportion of the entire image and contains more pixels.

[0047] After determining the focal plane area, a first proportion of the focal plane area in the first image is calculated. For example, the first proportion can be calculated by counting pixels, namely, a first number of pixels in the focal plane area and a second number of all pixels in the first image. The ratio of the first number to the second number is the first proportion of the focal plane area in the first image.

[0048] 104. Determine a target camera to be switched from a plurality of cameras according to the first ratio, and initialize the target camera.

[0049] Next, according to the first ratio, it is determined whether the user wants to zoom in or wants a larger viewing range, and then the target camera to be switched is determined. Next, several implementation methods of determining the target camera to be switched according to the first ratio are provided.

[0050] Method 1: when the first ratio is less than a first preset ratio, a first target camera having a focal length greater than that of the current camera is determined from multiple cameras; when the first ratio is greater than a second preset ratio, a second target camera having a focal length less than that of the current camera is determined from multiple cameras, wherein the second preset ratio is greater than the first preset ratio.

[0051] Still taking the current camera as the main camera S2 as an example, if the first ratio is less than the first preset ratio, it can be determined that the focal plane area accounts for too small a proportion. For example, if the first ratio is only 3%, the object in focus may be too far from the camera, and the lens needs to be zoomed in to enlarge the focal plane area. Then the first target camera to be switched is the telephoto camera S3. On the contrary, if the focal plane area accounts for too large a proportion, the framing range needs to be expanded to reduce the focal plane area, and then the second target camera to be switched is the wide-angle camera S1.

[0052] Next, take an actual shooting scene as an example. Figure 3 , Figure 3 Schematic diagram of the first application scenario of the camera switching method provided in the embodiment of the present application. In this shooting scene, the focus area is the face area, and the determined focal plane area may be the area where the entire portrait is located. It can be seen that the focal plane area occupies a very small proportion of the entire preview image. At this time, the telephoto camera S3 can be determined as the first target camera to be switched. Please refer to Figure 4 , Figure 4 A schematic diagram of a second application scenario of the camera switching method provided in an embodiment of the present application. In this shooting scenario, the focal plane area (the area where the portrait is located) accounts for a very large proportion of the entire preview image, and the wide-angle camera S1 can be determined as the second target camera to be switched.

[0053] After determining the target camera to be switched, the target camera is initialized in the background, for example, the target camera is started in the background and system resources are allocated to it. After the initialization is completed, the target camera can shoot the shooting scene and output the image. When the electronic device switches the lens according to the user's instruction, the image shot by the target camera can be directly displayed on the preview interface, realizing seamless switching of the preview interface, and improving the speed and fluency of camera switching. Figure 3 As shown in , after switching from the main camera S2 to the telephoto camera S3, the focal length becomes larger, the field of view becomes smaller, and the focal plane area accounts for a larger proportion in the image. Figure 4 As shown, after switching from the main camera S2 to the wide-angle camera S1, the focal length becomes smaller, the field of view becomes larger, and the proportion of the focal plane area in the image becomes smaller.

[0054] Optionally, in one embodiment, the camera can also be automatically switched according to the size of the first ratio. For example, the step of determining the target camera to be switched from multiple cameras according to the first ratio also includes: when the first ratio is less than the third preset ratio, determining a first target camera with a focal length greater than the current camera from multiple cameras, initializing the first target camera, and switching from the current camera to the first target camera after the initialization is completed, wherein the third preset ratio is less than the first preset ratio; when the first ratio is greater than the fourth preset ratio, determining a second target camera with a focal length less than the current camera from multiple cameras, initializing the second target camera, and switching from the current camera to the second target camera after the initialization is completed, wherein the fourth preset ratio is greater than the second preset ratio.

[0055] In this embodiment, a third preset ratio and a fourth preset ratio are provided, wherein the third preset ratio is smaller than the first preset ratio, and the fourth preset ratio is larger than the second preset ratio.

[0056] After step 103, if the first ratio is less than the third preset ratio, after the initialization of the telephoto camera S3 is completed in the background, the main camera S2 is directly switched to the telephoto camera S3. If the first ratio is greater than the fourth preset ratio, after the initialization of the wide-angle camera S1 is completed in the background, the main camera S2 is directly switched to the wide-angle camera S1. If the first ratio is not less than the third preset ratio and less than the first preset ratio, it is only necessary to initialize the camera without directly switching the camera. If the first ratio is not greater than the fourth preset ratio and greater than the second preset ratio, it is only necessary to initialize the camera without directly switching the camera.

[0057] Method 2, after the step of determining the focal plane area of ​​the first image according to the focus area, further includes: determining a first distance between an edge of the focal plane area and an edge of the first image.

[0058] The step of determining a target camera to be switched from a plurality of cameras according to a first ratio includes: determining a target camera to be switched from a plurality of cameras according to a first ratio and a first distance.

[0059] In this embodiment, in addition to the first ratio of the focal plane area in the first image, another judgment dimension is added: the first distance between the edge of the focal plane area and the edge of the first image. The first ratio and the first distance are combined to comprehensively predict the camera that may be switched.

[0060] Exemplarily, the step of determining a target camera to be switched from multiple cameras based on a first ratio and a first distance includes: calculating a second ratio of the first distance in the corresponding side length; when the first ratio is less than a first preset ratio and the second ratio is greater than a fifth preset ratio, determining a first target camera having a focal length only larger than that of a current camera from multiple cameras; when the first ratio is greater than a second preset ratio and the second ratio is less than a sixth preset ratio, determining a second target camera having a focal length only smaller than that of the current camera from multiple cameras, wherein the sixth preset ratio is less than the fifth preset ratio.

[0061] In this embodiment, the second ratio of the first distance to the corresponding side length is calculated. The focal plane area is regularized, and its shape is determined as a rectangle whose edges are parallel to the edges of the first image. The first distances from the four edges of the focal plane area to the four corresponding edges of the first image are calculated, and then the second ratio of the first distance to the corresponding side length is calculated. Figure 5 As shown, Figure 5Schematic diagram of the first distance determination method in the camera switching method provided in an embodiment of the present application. Assuming that the distance between the left edge of the focal plane area and the left edge of the first image is 400 pixels, and the width of the first image is 1920 pixels, the second ratio is 400 / 1920. In this way, the second ratios in four directions can be calculated.

[0062] If the first ratio is less than the first preset ratio and the second ratio is greater than the fifth preset ratio, a first target camera having a focal length greater than the current camera is determined from the multiple cameras. If the first ratio is greater than the second preset ratio and the second ratio is less than the sixth preset ratio, a second target camera having a focal length less than the current camera is determined from the multiple cameras. In some embodiments, when the second ratios in at least three directions are greater than the fifth preset ratio, it can be determined that the second ratio is greater than the fifth preset ratio.

[0063] Mode three, the step of obtaining a first image obtained by the current camera shooting the target scene includes: obtaining a first image in an image frame sequence obtained by the current camera shooting the target scene.

[0064] After the step of acquiring the first image in the image frame sequence obtained by the current camera shooting the target scene, the method further includes: determining at least two feature points from the first image, and calculating a second distance between the at least two feature points.

[0065] The step of determining a target camera to be switched from multiple cameras according to a first ratio includes: determining the target camera to be switched from multiple cameras according to a first ratio of a first image in an image frame sequence and change information of a second distance.

[0066] In this embodiment, in addition to the first ratio of the focal plane area in the first image, some reference feature points are determined from the first image, and whether the camera will be switched is predicted based on changes in the reference feature points in the first image and the first ratio.

[0067] For the first image in the image frame sequence, at least two reference feature points are determined from it. The reference feature points are selected based on the content features of the entire image. Generally, points whose relative positions do not change during the shooting process are used as feature points. For example, at least two reference feature points are selected from buildings in the shooting scene, or at least two reference points are selected from trees or road edges in the shooting scene. Figure 6 As shown, Figure 6 Schematic diagram of reference feature points in the camera switching method provided in an embodiment of the present application: Select three reference feature points from the trees in the shooting scene.

[0068] After obtaining the reference feature points, a second distance between each two reference feature points of at least two reference feature points is calculated. Then, the first ratio and the change information of the second distance in the image frame sequence are combined to predict whether the target camera needs to be initialized in advance.

[0069] Exemplarily, the step of determining a target camera to be switched from multiple cameras based on the first ratio of the first image in the image frame sequence and the change information of the second distance includes: when the first ratio of the first image in the image frame sequence is less than a seventh preset ratio, the second distance increases and the change amount is greater than a first threshold, determining a first target camera having a focal length greater than the current camera from the multiple cameras; when the first ratio of the first image in the image frame sequence is greater than an eighth preset ratio, the second distance decreases and the change amount is greater than the first threshold, determining a second target camera having a focal length less than the current camera from the multiple cameras, wherein the seventh preset ratio is less than the eighth preset ratio.

[0070] A latest first image in the image frame sequence is acquired, and a first ratio of a focal plane area in the first image is calculated.

[0071] When the current camera is turned on, it will output continuous first images according to the corresponding frame rate and display them on the preview interface. For example, the frame rate of the main camera S2 is 30FPS, and 30 frames of images can be output per second. These continuously output multiple frames of first images constitute an image frame sequence.

[0072] A first image is obtained from the image frame sequence at intervals of 2-5 frames, such as every 3 frames, and a first ratio of the focal plane area of ​​the first image in the first image is calculated, and at least two reference feature points are determined from the first image, and a second distance between the reference feature points is calculated. The second distance change information between the reference feature points in the continuous plurality of first images is obtained, for example, the change information may include a change trend (increase, decrease or remain unchanged) and a change amount. The distance between the reference feature points can be calculated by the number of pixels in the width direction of the image and the number of pixels in the length direction of the image.

[0073] Among them, when the user is taking a photo, if the size of the framing range in the current preview screen is not satisfied, the user can increase or decrease the framing range by zooming in the preview interface, changing the zoom ratio, or moving the electronic device forward and backward. Among them, increasing the zoom ratio, or zooming in the preview interface, or translating the electronic device in the direction away from the shooting scene, can increase the focal length, reduce the framing range, increase the first ratio of the focal plane area, and increase the distance between the reference feature points. Conversely, reducing the zoom ratio, or zooming out the preview interface, or translating the electronic device in the direction close to the shooting scene, can reduce the focal length, increase the framing range, reduce the first ratio of the focal plane area, and reduce the distance between the reference feature points. Based on this principle, in this embodiment, the user's intention is predicted by combining the first ratio and the change information of the second distance. When the first ratio is less than the seventh preset ratio, the second distance increases and the change amount is greater than the first threshold, it is determined that the camera may need to be switched in a short period of time. Assuming that the current camera is the main camera S2, it can be predicted that the camera to be switched is the telephoto camera S3. Now the telephoto camera S3 is initialized in the background, and when the camera needs to be switched, the telephoto camera S3 is directly switched seamlessly to improve the smoothness of the camera switching. Conversely, when the first ratio is greater than the eighth preset ratio, the second distance decreases and the change is greater than the first threshold, the wide-angle camera S1 with a focal length greater than the main camera S2 is used as the second target camera to be switched, and is initialized in the background.

[0074] Optionally, in one embodiment, after the step of initializing the target camera, it also includes: when the first ratio is less than the seventh preset ratio and the change in the second distance is greater than the second threshold, switching from the current camera to the first target camera, wherein the second threshold is greater than the first threshold; when the first ratio is greater than the eighth preset ratio and the change in the second distance is greater than the second threshold, switching from the current camera to the second target camera.

[0075] After completing the initialization of the target camera, continue to detect the changes in the first ratio and the second distance. When it is detected that the first ratio is still smaller than the seventh preset ratio and the change in the second distance is greater than the second threshold, it is determined that the timing for lens switching has arrived, and the main camera S2 is switched to the telephoto camera S3. Since the telephoto camera S3 has been initialized in the background, it can be switched directly, which makes the camera switching smoother.

[0076] It should be noted that in the above embodiment, the electronic device has three cameras, namely, a wide-angle camera S1, a main camera S2 and a telephoto camera S3, and the current camera is the main camera S2. The first preset ratio, the second preset ratio, the third preset ratio, the fourth preset ratio, the fifth preset ratio, the sixth preset ratio, the seventh preset ratio and the eighth preset ratio are all preset preset values. The first preset ratio, the third preset ratio, the fifth preset ratio and the seventh preset ratio are the decision thresholds for initializing the telephoto camera S3 or switching to the telephoto camera S3 when the current camera is the main camera S2, and the second preset ratio, the fourth preset ratio, the sixth preset ratio and the eighth preset ratio are the decision thresholds for initializing the wide-angle camera S1 or switching to the wide-angle camera S1 when the current camera is the main camera S2. If the current camera is the wide-angle camera S1, it is also possible to judge whether it is necessary to initialize the main camera S2 or switch to the main camera S2 based on the corresponding decision threshold according to the same principle as in the above embodiment. If the current camera is the telephoto camera S3, it can also be determined whether it is necessary to initialize the main camera S2 or switch to the main camera S2 based on the corresponding decision threshold according to the same principle as in the above embodiment.

[0077] Of course, if the electronic device is provided with more than three cameras with different focal lengths, the same principle as in the above embodiment can also be used to determine whether the camera needs to be initialized or switched based on the corresponding decision threshold, which will not be described in detail here. It can be understood that if the current camera is the main camera, when it is determined that the focal length needs to be increased, but there are two cameras with a focal length larger than that of the main camera, it can be initialized or switched to the one with a relatively smaller focal length first, and then continue to determine whether it is necessary to continue switching according to the solution in the above embodiment.

[0078] It is understandable that the current camera will continue to expose and output the first image after it is turned on. In some embodiments, the first image outputted in each frame can be acquired in real time to calculate the first ratio. In other embodiments, a frame of image can be acquired every few frames to calculate the first ratio. In addition, the above judgment of whether to initialize a new camera in the background is based on the premise that the focus area remains unchanged. If the focus area changes, the focal plane area is re-determined and the judgment is made.

[0079] In some embodiments, in order to increase the speed of determining the focal plane area, the first image may be downsampled before calculating the depth information to reduce the image size and the amount of calculation.

[0080] In specific implementation, the present application is not limited by the execution order of the various steps described. If no conflict occurs, some steps can be performed in other orders or simultaneously.

[0081] From the above, it can be seen that the camera switching method provided in the embodiment of the present application determines the focal plane area of ​​the first image output by the current camera, predicts the target camera to be switched based on the first proportion of the focal plane area in the first image, and initializes the target camera in advance. When the switching conditions are met, the current camera can be directly switched to the target camera, thereby improving the efficiency of camera switching.

[0082] In some embodiments, the method may further include: when a camera switching operation is detected, determining camera switching information and obtaining a current preview image; calculating a third ratio of the focal plane area of ​​the preview image in the preview image; recording the third ratio and the camera switching information as sample data; and performing fitting processing on multiple sample data to determine a camera switching threshold that matches the camera switching information.

[0083] The decision thresholds involved in the above embodiments may be pre-set fixed values. The decision threshold (camera switching threshold) may also be personalized according to the scheme proposed in this embodiment and user habits. Different users may have different shooting habits. For example, some users do not adjust the proportion of the focal plane area to a large extent when shooting, so the main camera can meet the shooting requirements. However, other users may want the proportion of the focal plane area to be larger when shooting, so the probability of switching from the main camera to the telephoto camera will be relatively high.

[0084] Still taking the electronic device including a wide-angle camera S1, a main camera S2, and a telephoto camera S3 as an example, whenever a camera switching operation is detected, the current camera switching information is recorded. The camera switching operation here mainly refers to the camera switching operation manually triggered by the user, such as switching the camera by triggering a camera selection command through a camera selection control on the shooting interface, or switching the camera by adjusting the zoom factor.

[0085] When a camera switching operation is detected, the camera switching information is determined, for example, the camera switching information is switching from the main camera S2 to the telephoto camera S3. At the same time, the latest frame of the image output by the current camera when the camera switching operation is detected is obtained, that is, the latest frame of the preview image, and the third proportion of the focal plane area in the preview image is calculated, and the above camera switching information and the third proportion are recorded as a sample data, as follows: Sample data 1: [The camera switching information is switching from the main camera S2 to the telephoto camera S3, and the third proportion of the focal plane area in the image]. In other embodiments, the sample data may also include distance change information between reference feature points. Please refer to the above for the acquisition method, which will not be repeated here.

[0086] In this way, a large amount of sample data is collected to obtain multiple third ratios corresponding to switching from the main camera S2 to the wide-angle camera S1, multiple third ratios corresponding to switching from the main camera S2 to the telephoto camera S3, multiple third ratios corresponding to switching from the wide-angle camera S1 to the main camera S2, and so on. The data corresponding to each switching situation are fitted to obtain a suitable ratio value, and the above-mentioned decision thresholds are set according to this value, such as the first preset ratio, the third preset ratio, the fifth preset ratio and the seventh preset ratio.

[0087] In one embodiment, a camera switching device is also provided. Figure 7 , Figure 7 The structure diagram of the camera switching device 300 provided in the embodiment of the present application is as follows: The camera switching device 300 is applied to an electronic device, and the camera switching device 300 includes an image acquisition module 301, a focal plane determination module 302, a ratio calculation module 303 and a switching control module 304, as follows:

[0088] An image acquisition module 301 is used to acquire a first image obtained by shooting a target scene with a current camera;

[0089] A focal plane determination module 302, configured to determine a focus area of ​​the first image, and determine a focal plane area of ​​the first image according to the focus area;

[0090] A ratio calculation module 303, used to calculate a first ratio of the focal plane area in the first image;

[0091] The switching control module 304 is used to determine a target camera to be switched from a plurality of cameras according to the first ratio, and initialize the target camera.

[0092] In some embodiments, the focal plane determination module 302 is also used to: determine the focus area of ​​the first image and calculate the depth information of the first image; determine the depth value of the focus area based on the depth information; and determine the area where the pixels with the depth value in the first image are located as the focal plane area of ​​the first image.

[0093] In some embodiments, the focal plane determining module 302 is further configured to: determine the focus area and an area consisting of pixels connected to the focus area and having the depth value as the focus plane area of ​​the first image.

[0094] In some embodiments, the switching control module 304 is also used to: when the first ratio is less than a first preset ratio, determine a first target camera having a focal length greater than that of the current camera from multiple cameras; when the first ratio is greater than a second preset ratio, determine a second target camera having a focal length less than that of the current camera from the multiple cameras, wherein the second preset ratio is greater than the first preset ratio.

[0095] In some embodiments, the switching control module 304 is also used to: when the first ratio is less than a third preset ratio, determine a first target camera whose focal length is greater than the current camera from multiple cameras, initialize the first target camera, and switch from the current camera to the first target camera after the initialization is completed, wherein the third preset ratio is less than the first preset ratio; when the first ratio is greater than a fourth preset ratio, determine a second target camera whose focal length is less than the current camera from the multiple cameras, initialize the second target camera, and switch from the current camera to the second target camera after the initialization is completed, wherein the fourth preset ratio is greater than the second preset ratio.

[0096] In some embodiments, the focal plane determination module 302 is further used to: determine a first distance between an edge of the focal plane area and an edge of the first image; the switching control module 304 is further used to: determine a target camera to be switched from multiple cameras based on the first ratio and the first distance.

[0097] In some embodiments, the switching control module 304 is also used to: calculate a second ratio of the first distance in the corresponding side length; when the first ratio is less than a first preset ratio and the second ratio is greater than a fifth preset ratio, determine a first target camera from multiple cameras whose focal length is only larger than that of the current camera; when the first ratio is greater than a second preset ratio and the second ratio is less than a sixth preset ratio, determine a second target camera from the multiple cameras whose focal length is only smaller than that of the current camera, wherein the sixth preset ratio is smaller than the fifth preset ratio.

[0098] In some embodiments, the image acquisition module 301 is also used to: acquire the first image in the image frame sequence obtained by the current camera shooting the target scene; the switching control module 304 is also used to: determine at least two feature points from the first image, and calculate the second distance between the at least two feature points; determine the target camera to be switched from multiple cameras based on the first ratio of the first image in the image frame sequence and the change information of the second distance.

[0099] In some embodiments, the switching control module 304 is also used to: when the first ratio of the first image in the image frame sequence is less than a seventh preset ratio, the second distance increases and the change is greater than a first threshold, determine from the multiple cameras a first target camera whose focal length is greater than the current camera; when the first ratio of the first image in the image frame sequence is greater than an eighth preset ratio, the second distance decreases and the change is greater than the first threshold, determine from the multiple cameras a second target camera whose focal length is less than the current camera, wherein the seventh preset ratio is less than the eighth preset ratio.

[0100] In some embodiments, the switching control module 304 is also used to: when the first ratio is less than the seventh preset ratio and the change in the second distance is greater than a second threshold, switch from the current camera to the first target camera, wherein the second threshold is greater than the first threshold; when the first ratio is greater than the eighth preset ratio and the change in the second distance is greater than the second threshold, switch from the current camera to the second target camera.

[0101] In some embodiments, the camera switching device 300 also includes: a threshold setting module, which is used to determine camera switching information and obtain a current preview image when a camera switching operation is detected; calculate a third ratio of the focal plane area of ​​the preview image in the preview image; record the third ratio and the camera switching information as sample data; and perform fitting processing on multiple sample data to determine a camera switching threshold that matches the camera switching information.

[0102] It should be noted that the camera switching device provided in the embodiment of the present application belongs to the same concept as the camera switching method in the above embodiment. Any method provided in the camera switching method embodiment can be implemented through the camera switching device. The specific implementation process is detailed in the camera switching method embodiment, which will not be repeated here.

[0103] From the above, it can be seen that the camera switching device proposed in the embodiment of the present application determines the focal plane area of ​​the first image output by the current camera, predicts the target camera to be switched based on the first proportion of the focal plane area in the first image, and initializes the target camera in advance. When the switching conditions are met, it is possible to directly switch from the current camera to the target camera, thereby improving the efficiency of camera switching.

[0104] The present application also provides an electronic device. The electronic device may be a smart phone, a tablet computer, or other device. Figure 8 , Figure 8The first structural diagram of the electronic device provided in the embodiment of the present application is as follows: The electronic device 400 includes a processor 401 and a memory 402. The processor 401 is electrically connected to the memory 402.

[0105] The processor 401 is the control center of the electronic device 400. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or calling computer programs stored in the memory 402, and calling data stored in the memory 402, thereby monitoring the electronic device as a whole.

[0106] The memory 402 may be used to store computer programs and data. The computer programs stored in the memory 402 include instructions that can be executed in the processor. The computer programs may constitute various functional modules. The processor 401 executes various functional applications and data processing by calling the computer programs stored in the memory 402.

[0107] In this embodiment, the processor 401 in the electronic device 400 loads instructions corresponding to the processes of one or more computer programs into the memory 402 according to the following steps, and the processor 401 runs the computer programs stored in the memory 402 to implement various functions:

[0108] Obtain the first image of the target scene captured by the current camera;

[0109] Determining a focus area of ​​the first image, and determining a focal plane area of ​​the first image according to the focus area;

[0110] Calculating a first ratio of the focal plane area in the first image;

[0111] A target camera to be switched is determined from a plurality of cameras according to the first ratio, and the target camera is initialized.

[0112] In some embodiments, see Fig. 9 , Fig. 9 A second structural diagram of an electronic device provided in an embodiment of the present application. The electronic device 400 further includes: a radio frequency circuit 403, a display screen 404, a control circuit 405, an input unit 406, an audio circuit 407, a sensor 408, and a power supply 409. The processor 401 is electrically connected to the radio frequency circuit 403, the display screen 404, the control circuit 405, the input unit 406, the audio circuit 407, the sensor 408, and the power supply 409, respectively.

[0113] The radio frequency circuit 403 is used to send and receive radio frequency signals to communicate with network devices or other electronic devices through wireless communication.

[0114] The display screen 404 may be used to display information input by a user or information provided to a user and various graphical user interfaces of the electronic device. These graphical user interfaces may be composed of images, texts, icons, videos and any combination thereof.

[0115] The control circuit 405 is electrically connected to the display screen 404 and is used to control the display screen 404 to display information.

[0116] The input unit 406 can be used to receive input numbers, character information or user feature information (such as fingerprints), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. The input unit 406 can include a fingerprint recognition module.

[0117] The audio circuit 407 can provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 407 includes a microphone. The microphone is electrically connected to the processor 401. The microphone is used to receive voice information input by the user.

[0118] The sensor 408 is used to collect external environment information. The sensor 408 may include one or more sensors such as an environment brightness sensor, an acceleration sensor, and a gyroscope.

[0119] The power supply 409 is used to supply power to various components of the electronic device 400. In some embodiments, the power supply 409 may be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, power consumption, and other functions.

[0120] Although not shown in the figure, the electronic device 400 may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0121] In this embodiment, the processor 401 in the electronic device 400 loads instructions corresponding to the processes of one or more computer programs into the memory 402 according to the following steps, and the processor 401 runs the computer programs stored in the memory 402 to implement various functions:

[0122] Obtain the first image of the target scene captured by the current camera;

[0123] Determining a focus area of ​​the first image, and determining a focal plane area of ​​the first image according to the focus area;

[0124] Calculating a first ratio of the focal plane area in the first image;

[0125] A target camera to be switched is determined from a plurality of cameras according to the first ratio, and the target camera is initialized.

[0126] From the above, it can be seen that an embodiment of the present application provides an electronic device, which determines the focal plane area of ​​the first image output by the current camera, predicts the target camera to be switched based on the first proportion of the focal plane area in the first image, and initializes the target camera in advance. When the switching conditions are met, the current camera can be directly switched to the target camera, thereby improving the efficiency of camera switching.

[0127] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program runs on a computer, the computer executes the camera switching method described in any of the above embodiments.

[0128] It should be noted that, those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer-readable storage medium can include but is not limited to: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0129] In addition, the terms "first", "second", and "third" in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or modules is not limited to the listed steps or modules, but some embodiments also include steps or modules that are not listed, or some embodiments also include other steps or modules inherent to these processes, methods, products, or devices.

[0130] The camera switching method, device, storage medium and electronic device provided in the embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application; at the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A camera switching method, characterized in that: include: Obtain the first image of the target scene captured by the current camera; Determining a focus area of ​​the first image and calculating depth information of the first image; Determining a depth value of the focus area according to the depth information; determining the focus area and an area consisting of pixels connected to the focus area and having the depth value as a focal plane area of ​​the first image; determining a first distance between an edge of the focal plane area and an edge of a first image; Calculating a first ratio of the focal plane area in the first image; Determine a target camera to be switched from a plurality of cameras according to the first ratio and the first distance, wherein a second ratio of the first distance in the corresponding side length is calculated; when the first ratio is less than a first preset ratio and the second ratio is greater than a fifth preset ratio, determine a first target camera whose focal length is only greater than that of the current camera from a plurality of cameras; when the first ratio is greater than a second preset ratio and the second ratio is less than a sixth preset ratio, determine a second target camera whose focal length is only less than that of the current camera from the plurality of cameras, wherein the sixth preset ratio is less than the fifth preset ratio; Alternatively, the acquiring of the first image obtained by photographing the target scene by the current camera includes acquiring a first image in an image frame sequence obtained by photographing the target scene by the current camera, determining at least two feature points from the first image, and calculating a second distance between the at least two feature points, and determining a target camera to be switched from a plurality of cameras according to the first ratio of the first image in the image frame sequence and change information of the second distance; Initialize the target camera.

2. The camera switching method according to claim 1, characterized in that: The step of determining a target camera to be switched from a plurality of cameras according to the first ratio includes: When the first ratio is less than a first preset ratio, determining a first target camera having a focal length greater than that of the current camera from a plurality of cameras; When the first ratio is greater than a second preset ratio, a second target camera having a smaller focal length than the current camera is determined from the multiple cameras, wherein the second preset ratio is greater than the first preset ratio.

3. The camera switching method according to claim 2, characterized in that: The step of determining a target camera to be switched from a plurality of cameras according to the first ratio also includes: When the first ratio is smaller than a third preset ratio, determining a first target camera having a focal length larger than that of the current camera from a plurality of cameras, initializing the first target camera, and switching from the current camera to the first target camera after the initialization is completed, wherein the third preset ratio is smaller than the first preset ratio; When the first ratio is greater than a fourth preset ratio, a second target camera having a focal length smaller than that of the current camera is determined from the multiple cameras, the second target camera is initialized, and after the initialization is completed, the current camera is switched to the second target camera, wherein the fourth preset ratio is greater than the second preset ratio.

4. The camera switching method according to claim 1, wherein: The step of determining a target camera to be switched from a plurality of cameras according to the first ratio of the first image in the image frame sequence and the change information of the second distance includes: When the first ratio of the first image in the image frame sequence is less than a seventh preset ratio and the second distance increases and the change amount is greater than a first threshold, determining a first target camera having a focal length greater than the current camera from the multiple cameras; When the first ratio of the first image in the image frame sequence is greater than the eighth preset ratio, the second distance decreases and the change is greater than the first threshold, a second target camera having a focal length smaller than the current camera is determined from the multiple cameras, wherein the seventh preset ratio is smaller than the eighth preset ratio.

5. The camera switching method according to claim 4, characterized in that: After the step of initializing the target camera, the method further includes: When the first ratio is less than a seventh preset ratio and the change in the second distance is greater than a second threshold, switching from the current camera to the first target camera, wherein the second threshold is greater than the first threshold; When the first ratio is greater than an eighth preset ratio and the change in the second distance is greater than the second threshold, the current camera is switched to the second target camera.

6. The camera switching method according to claim 2, wherein: Also includes: When a camera switching operation is detected, the camera switching information is determined and the current preview image is obtained; Calculating a third ratio of the focal plane area of ​​the preview image in the preview image; Recording the third ratio and the camera switching information as sample data; Fitting processing is performed on the plurality of sample data to determine a camera switching threshold that matches the camera switching information.

7. A camera switching device, characterized in that: include: An image acquisition module, used to acquire a first image obtained by the current camera shooting a target scene, or used to acquire a first image in an image frame sequence obtained by the current camera shooting a target scene; A focal plane determination module, used to determine a focus area of ​​the first image and calculate depth information of the first image; Determine a depth value of the focus area according to the depth information; Determine the focus area and an area consisting of pixels connected to the focus area and having the depth value as a focus plane area of ​​the first image, and determine a first distance between an edge of the focus plane area and an edge of the first image; a ratio calculation module, used for calculating a first ratio of the focal plane area in the first image; used to calculate a second ratio of the first distance in the corresponding side length, or used to determine at least two feature points from the first image and calculate a second distance between the at least two feature points; A switching control module, used to determine a target camera to be switched from a plurality of cameras according to the first ratio and the first distance; when the first ratio is less than a first preset ratio and the second ratio is greater than a fifth preset ratio, determine a first target camera whose focal length is only greater than that of the current camera from the plurality of cameras; when the first ratio is greater than a second preset ratio and the second ratio is less than a sixth preset ratio, determine a second target camera whose focal length is only less than that of the current camera from the plurality of cameras, wherein the sixth preset ratio is less than the fifth preset ratio; or used to determine a target camera to be switched from a plurality of cameras according to the first ratio of the first image in the image frame sequence and change information of the second distance, and initialize the target camera.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program runs on a computer, the computer is enabled to execute the camera switching method according to any one of claims 1 to 6.

9. An electronic device comprising a processor and a memory, wherein the memory stores a computer program, characterized in that: The processor is used to execute the camera switching method as described in any one of claims 1 to 6 by calling the computer program.