Focusing method, focusing device, electronic device, storage medium, and program product
By detecting and adjusting the focus area and exposure parameters in face shooting scenarios, the problem of misjudgment caused by the high focus priority of the region of interest on the face is solved, thereby improving the focus accuracy and image quality of the object.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING XIAOMI MOBILE SOFTWARE CO LTD
- Filing Date
- 2025-01-08
- Publication Date
- 2026-07-10
AI Technical Summary
In face shooting scenarios, the focusing priority of the region of interest on the face is higher than that of the center area, which leads to misjudgment by the focusing module and affects the imaging effect of other objects.
When a focus event of the first object is detected, a second object in the preview screen is detected. If the second object is partially located in the first area, a focus operation is performed on the first object. At the same time, the exposure parameters of the second object are kept unchanged, and the first area is adjusted according to its position information to reduce misjudgment.
By adjusting the focus area and exposure parameters, the misjudgment of the focus module was reduced, thereby improving the focus accuracy and image quality of the first object.
Smart Images

Figure CN122372835A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of camera technology, and more particularly to a focusing method, focusing device, electronic device, storage medium, and program product. Background Technology
[0002] With technological breakthroughs in science and industry, cameras have been widely used in various fields. The accuracy of autofocus (AF) is one of the indicators of the quality of a camera's imaging system. Currently, the main autofocus methods include Contrast Detection Auto Focus (CDAF), Phase Detection Auto Focus (PDAF), Time-of-Flight Assisted Focus (TOF), and Dual Camera Instant Auto Focus (DCIAF) for dual cameras. Face capture scenarios typically employ one or more of these focusing methods as the focusing mechanism for electronic devices.
[0003] In face shooting scenarios, since the focus priority of the Region of Interest (ROI) is higher than that of the center ROI, when a face ROI appears, the focus is prioritized on the face ROI based on the above focusing method, while other ROIs are not focused on. This results in poor image quality for objects located in other ROIs. Summary of the Invention
[0004] To overcome the problems in the related technologies, this disclosure provides a focusing method, focusing device, electronic device, storage medium, and program product, thereby reducing the situation where the focusing module misjudges due to the higher focusing priority of the second object located at the edge of the reference area, and improving the focusing accuracy for the first object, thereby ensuring the imaging quality of the first object.
[0005] According to a first aspect of the present disclosure, a focusing method is provided, comprising:
[0006] If a focus event is detected on a first object within a first region of the preview screen, a second object in the preview screen is detected; wherein the first region is smaller than a reference region, the reference region is determined based on the field of view of the image acquisition module of the electronic device, and the focus priority of the second object is higher than that of the first object.
[0007] If the second object is present in the preview screen and a portion of the second object is located in the first area, a focus operation is performed on the first object.
[0008] In some embodiments, the method further includes:
[0009] While performing the focusing operation on the first object, the current exposure parameters of the second object are kept unchanged.
[0010] In some embodiments, the method further includes:
[0011] The first region is adjusted based on the position information of the second object in the preview screen to obtain the adjusted first region; wherein the adjusted first region is smaller than the original first region.
[0012] Detect focus events for the first object within the adjusted first region.
[0013] In some embodiments, adjusting the first region based on the position information of the second object in the preview screen to obtain the adjusted first region includes:
[0014] Based on the location information, it is determined that a portion of the second object is located at the first edge of the first region;
[0015] The first region is reduced from the first edge toward the center of the first region, while keeping the edges other than the first edge unchanged, to obtain the adjusted first region.
[0016] In some embodiments, the method further includes:
[0017] If the second object is present in the preview screen and is completely located within the first area, the focusing operation is performed on the second object.
[0018] When performing the focusing operation on the second object, the exposure parameters of the second object are adjusted based on the focusing priority of the second object.
[0019] In some embodiments, the method further includes:
[0020] Identify at least one preset object located at the second edge of the reference region;
[0021] For any of the preset objects, the reference region is reduced from the second edge toward the center of the reference region, while keeping the edges other than the second edge unchanged, to obtain the first region.
[0022] In some embodiments, performing a focusing operation on the first object includes:
[0023] Acquire at least one frame of the first image of the first object;
[0024] Based on the pixel values of the pixels in the first image, the focus position is determined, and based on the brightness value of the first image and a preset brightness threshold, the exposure parameters of the first object are determined.
[0025] The method further includes:
[0026] Upon detecting a shooting command, the target image indicated by the shooting command is obtained based on the determined focus position and the exposure parameters.
[0027] According to a second aspect of the present disclosure, a focusing device is provided, comprising:
[0028] The detection module is configured to detect a second object in the preview screen when a focus event is detected on a first object in a first region of the preview screen; wherein the first region is smaller than a reference region, the reference region is determined based on the field of view of the image acquisition module of the electronic device, and the focus priority of the second object is higher than that of the first object.
[0029] The first focusing module is configured to perform a focusing operation on the first object when the second object is present in the preview screen and a portion of the second object is located in the first area.
[0030] In some embodiments, the apparatus further includes:
[0031] The first exposure module is configured to maintain the current exposure parameters of the second object unchanged when the focusing operation is performed on the first object.
[0032] In some embodiments, the apparatus further includes:
[0033] The adjustment module is configured to adjust the first region based on the position information of the second object in the preview screen to obtain the adjusted first region; wherein the adjusted first region is smaller than the original first region.
[0034] The monitoring module is configured to detect focus events for the first object within the adjusted first region.
[0035] In some embodiments, the adjustment module is specifically configured as follows:
[0036] Based on the location information, it is determined that a portion of the second object is located at the first edge of the first region;
[0037] The first region is reduced from the first edge toward the center of the first region, while keeping the edges other than the first edge unchanged, to obtain the adjusted first region.
[0038] In some embodiments, the apparatus further includes:
[0039] The second focusing module is configured to perform the focusing operation on the second object when the second object is present in the preview screen and the second object is completely located within the first area.
[0040] The second exposure module is configured to adjust the exposure parameters of the second object based on the focus priority of the second object when performing the focusing operation on the second object.
[0041] In some embodiments, the apparatus further includes:
[0042] The determination module is configured to determine at least one preset object located at the second edge of the reference region;
[0043] The acquisition module is configured to, for any of the preset objects, shrink the reference region from the second edge toward the center of the reference region, while keeping the edges other than the second edge unchanged, to obtain the first region.
[0044] In some embodiments, the first focusing module is specifically configured as follows:
[0045] Acquire at least one frame of the first image of the first object;
[0046] Based on the pixel values of the pixels in the first image, the focus position is determined, and based on the brightness value of the first image and a preset brightness threshold, the exposure parameters of the first object are determined.
[0047] The device further includes:
[0048] The generation module is configured to, upon detecting a shooting command, obtain the target image indicated by the shooting command based on the determined focus position and the exposure parameters.
[0049] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0050] processor;
[0051] Memory used to store computer programs or instructions;
[0052] The processor executes computer programs or instructions to implement the steps in any of the focusing methods in the first aspect described above.
[0053] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, comprising:
[0054] When a computer program or instruction in a storage medium is executed by a processor, the steps in any of the focusing methods in the first aspect described above are implemented.
[0055] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implement the steps of any of the focusing methods in the first aspect described above.
[0056] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:
[0057] In this embodiment of the present disclosure, when a focus event is detected on a first object in a first area of the preview screen, a second object in the preview screen is detected; when a second object exists in the preview screen and a portion of the second object is located in the first area, a focus operation is performed on the first object.
[0058] On the one hand, the area available for focusing is adjusted from the reference area to a smaller first area, reducing the possibility of misjudgment by the focusing module due to the higher focusing priority of the second object located at the edge of the reference area; on the other hand, when part of the second object is located in the first area, focusing is performed on the first object, improving the focusing accuracy of the first object and thus improving the image quality of the first object.
[0059] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0060] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0061] Figure 1 This is a schematic diagram of a focusable area according to an exemplary embodiment. Figure 1 .
[0062] Figure 2a This is a flowchart illustrating a focusing method according to an exemplary embodiment. Figure 1 .
[0063] Figure 2b This is a schematic diagram of a focusable area according to an exemplary embodiment.
[0064] Figure 3a This is a schematic diagram of an image according to an exemplary embodiment. Figure 1 .
[0065] Figure 3b This is a schematic diagram of an image according to an exemplary embodiment.
[0066] Figure 4 This is a flowchart illustrating a focusing method according to an exemplary embodiment.
[0067] Figure 5 This is a block diagram illustrating a focusing device according to an exemplary embodiment.
[0068] Figure 6 This is a structural block diagram of an electronic device 600 according to an exemplary embodiment. Detailed Implementation
[0069] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0070] In one related technology, during the debugging phase of a face detection algorithm, a reference area for focusing is determined based on the field of view of the image acquisition module. Areas outside the reference area are defined as edge areas, and face avoidance settings are implemented within these edge areas. Therefore, when a face is located in an edge area, it cannot be detected, and focusing is performed on objects within the reference area, thus reducing the likelihood of the focusing module mistakenly focusing on areas the user does not want to focus on.
[0071] For example, Figure 1 This is a schematic diagram of a focusable area according to an exemplary embodiment. Figure 1 ,like Figure 1 As shown, Figure 10 shows the visible area of the image acquisition module determined based on the field of view angle, Figure 11 shows the reference area that can be focused, and Figure 12 shows the edge area.
[0072] In the above scheme, setting the edge region to avoid faces is too mechanical. After the edge region is determined in the debugging stage of the face detection algorithm, the size of the edge region cannot be adjusted in actual use, and the influence of faces located at the edge of the reference region on the focusing module cannot be avoided, which is not conducive to improving the focusing accuracy of objects in the reference region.
[0073] In this embodiment, on the one hand, the area available for focusing is adjusted from the reference area to a smaller first area to reduce the possibility of misjudgment by the focusing module due to the higher focusing priority of the second object located at the edge of the reference area; on the other hand, when there is a second object in the preview image and part of the second object is located in the first area, a focusing operation is performed on the first object to avoid the influence of the second object located at the edge of the first area on the focusing module and improve the focusing accuracy of the first object.
[0074] Figure 2a This is a flowchart illustrating a focusing method according to an exemplary embodiment. Figure 1 ,like Figure 2a As shown, this focusing method mainly includes the following steps:
[0075] In step 201, if a focus event is detected for a first object in a first region of the preview screen, a second object in the preview screen is detected; wherein the first region is smaller than the reference region, the reference region is determined based on the field of view of the image acquisition module of the electronic device, and the focus priority of the second object is higher than that of the first object;
[0076] In step 202, if a second object exists in the preview screen and a portion of the second object is located in the first area, a focus operation is performed on the first object.
[0077] It should be noted that the focusing method proposed in this disclosure can be applied to electronic devices. Here, electronic devices can include terminal devices, such as mobile terminals or fixed terminals. Mobile terminals can include devices such as mobile phones, tablets, laptops, and wearable electronic devices. Fixed terminals can include desktop computers, smart TVs, and in-vehicle systems. In other embodiments, the focusing method can also be applied to applications installed on electronic devices.
[0078] In other embodiments, the focusing method in this disclosure can be configured in a focusing device, which can be located in an electronic device; this disclosure does not limit this. It should be noted that the execution entity in this disclosure can be a central processing unit (CPU) in an electronic device in hardware, and related background services in an electronic device in software; this is not limited.
[0079] Here, electronic devices include, but are not limited to, digital cameras with autofocus, electronic toys, medical devices, industrial equipment, robots, drones, or self-driving cars.
[0080] In some embodiments, the field of view (FOV) of the image acquisition module refers to the angular range of the spatial area that can be observed through the camera lens. The reference area for focusing refers to the entire range or set of areas that the image acquisition module can identify and select for focusing.
[0081] Here, the reference area is concentrated in the center of the preview screen and can be determined based on the field of view of the image acquisition module of the electronic device. For example, when the field of view of the image acquisition module is greater than a first angle threshold, the reference area is determined as a first preset area; when the field of view of the image acquisition module is less than or equal to the first angle threshold and greater than a second angle threshold, the reference area is determined as a second preset area; when the field of view of the image acquisition module is less than or equal to the second angle threshold and less than the second angle threshold, the reference area is determined as a third preset area. Here, the first preset area is greater than the second preset area, which is greater than the third preset area.
[0082] For example, based on the field of view of the image acquisition module, the visible area of the image acquisition module, i.e. the entire preview screen of the electronic device, can be determined. The visible area is rectangular; the reference area is the central area of the preview screen, which is also rectangular.
[0083] Here, the shape and size of the first region can be arbitrarily set according to requirements, as long as the first region is smaller than the reference region and the center position of the first region and the center position of the reference region are both the center of the preview screen. This embodiment of the disclosure does not limit this. For example, the first region is the region after adjusting the reference region. The first region can be a regular region, such as a regular pentagon or a circle; or it can be an irregular region, such as an irregular polygon.
[0084] For example, Figure 2b This is a schematic diagram of a focusable area according to an exemplary embodiment, as shown in Figure 2. Figure 2b As shown, Figure 20 shows the visible area of the image acquisition module determined based on the field of view angle, Figure 21 shows the first area that can be focused, and Figure 22 shows the edge area.
[0085] In some embodiments, when a user controls the image acquisition module of an electronic device to point at a first object, a focus event for the first object within a first area of the preview screen of the electronic device is determined to be triggered. In other embodiments, when the first object moves toward the image acquisition module and the distance between the first object and the image acquisition module is less than a preset distance threshold, a focus event for the first object within the first area is determined to be triggered.
[0086] Understandably, when a focus event is detected targeting the first object within the first area, the first object is identified as the object to be focused that corresponds to the user's needs; it is possible to detect whether there is a second object in the preview interface, thereby assessing the risk of misjudgment by the focus module and ensuring the focus accuracy of the object to be focused.
[0087] Here, the focus priority of the second object is higher than that of the first object. This can be understood as follows: if the image acquisition module recognizes both the first and second objects at the same time, and both objects are within the focusable area, the image acquisition module will prioritize focusing on the second object.
[0088] For example, the second object is an object with facial features, and the first object is an object without facial features; in another example, the second object is a user-defined priority focus object, and the first object is an object other than the priority focus object. This disclosure does not limit the specific object in this regard.
[0089] Taking the second object as an object with facial features as an example, when the focusing event of the first object is detected, the image acquisition module captures image data and sends the image data to the processor or graphics processor, and then processes it based on the facial detection algorithm. The facial detection algorithm analyzes the pixel values in the image data; when facial features such as eyes, nose and mouth are identified, it is determined that the second object exists in the preview image.
[0090] In some embodiments, when the ambient brightness of the environment in which the electronic device is located changes significantly, the intensity and contrast of the light received by the focusing module also change, affecting the determination of the focus position. Furthermore, when the electronic device undergoes significant motion changes, the feature points and contrast in the image change rapidly, which can also make it difficult for the focusing module to accurately determine the focus position. Therefore, to improve focusing accuracy, the positions of the first and second objects in the preview screen are determined only when the ambient brightness change value is within a preset brightness range and / or the motion change amplitude indicated by the motion parameters is within a preset amplitude range.
[0091] In some embodiments, when there is no second object in the preview image, or when it is determined that the second object is not in the first area based on the position information of the second object in the preview image, the first object is directly focused based on the preset focusing algorithm.
[0092] It should be noted that since the focus priority of the second object is higher than that of the first object, when the position information of the second object in the preview image determines that part of the second object is located in the first area, it is certain that the focus module will preferentially treat the second object as the object to be focused. Therefore, in this case, the risk of misjudgment by the focus module is relatively high.
[0093] In this embodiment of the disclosure, in order to reduce the risk of misjudgment by the focusing module and improve the focusing accuracy of the first object, a focusing operation is performed on the first object when a portion of the second object is located in the first region.
[0094] In some embodiments, a preset threshold is set in advance, and face avoidance settings are performed in the edge region. When a part of the second object is located in the first region, the overlap area between the second object and the first region is determined. When the overlap area is less than the preset threshold, the second object can be determined as an object located in the edge region outside the first region, and then a focusing operation is performed on the first object.
[0095] In other embodiments, when a portion of the second object is located in the first region, the first region is adjusted based on the position information of the second object in the preview screen, so that the second object is located in the edge region outside the first region, and the adjusted first region is obtained; then a focusing operation is performed on the first object.
[0096] Here, focusing is performed on the first object based on a preset focusing algorithm. The preset focusing algorithm includes, but is not limited to, one or more of contrast autofocus, phase detection autofocus, and time-of-flight assisted focusing.
[0097] Taking contrast autofocus as an example, the contrast value between adjacent pixels in the focus area is obtained; when there is no contrast value greater than the preset contrast threshold, it is determined that the current focal length is inaccurate; the lens focal length is then adjusted, and the contrast value between adjacent pixels is obtained again until a contrast value greater than the preset contrast threshold is found, and the position with the largest contrast is determined as the focus position.
[0098] Taking phase detection autofocus as an example, when light enters the image acquisition module, some of the light is guided to the phase detection sensor; the phase detection sensor splits the light into two beams and forms an image pair; then it determines the phase difference that represents the offset of the image pair in the horizontal or vertical direction; when the phase difference is greater than a preset phase difference threshold, the lens focal length is adjusted, and the phase difference of the image pair is reacquired until the phase difference is less than or equal to the preset phase difference threshold, thus completing the focusing.
[0099] In this embodiment of the present disclosure, when a focus event is detected on a first object in a first area of the preview screen, a second object in the preview screen is detected; when a second object exists in the preview screen and a portion of the second object is located in the first area, a focus operation is performed on the first object.
[0100] On the one hand, the area available for focusing is adjusted from the reference area to a smaller first area, reducing the possibility of misjudgment by the focusing module due to the higher focusing priority of the second object located at the edge of the reference area; on the other hand, when part of the second object is located in the first area, focusing is performed on the first object, improving the focusing accuracy of the first object and thus improving the image quality of the first object.
[0101] In some embodiments, the method further includes:
[0102] While focusing on the first object, the current exposure parameters of the second object are kept unchanged.
[0103] In one implementation, during the autofocus algorithm debugging phase, a reference area and edge areas for focusing are determined. During the face detection debugging phase, no face avoidance settings are implemented in the edge areas. When a face is detected, the detection result is sent to the focusing module and the exposure module. During the focusing module processing phase, when a face is determined to be located in the edge area, the focusing module discards the face focus box within the edge area and focuses on the object within the reference area, thereby avoiding misfocusing on areas the user does not want to focus on. However, because the exposure module operates independently of the focusing module, even though the focusing module focuses on the reference area, the exposure module will still brighten faces in the edge areas, which is also detrimental to improving the imaging effect of the first object.
[0104] For example, Figure 3a This is a schematic diagram of an image according to an exemplary embodiment. Figure 1 ,like Figure 3a As shown in Figure 30, Figure 302 shows the first object located within the reference area, and Figure 301 shows the second object located in the edge area outside the first area. Since the focusing module focuses on the first object, the exposure module brightens the second object in the edge area, making the sharpness of the first object higher than that of the second object. However, the exposure effect of the first object is lower than that of the second object, resulting in a poor imaging effect of the first object.
[0105] Therefore, in this embodiment of the present disclosure, when focusing on the first object, the current exposure parameters of the second object are kept unchanged, thereby reducing the situation where the image brightness of the non-focused object is higher than that of the focused object, and improving the imaging effect of the first object.
[0106] For example, Figure 3b This is a schematic diagram of an image according to an exemplary embodiment, such as... Figure 3bAs shown in Figure 31, Figure 302 shows the first object located in the first area of the preview screen, and Figure 301 shows the second object located in the edge area outside the first area. Since the focusing module focuses on the first object, the exposure module will not brighten the second object in the edge area, making the clarity of the first object higher than that of the second object, and the exposure effect of the first object lower than that of the second object, thereby improving the poor imaging effect of the first object.
[0107] Taking the second object as an object with facial features as an example, when the second object is detected to be located at the edge of the first region, the Edge Face=1 Flag signal is fed back to the exposure module and the focus module respectively; when the focus module receives the Flag signal, it determines that the second object is not the object to be focused and the first object is the object to be focused, and performs a focusing operation on the first object; when the exposure module receives the Flag signal, the exposure module maintains the current exposure parameters of the second object unchanged.
[0108] In some embodiments, during the focusing operation on the first object, while maintaining the current exposure parameters of the second object unchanged, a preview image of the first object can be acquired; and based on the index parameters of the preview image, the current exposure parameters of the first object can be adjusted or maintained, wherein the index parameters are positively correlated with the image performance. For example, when the image quality index parameter is greater than a preset index threshold, the current exposure parameters of the first object are maintained; when the image quality index parameter is less than or equal to the preset index threshold, the current exposure parameters of the first object are adjusted.
[0109] In this embodiment of the present disclosure, when focusing on the first object, the current exposure parameters of the second object are kept unchanged, reducing the exposure module from brightening the second object, thereby improving the imaging effect of the first object.
[0110] In some embodiments, the method further includes:
[0111] The first region is adjusted based on the position information of the second object in the preview screen to obtain the adjusted first region; wherein the adjusted first region is smaller than the original first region.
[0112] Detect the focus event of the first object within the adjusted first region.
[0113] It should be noted that you can first determine the position information of the second object in the preview screen, and then adjust the first area based on the position information so that the adjusted first area is far away from the second object, thereby improving the accuracy of adjusting the first area and ensuring the accuracy of focus.
[0114] Here, in order to ensure the focus processing of the first object, when adjusting the first region based on the position information, the center position of the first region can be kept unchanged, and the edge position of the first region can be narrowed towards the center position of the first region, so that the adjusted first region is smaller than the original first region.
[0115] In some embodiments, in order to improve the efficiency of adjusting the first region, a correlation between the area range and the adjustment ratio of the first region can be established. Based on the location information of the second object, the overlapping area between the second object and the first region is determined; then the area range of the overlapping area is determined; then, based on the correlation and the area range of the overlapping area, the adjustment ratio is determined; finally, based on the adjustment ratio, the first region is adjusted to obtain the adjusted first region.
[0116] In other embodiments, in order to reduce the shrinkage area of the first region, it can be determined that a portion of the second object is located at the first edge of the first region based on the location information of the second object; and the first region is shrunk from the first edge toward the center of the first region while keeping the edges other than the first edge unchanged, to obtain the adjusted first region.
[0117] Here, after determining the adjusted first region, the focus event of the first object within the adjusted first region is detected, and then the focus operation is performed on the first object.
[0118] In this embodiment, when a portion of the second object is located within the first region, the first region is adjusted based on the position information of the second object in the preview image to obtain an adjusted first region; a focusing event targeting the first object within the adjusted first region is detected. Thus, by dynamically adjusting the first region, the influence of the second object located at the edge of the first region on the focusing module can be reduced, thereby improving the accuracy of focusing on the first object.
[0119] In some embodiments, the first region is adjusted based on the position information of the second object in the preview screen to obtain the adjusted first region, including:
[0120] Based on the location information, it is determined that a portion of the second object is located at the first edge of the first region;
[0121] Shrink the first region from the first edge toward the center of the first region, while keeping the edges other than the first edge unchanged, to obtain the adjusted first region.
[0122] In one implementation, in order to avoid more faces within the edge region, the entire edge region must be expanded (e.g., Figure 1(As shown in Figure 12, the area shrinks towards the center of Figure 11), sacrificing more of the reference area. When multiple first objects exist within the reference area, due to the shrinking of the reference area, any part of the first object within the shrunken reference area is located at the edge, causing the focusing module to identify the first object as an out-of-focus object. This results in the first object being out of focus, which is detrimental to improving the imaging effect of the first object.
[0123] Therefore, in this embodiment of the present disclosure, in order to reduce the shrinkage area of the first region while expanding the edge region outside the first region, the first edge in the first region that is in contact with the second object can be determined based on the position information of the second object, and the first edge can be moved from the center position of the first region while ensuring that the edges other than the first edge remain unchanged, thereby obtaining the adjusted first region.
[0124] Taking the first region as a pentagon as an example, based on the position information of the second object, it is determined that part of the second object is located at the upper left corner of the pentagon. Then, the pentagon is shrunk from the upper left corner toward the center of the pentagon until the shrunk pentagon is far away from the second object. At the same time, the other edges except the upper left corner are kept unchanged to obtain the adjusted pentagon.
[0125] In some embodiments, when two second objects are located at the edge of the first region, the position information of the two second objects in the preview screen is determined respectively; when both second objects are located at the first edge of the first region, the first region is shrunk from the first edge toward the center of the first region, while keeping the edges other than the first edge unchanged, to obtain the adjusted first region; when one second object is located at the first edge of the first region and the other second object is located at the second edge of the first region, the first region is shrunk from the first edge and the second edge toward the center of the first region respectively, so that the shrunk first region is far away from the two second objects, while keeping the edges other than the first edge and the second edge unchanged, to obtain the adjusted first region.
[0126] In this embodiment, a portion of the second object is determined to be located at the first edge of the first region; the first region is then reduced from the first edge toward the center of the first region, while maintaining the edges other than the first edge unchanged, to obtain the adjusted first region. Thus, by only reducing the first edge that contacts the second object, the edge region outside the first region can be expanded, reducing the possibility of the second object being misjudged by the focusing module; simultaneously, the reduced area of the first region ensures focusing operation for objects within the first region.
[0127] In some embodiments, the method further includes:
[0128] If a second object exists in the preview screen and is completely located within the first area, perform a focus operation on the second object.
[0129] When focusing on the second object, the exposure parameters of the second object are adjusted based on the focus priority of the second object.
[0130] In some embodiments, during portrait photography, the image acquisition module adjusts the exposure parameters of the face to ensure that the face is clear, bright, and conveys the desired emotion and atmosphere.
[0131] Therefore, in this embodiment of the disclosure, when the second object is completely located within the first area, since the focusing priority of the second object is higher than that of the first object, the second object can be identified as the object to be focused; and when performing a focusing operation on the second object, the exposure parameters of the second object are adjusted based on the focusing priority of the second object, so that the adjusted second object is displayed clearly, thereby improving the imaging effect of the second object.
[0132] Here, exposure parameters include, but are not limited to, exposure time, aperture size, or ISO.
[0133] In some embodiments, the second object is an object with facial features. When focusing on the second object, a preview image is acquired. Based on the brightness value of the preview image and a preset brightness threshold, the recognition result of the current environmental scene is determined. Based on the recognition result of the current environmental scene, the exposure parameters of the second object are adjusted to improve the sharpness and contrast of the adjusted second object. For example, when the recognition result indicates that the current environmental scene is a sufficiently bright scene, the exposure time can be shortened and the gain reduced to suppress overexposure of the light source and prevent the face from losing details due to overexposure. Or, for example, when the recognition result indicates that the current environmental scene is an insufficiently bright scene, the exposure time can be increased and the gain increased to brighten the image and prevent the face from losing details due to underexposure.
[0134] In this embodiment of the present disclosure, when the second object is completely located within the first area, the second object is identified as the object to be focused, and the exposure parameters of the second object are adjusted so that the second object has higher sharpness after adjustment, thereby improving the imaging quality of the second object.
[0135] In some embodiments, the method further includes:
[0136] Identify at least one pre-defined object located at the second edge of the reference region;
[0137] For any preset object, the reference region is reduced from the second edge toward the center of the reference region, while keeping the edges other than the second edge unchanged, to obtain the first region.
[0138] It should be explained that during actual shooting, there may be instances where a portion of the second object is located within the reference area, causing focusing errors in the autofocus module. Therefore, during the testing phase of the electronic device, a preset object is first set at the edge of the reference area to adjust the reference area, thereby improving the accuracy of determining the first area.
[0139] Since a first region smaller than the reference region is predetermined, when a focusing event is detected targeting the first object, the influence of a second object located at the edge of the reference region on the focusing module can be reduced, thereby improving the focusing accuracy and thus improving the imaging effect of the first object.
[0140] Here, the preset objects and the second objects are of the same type. Each preset object can be located on the same second edge of the reference area, or on different second edges of the reference area.
[0141] In some embodiments, when the requirements for scene shooting are high and / or the image acquisition module of the electronic device has high precision, a larger number of preset objects can be set at the edges of the reference area, so that the adjusted first area can better avoid the situation where the focusing module misjudges due to the higher focusing priority of the second object located at the edge of the reference area, thereby improving the focusing accuracy of the focusing module.
[0142] Taking a rectangular reference area as an example, during the testing phase of the electronic device, four preset objects are placed at the four edges of the reference area. The reference area is then reduced from each of its second edges towards the center, moving away from the preset objects to form a first region. Here, when the size difference between the four preset objects is less than a preset difference threshold, the first region can be a regular octagon.
[0143] In this embodiment, a preset object is determined to be located at the second edge of a reference area, and the reference area is narrowed from the second edge toward the center of the reference area to obtain a first area. This improves the accuracy of determining the first area and reduces the impact of the second object located at the edge of the reference area on the focusing module, thereby improving focusing accuracy.
[0144] In some embodiments, performing a focusing operation on a first object includes:
[0145] Get at least one frame of the first image of the first object;
[0146] The focus position is determined based on the pixel values of the pixels in the first image, and the exposure parameters of the first object are determined based on the brightness value of the first image and a preset brightness threshold.
[0147] The method also includes:
[0148] Upon detecting a shooting command, the target image indicated by the shooting command is obtained based on the determined focus position and exposure parameters.
[0149] Understandably, in order to improve the imaging quality of the target image, during the focusing operation on the first object, at least one frame of the first image can be acquired first, and the focus position and exposure parameters can be determined based on the image parameters of the first image; then, when the shooting command is detected, the target image is generated based on the determined focus position and exposure parameters.
[0150] Here, the focus position can be determined based on the pixel values of the pixels in the first image.
[0151] In some embodiments, the first image is converted to a grayscale image, and a sliding window is set on the grayscale image to traverse each position of the grayscale image; at each position, the focus evaluation function value of the grayscale image within the window is calculated; then, the position with the largest focus evaluation function value is determined as the focus position. Here, the focus evaluation function includes, but is not limited to, grayscale variance, grayscale entropy, or gradient information.
[0152] In other embodiments, when a focus region is determined in the first image, the focus region is divided into at least two sub-regions; and based on the statistical results of the pixel values of the pixels in each sub-region, the recognition result of the focus region is determined; then, if the recognition result indicates that the focus region is a flat region, the focus region is expanded; and then, based on the expanded focus region, the focus position is determined.
[0153] In some embodiments, the focusing module divides each sub-region using a sliding window or based on a preset number of regions, or obtains multiple sub-blocks corresponding to each sub-region using the method of dividing blocks in the automatic white balance algorithm; wherein each sub-block includes multiple pixels.
[0154] In some embodiments, if the focus area is a flat area, the focusing module can expand the focus area, such as expanding the focus area in a preset direction (e.g., the x-direction or the y-direction), or expanding the focus area in all directions (e.g., the x-direction and the y-direction), and based on the expanded focus area, determine the focus position using the aforementioned PDAF algorithm, CDAF algorithm, and other autofocus technologies.
[0155] Here, based on the brightness value of the first image and a preset brightness threshold, the recognition result of the current environment scene is determined. When the recognition result indicates that the current environment is bright, the exposure time indicated by the exposure parameters is shortened, and / or the aperture value indicated by the exposure parameters is increased. When the recognition result indicates that the current environment is dim, the exposure time indicated by the exposure parameters is increased, and / or the aperture value indicated by the exposure parameters is decreased. The size and number of preset brightness thresholds can be set according to needs, and this embodiment does not limit them.
[0156] In some embodiments, the first image is converted into a grayscale image, and then the average or median of the grayscale values is calculated as the brightness value of the first image. The grayscale values range from 0 to 255, with higher grayscale values indicating higher brightness. The calculated brightness value is then compared with a preset brightness threshold to obtain the recognition result of the current environmental scene.
[0157] In other embodiments, a brightness histogram of the first image is determined, and the distribution of the histogram is analyzed to determine the brightness value of the first image. For example, the proportion of pixels with brightness values higher than a first threshold in the histogram can be calculated as the brightness value, and the calculated brightness value is compared with a preset brightness threshold to obtain the recognition result of the current environmental scene.
[0158] In this embodiment of the present disclosure, during the focusing operation on the first object, at least one frame of the first image can be acquired first, and the focus position and exposure parameters can be determined based on the image parameters of the first image; then, when a shooting command is detected, a target image is generated based on the determined focus position and exposure parameters, thereby improving the imaging quality of the target image and enhancing the user's photography experience.
[0159] Figure 4 This is a flowchart illustrating a focusing method according to an exemplary embodiment, as shown in Figure 2. Figure 4 As shown, this focusing method mainly includes the following steps:
[0160] In step 401, a focus event is detected for a first object within a first area of the preview screen.
[0161] In some embodiments, at least one preset object located at the second edge of the reference region is determined; for any preset object, the reference region is reduced from the second edge toward the center of the reference region, while keeping the edges other than the second edge unchanged, to obtain a first region. For example, the reference region is shown in Figure 11, and the first region is shown in Figure 21.
[0162] In step 402, if the ambient brightness change value is within a preset brightness range and / or the motion change amplitude indicated by the motion parameters is within a preset amplitude range, the position of the first object in the preview screen is redefined.
[0163] In step 403, if the first object is located in the first area, it is determined whether a second object exists in the preview screen.
[0164] Here, the focus priority of the second object is higher than that of the first object.
[0165] In some embodiments, if it is determined that a second object exists in the preview screen, step 404 is performed.
[0166] In other embodiments, step 405 is performed if it is determined that there is no second object in the preview screen.
[0167] In step 404, it is determined whether the second object is located at the edge of the first region.
[0168] In some embodiments, step 406 is performed when the location of the second object at the edge of the first region is determined.
[0169] In other embodiments, step 407 is performed if it is determined that the second object is not located at the edge of the first region.
[0170] In step 405, a focusing operation is performed on the first object based on a preset focusing algorithm.
[0171] In step 406, a focusing operation is performed on the first object.
[0172] In some embodiments, based on the position information of the second object in the preview screen, it is determined that a portion of the second object is located at the first edge of the first region; and the first region is reduced from the first edge toward the center of the first region while keeping the edges other than the first edge unchanged to obtain the adjusted first region; then, a focus event for the first object in the adjusted first region is detected, and a focus operation is performed on the first object.
[0173] In some embodiments, during the focusing operation on the first object, at least one frame of the first image of the first object is first acquired; then, based on the pixel values of the pixels in the first image, the focus position is determined, and based on the brightness value of the first image and a preset brightness threshold, the exposure parameters of the first object are determined.
[0174] In step 407, a focusing operation is performed on the second object.
[0175] In step 408, while performing a focusing operation on the first object, the current exposure parameters of the second object are kept unchanged.
[0176] In step 409, when focusing on the second object, the exposure parameters of the second object are adjusted based on the focus priority of the second object.
[0177] In step 410, if a shooting command is detected, the target image indicated by the shooting command is obtained based on the determined focus position and exposure parameters.
[0178] In this embodiment of the present disclosure, when a focus event is detected on a first object in a first area of the preview screen, a second object in the preview screen is detected; when a second object exists in the preview screen and a portion of the second object is located in the first area, a focus operation is performed on the first object.
[0179] On the one hand, the area available for focusing is adjusted from the reference area to a smaller first area, reducing the possibility of misjudgment by the focusing module due to the higher focusing priority of the second object located at the edge of the reference area; on the other hand, when part of the second object is located in the first area, focusing is performed on the first object, improving the focusing accuracy of the first object and thus improving the image quality of the first object.
[0180] Figure 5 This is a block diagram illustrating a focusing device according to an exemplary embodiment, such as... Figure 5 As shown, the focusing device 500 includes:
[0181] The detection module 501 is configured to detect a second object in the preview screen when a focusing event is detected targeting a first object in a first region of the preview screen; wherein the first region is smaller than a reference region, the reference region is determined based on the field of view of the image acquisition module of the electronic device, and the focusing priority of the second object is higher than that of the first object.
[0182] The first focusing module 502 is configured to perform a focusing operation on the first object when the second object is present in the preview screen and a portion of the second object is located in the first area.
[0183] In some embodiments, the device 500 further includes:
[0184] The first exposure module is configured to maintain the current exposure parameters of the second object unchanged when the focusing operation is performed on the first object.
[0185] In some embodiments, the device 500 further includes:
[0186] The adjustment module is configured to adjust the first region based on the position information of the second object in the preview screen to obtain the adjusted first region; wherein the adjusted first region is smaller than the original first region.
[0187] The monitoring module is configured to detect focus events for the first object within the adjusted first region.
[0188] In some embodiments, the adjustment module is specifically configured as follows:
[0189] Based on the location information, it is determined that a portion of the second object is located at the first edge of the first region;
[0190] The first region is reduced from the first edge toward the center of the first region, while keeping the edges other than the first edge unchanged, to obtain the adjusted first region.
[0191] In some embodiments, the device 500 further includes:
[0192] The second focusing module is configured to perform the focusing operation on the second object when the second object is present in the preview screen and the second object is completely located within the first area.
[0193] The second exposure module is configured to adjust the exposure parameters of the second object based on the focus priority of the second object when performing the focusing operation on the second object.
[0194] In some embodiments, the device 500 further includes:
[0195] The determination module is configured to determine at least one preset object located at the second edge of the reference region;
[0196] The acquisition module is configured to, for any of the preset objects, shrink the reference region from the second edge toward the center of the reference region, while keeping the edges other than the second edge unchanged, to obtain the first region.
[0197] In some embodiments, the first focusing module 502 is specifically configured as follows:
[0198] Acquire at least one frame of the first image of the first object;
[0199] Based on the pixel values of the pixels in the first image, the focus position is determined, and based on the brightness value of the first image and a preset brightness threshold, the exposure parameters of the first object are determined.
[0200] The device 500 further includes:
[0201] The generation module is configured to, upon detecting a shooting command, obtain the target image indicated by the shooting command based on the determined focus position and the exposure parameters.
[0202] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0203] Figure 6 This is a structural block diagram illustrating an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0204] Reference Figure 6 The electronic device 600 may include one or more of the following components: processing component 602, memory 604, power supply component 606, multimedia component 608, audio component 610, input / output (I / O) interface 612, sensor component 614, and communication component 616.
[0205] Processing component 602 typically controls the overall operation of electronic device 600, such as operations associated with at least one of display, telephone call, data communication, camera operation, and recording operation. Processing component 602 may include one or more processors 620 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 602 may include one or more modules to facilitate interaction between processing component 602 and other components. For example, processing component 602 may include a multimedia module to facilitate interaction between multimedia component 608 and processing component 602.
[0206] Memory 604 is configured to store various types of data to support the operation of electronic device 600. Examples of such data include at least one of the following: instructions for any application or method operating on electronic device 600, contact data, phonebook data, messages, pictures, and videos. Memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0207] Power supply component 606 provides power to various components of electronic device 600. Power supply component 606 may include at least one of the following: a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 600.
[0208] Multimedia component 608 includes a screen that provides an output interface between electronic device 600 and user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen may be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 608 includes a front-facing camera and / or a rear-facing camera. When electronic device 600 is in an operating mode, such as a shooting mode or video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0209] Audio component 610 is configured to output and / or input audio signals. For example, audio component 610 includes a microphone (MIC) configured to receive external audio signals when electronic device 600 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 604 or transmitted via communication component 616. In some embodiments, audio component 610 also includes a speaker for outputting audio signals.
[0210] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, and buttons. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0211] Sensor assembly 614 includes one or more sensors for providing state assessments of various aspects of electronic device 600. For example, sensor assembly 614 may detect the on / off state of electronic device 600, the relative positioning of components such as the display and keypad of electronic device 600, changes in position of electronic device 600 or one of its components, the presence or absence of user contact with electronic device 600, orientation or acceleration / deceleration of electronic device 600, and temperature changes of electronic device 600. Sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 614 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, sensor assembly 614 may also include, but is not limited to, at least one of the following: an accelerometer, a gyroscope, a magnetometer, a pressure sensor, and a temperature sensor.
[0212] Communication component 616 is configured to facilitate wired or wireless communication between electronic device 600 and other devices. Electronic device 600 can access wireless networks based on communication standards, such as Wi-Fi, 4G, 5G, or combinations thereof. In one exemplary embodiment, communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 616 also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, UWB technology, Bluetooth (BT) technology, and other technologies.
[0213] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.
[0214] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including executable instructions or a computer program, which can be executed by a processor 620 of an electronic device 600 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0215] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform any of the focusing methods described above in the embodiments of this disclosure. For example, the focusing method includes:
[0216] If a focus event is detected on a first object within a first region of the preview screen, a second object in the preview screen is detected; wherein the first region is smaller than a reference region, the reference region is determined based on the field of view of the image acquisition module of the electronic device, and the focus priority of the second object is higher than that of the first object.
[0217] If the second object is present in the preview screen and a portion of the second object is located in the first area, a focus operation is performed on the first object.
[0218] This disclosure provides a computer program product comprising a computer program or executable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the computer device to perform any of the focusing methods described above in this disclosure.
[0219] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0220] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A focusing method, characterized in that, The method includes: If a focus event is detected on a first object within a first region of the preview screen, a second object in the preview screen is detected; wherein the first region is smaller than a reference region, the reference region is determined based on the field of view of the image acquisition module of the electronic device, and the focus priority of the second object is higher than that of the first object. If the second object is present in the preview screen and a portion of the second object is located in the first area, a focus operation is performed on the first object.
2. The method according to claim 1, characterized in that, The method further includes: While performing the focusing operation on the first object, the current exposure parameters of the second object are kept unchanged.
3. The method according to claim 2, characterized in that, The method further includes: The first region is adjusted based on the position information of the second object in the preview screen to obtain the adjusted first region; wherein the adjusted first region is smaller than the original first region. Detect focus events for the first object within the adjusted first region.
4. The method according to claim 3, characterized in that, The step of adjusting the first region based on the position information of the second object in the preview screen to obtain the adjusted first region includes: Based on the location information, it is determined that a portion of the second object is located at the first edge of the first region; The first region is reduced from the first edge toward the center of the first region, while keeping the edges other than the first edge unchanged, to obtain the adjusted first region.
5. The method according to claim 1, characterized in that, The method further includes: If the second object is present in the preview screen and is completely located within the first area, the focusing operation is performed on the second object. When performing the focusing operation on the second object, the exposure parameters of the second object are adjusted based on the focusing priority of the second object.
6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: Identify at least one preset object located at the second edge of the reference region; For any of the preset objects, the reference region is reduced from the second edge toward the center of the reference region, while keeping the edges other than the second edge unchanged, to obtain the first region.
7. The method according to any one of claims 1 to 5, characterized in that, The focusing operation on the first object includes: Acquire at least one frame of the first image of the first object; Based on the pixel values of the pixels in the first image, the focus position is determined, and based on the brightness value of the first image and a preset brightness threshold, the exposure parameters of the first object are determined. The method further includes: Upon detecting a shooting command, the target image indicated by the shooting command is obtained based on the determined focus position and the exposure parameters.
8. A focusing device, characterized in that, The device includes: The detection module is configured to detect a second object in the preview screen when a focus event is detected on a first object in a first region of the preview screen; wherein the first region is smaller than a reference region, the reference region is determined based on the field of view of the image acquisition module of the electronic device, and the focus priority of the second object is higher than that of the first object. The first focusing module is configured to perform a focusing operation on the first object when the second object is present in the preview screen and a portion of the second object is located in the first area.
9. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes a computer program or instructions to implement the steps of the method of any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing a computer program or instructions, characterized in that, When a computer program or instructions in a storage medium are executed by a processor, the steps of the method of any one of claims 1 to 7 are implemented.
11. A computer program product, comprising a computer program or instructions, characterized in that, When a computer program or instruction is executed by a processor, it implements the steps of the method of any one of claims 1 to 7.