Automatic focusing method and device, camera system, electronic equipment and storage medium

By obtaining the ambient brightness information during the autofocus of the camera system and performing compensation processing, the problem of blurred or failure in dark or weak texture scenes is solved, and the focus effect and accuracy are improved.

CN119545174APending Publication Date: 2025-02-28BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202311101739.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-29
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

In the prior art, the automatic focus algorithm of the camera system is not effective, especially in dark or weak texture scenarios, where focus blur or focus failure often occurs.

Method used

By obtaining the focus value and ambient brightness information when the lens moves to each lens position during the autofocus process, the target compensation coefficient is determined based on the pre-calibrated compensation relationship, and the focus value is compensated to obtain the target focus value, thereby determining the quasi-focus position of the lens.

Benefits of technology

Effectively eliminate or alleviate the calculation error of focus value caused by changes in ambient brightness caused by lens movement, and improve the autofocus effect and accuracy, especially in weak texture focusing scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119545174A_ABST
    Figure CN119545174A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of electronic imaging, and particularly provides an automatic focusing method and device, and the method comprises the steps: obtaining a focusing value and environment brightness information when a lens moves to each lens position in the focusing process of a camera, determining a corresponding target compensation coefficient based on the environment brightness information and a pre-calibrated compensation relation, and carrying out the adjustment of the target compensation coefficient. And performing compensation processing on the focusing value by using the target compensation coefficient and the position parameter corresponding to the lens position to obtain a target focusing value, and determining a focusing position based on the target focusing values of all the lens positions. According to the embodiment of the invention, the focusing effect and accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of electronic imaging technology, and in particular to an autofocus method, device, camera system, electronic device and storage medium. Background Art

[0002] With the development of imaging technology of mobile terminals, people increasingly rely on mobile terminals for image capture, so imaging algorithms for mobile terminals have become a key research direction for major terminal manufacturers. Autofocus (AF) technology refers to the technology of the imaging system to obtain the maximum clarity of the subject by autonomously moving the lens, which is an important part of the computational photography 3A algorithm.

[0003] In the related art, the autofocus algorithm of the camera system does not work well and often causes blurred focus problems, especially in low light or weak texture scenes, and it may even be impossible to find the exact focus position, resulting in focus failure. Summary of the invention

[0004] To improve the autofocus effect, the embodiments of the present disclosure provide an autofocus method, device, camera system, electronic device and storage medium.

[0005] In a first aspect, an embodiment of the present disclosure provides an auto-focusing method, comprising:

[0006] During the camera focusing process, the focus value and ambient brightness information are obtained when the lens moves to each lens position;

[0007] Determining a target compensation coefficient corresponding to the ambient brightness information at each lens position based on the ambient brightness information and a pre-calibrated compensation relationship, wherein the compensation relationship represents a corresponding relationship between the ambient brightness information and the compensation coefficient of the focus value;

[0008] For each lens position, based on the position parameter corresponding to the lens position and the target compensation coefficient, the focus value is compensated to obtain a target focus value;

[0009] Based on the target focus values ​​of all lens positions during the focusing process, the in-focus position of the lens is determined.

[0010] In some implementations, the ambient brightness information includes a brightness parameter, and obtaining the ambient brightness information of each lens position includes:

[0011] For each lens position, determining the brightness parameter based on the sum of all pixel values ​​in the focus window and the number of pixels;

[0012] Before determining the target compensation coefficient corresponding to the ambient brightness at each lens position based on the ambient brightness and the pre-calibrated compensation relationship, the method further includes:

[0013] For each lens position, the focus value is normalized based on the brightness parameter to obtain a focus value after normalization.

[0014] In some implementations, the ambient brightness information includes a brightness parameter and an exposure gain, and determining a target compensation coefficient corresponding to the ambient brightness information at each lens position based on the ambient brightness information and a pre-calibrated compensation relationship includes:

[0015] Based on the brightness parameter and the exposure gain, the compensation relationship is interpolated to obtain the target compensation coefficient corresponding to the brightness parameter and the exposure gain.

[0016] In some implementations, the compensating the focus value based on the position parameter corresponding to the lens position and the target compensation coefficient to obtain the target focus value includes:

[0017] Based on the product of the target compensation coefficient and the position parameter, the focus value is compensated to obtain the target focus value.

[0018] In some implementations, determining the in-focus position of the lens based on the target focus values ​​of all lens positions during the focusing process includes:

[0019] Based on the target focus values ​​corresponding to all lens positions during the focusing process, a relationship curve between the lens position and the target focus value is obtained by fitting;

[0020] Based on the relationship curve, a lens position corresponding to a peak value of the target focus value is determined as the in-focus position.

[0021] In some embodiments, the compensation relationship is calibrated in the following manner:

[0022] Pre-configuring a focus window size and an ambient brightness information list, wherein the ambient brightness information list includes a plurality of different ambient brightness information;

[0023] For each piece of environmental brightness information, the camera lens is controlled to move with a preset step length, and a focus image is collected by using the focus window when each lens position is moved, wherein the focus image is an image of a pure color object;

[0024] Determine a focus value corresponding to each lens position based on the focus image, obtain a straight line equation between the lens position and the focus value according to the focus value of each lens position, and determine a compensation coefficient corresponding to the ambient brightness information based on the slope of the straight line equation;

[0025] The compensation relationship is determined according to the compensation coefficient corresponding to each piece of ambient brightness information.

[0026] In some embodiments, the ambient brightness information list includes a brightness parameter list and an exposure gain list, the brightness parameter list includes multiple brightness parameters, the exposure gain list includes multiple exposure gains, and the ambient brightness information includes any brightness parameter and any exposure gain.

[0027] In a second aspect, an embodiment of the present disclosure provides an autofocus device, comprising:

[0028] The FV acquisition module is configured to acquire the focus value and the ambient brightness information when the lens moves to each lens position during the camera focusing process;

[0029] a compensation determination module configured to determine a target compensation coefficient corresponding to the ambient brightness information of each lens position based on the ambient brightness information and a pre-calibrated compensation relationship, wherein the compensation relationship represents a corresponding relationship between the ambient brightness information and the compensation coefficient of the focus value;

[0030] A compensation processing module is configured to, for each lens position, perform compensation processing on the focus value based on a position parameter corresponding to the lens position and the target compensation coefficient to obtain a target focus value;

[0031] The focus determination module is configured to determine the in-focus position of the lens based on the target focus values ​​of all lens positions during the focusing process.

[0032] In some implementations, the ambient brightness information includes a brightness parameter, and the FV acquisition module is configured to:

[0033] For each lens position, determining the brightness parameter based on the sum of all pixel values ​​in the focus window and the number of pixels;

[0034] For each lens position, the focus value is normalized based on the brightness parameter to obtain a focus value after normalization.

[0035] In some implementations, the ambient brightness information includes a brightness parameter and an exposure gain, and the compensation determination module is configured to:

[0036] Based on the brightness parameter and the exposure gain, the compensation relationship is interpolated to obtain the target compensation coefficient corresponding to the brightness parameter and the exposure gain.

[0037] In some embodiments, the compensation processing module is configured to:

[0038] Based on the product of the target compensation coefficient and the position parameter, the focus value is compensated to obtain the target focus value.

[0039] In some implementations, the focus determination module is configured to:

[0040] Based on the target focus values ​​corresponding to all lens positions during the focusing process, a relationship curve between the lens position and the target focus value is obtained by fitting;

[0041] Based on the relationship curve, a lens position corresponding to a peak value of the target focus value is determined as the in-focus position.

[0042] In some implementations, the auto-focusing device of the example of the present disclosure further includes a calibration module, and the calibration module is configured to:

[0043] Pre-configuring a focus window size and an ambient brightness information list, wherein the ambient brightness information list includes a plurality of different ambient brightness information;

[0044] For each piece of environmental brightness information, the camera lens is controlled to move with a preset step length, and a focus image is collected by using the focus window when each lens position is moved, wherein the focus image is an image of a pure color object;

[0045] Determine a focus value corresponding to each lens position based on the focus image, obtain a straight line equation between the lens position and the focus value according to the focus value of each lens position, and determine a compensation coefficient corresponding to the ambient brightness information based on the slope of the straight line equation;

[0046] The compensation relationship is determined according to the compensation coefficient corresponding to each piece of ambient brightness information.

[0047] In some embodiments, the ambient brightness information list includes a brightness parameter list and an exposure gain list, the brightness parameter list includes multiple brightness parameters, the exposure gain list includes multiple exposure gains, and the ambient brightness information includes any brightness parameter and any exposure gain.

[0048] In a third aspect, an embodiment of the present disclosure provides a camera system, including:

[0049] Lens;

[0050] an actuator for driving the lens to move during focusing; and

[0051] A controller comprises a processor and a memory, wherein the memory stores computer instructions, and the computer instructions are used to enable the processor to execute the method according to any embodiment of the first aspect.

[0052] In a fourth aspect, an embodiment of the present disclosure provides an electronic device, comprising the camera system according to any embodiment of the third aspect.

[0053] In a fifth aspect, an embodiment of the present disclosure provides a storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in any embodiment of the first aspect.

[0054] The autofocus method of the disclosed embodiment includes obtaining the focus value and ambient brightness information when the lens moves to each lens position during the camera focusing process, determining the corresponding target compensation coefficient based on the ambient brightness information and a pre-calibrated compensation relationship, compensating the focus value using the target compensation coefficient and the position parameter corresponding to the lens position to obtain the target focus value, and determining the quasi-focus position based on the target focus values ​​of all lens positions. In the disclosed embodiment, during the autofocus process, the corresponding compensation coefficient is determined based on the ambient brightness information of each lens position, and the compensation coefficient is used to achieve compensation correction of the FV value of the lens position, thereby eliminating or alleviating the FV calculation error caused by the change in ambient brightness caused by the movement of the lens, especially for weak texture focus scenes, improving the focusing effect and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0056] Figure 1 It is a schematic diagram of the principle of the auto-focus method in some embodiments of the present disclosure.

[0057] Figure 2 It is a schematic diagram of the principle of the auto-focus method in some embodiments of the present disclosure.

[0058] Figure 3 It is a schematic diagram of the principle of the auto-focus method in some embodiments of the present disclosure.

[0059] Figure 4 is a flowchart of an auto-focus method according to some embodiments of the present disclosure.

[0060] Figure 5 It is a schematic diagram of the principle of the auto-focus method in some embodiments of the present disclosure.

[0061] Figure 6 is a flowchart of an auto-focus method according to some embodiments of the present disclosure.

[0062] Figure 7 is a flowchart of an auto-focus method according to some embodiments of the present disclosure.

[0063] Figure 8 is a flowchart of an auto-focus method according to some embodiments of the present disclosure.

[0064] Fig. 9 It is a structural block diagram of an autofocus device in some embodiments of the present disclosure.

[0065] Fig.10 It is a structural block diagram of an electronic device according to some implementations of the present disclosure. DETAILED DESCRIPTION

[0066] The technical solution of the present disclosure will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described implementation is a part of the implementation of the present disclosure, rather than all the implementations. Based on the implementation in the present disclosure, all other implementations obtained by ordinary technicians in the field without creative work are within the scope of protection of the present disclosure. In addition, the technical features involved in the different implementations of the present disclosure described below can be combined with each other as long as they do not conflict with each other.

[0067] The 3A algorithm of computational photography refers to auto focus (AF), automatic exposure (AE) and automatic white balance (AWB), and auto focus AF is an important part of the 3A algorithm.

[0068] Currently, AF algorithms are divided into active focus and passive focus. Active focus refers to detecting the depth information of an object by actively emitting laser signals and completing the focusing purpose by object distance conversion. Active focus requires additional laser devices, which increases camera costs and power consumption. Therefore, most imaging devices still use passive focus solutions.

[0069] Passive focus mainly includes PDAF (Phase Detection Auto Focus) and CDAF (Contrast Detection Auto Focus).

[0070] PDAF requires a certain number of masked pixels to be set on the photosensitive element, and a complex optical path is required for phase detection. The focus position is determined based on the phase difference between pixels to achieve accurate focus. CDAF can be achieved only through software algorithms without improving the sensor structure and complex optical path design, so it is more commonly used in electronic imaging devices.

[0071] It can be understood that focusing refers to the process of finding the image distance corresponding to the clearest image. For a camera system with an autofocus function, it often includes a lens, an actuator and a photosensitive element. A photosensitive element refers to an electrical element used to receive light entering the lens to form an image. The photosensitive element can be, for example, a COMS (Complementary Metal Oxide Semiconductor) chip, etc. An actuator refers to a power element that drives the lens to move back and forth along the optical axis. For example, in one example, the actuator can be a voice coil motor (VCM). The lens refers to the optical lens of the camera system. When the lens is driven by the actuator to move closer to or away from the photosensitive element, the quasi-focal plane position of the camera system can be adjusted. The quasi-focal plane is a clear surface with clear imaging.

[0072] During the autofocus process, the actuator (hereinafter referred to as the voice coil motor VCM) will continuously drive the camera lens to move. Each time the lens moves, an image is captured and the focus value (FV) corresponding to the image is calculated. The focus value FV can reflect the clarity of the image. Generally, the larger the FV value, the clearer the image. By finding the maximum FV value during the lens movement, the best quasi-focus position can be determined. The quasi-focus position is the lens position when the image is clearest. After determining the quasi-focus position of the lens, the voice coil motor can be configured according to the quasi-focus position, so as to control the voice coil motor to drive the lens to move to the quasi-focus position and complete the autofocus process.

[0073] Figure 1 FIG. 1 shows a curve showing a change in lens position and FV value during autofocus in an exemplary embodiment. Figure 1 The specific principle and process of CDAF are explained.

[0074] First, the voice coil motor can drive the lens to move in a large step size, and calculate the FV value each time it moves to a lens position. If the FV value of the current lens position is greater than the FV value of the previous lens position, it continues to move to the next step. Conversely, if the current FV value is less than the FV value of the previous lens position, the position interval between the current lens position and the previous lens position can be determined as the refined search interval.

[0075] For example Figure 1In the example scenario, during the process of moving from lens position A to lens position D, the FV value gradually increases, so that the motor continues to push the lens to move to lens position E. At this time, the FV value of lens position E is smaller than the FV value of lens position D, and the lens will no longer continue to move in larger steps. Instead, the position interval between lens positions E and D is determined as the precise search interval.

[0076] Then, the camera continues to move in the refinement interval with smaller steps, for example Figure 1 In the example scenario, during the process of moving from lens position E to lens position H, the FV value gradually increases, so that the motor continues to push the lens to move to lens position D. At this time, the FV value of lens position D is less than the FV value of lens position H, and the focus scanning process is stopped.

[0077] Afterwards, the curve shown in the figure is fitted based on the discrete points that have been obtained. The fitting curve can describe the change pattern of the FV value with the lens position. Then, the lens position I corresponding to the peak point of the fitting curve is used as the best focus position for shooting, that is, the lens position I corresponding to the peak point of the curve is the quasi-focus position of autofocus.

[0078] In actual shooting scenes, the CDAF algorithm in related technologies has acceptable autofocus effect and accuracy for scenes with rich texture details or high ambient light brightness, but for scenes with low light or weak texture, blurred focus or focus failure often occurs.

[0079] Through research, we found that this is because the FV value calculated by the hardware is more sensitive to changes in ambient brightness. When the object distance and the focus object remain unchanged, the higher the ambient brightness, the larger the calculated FV value. During the autofocus process, AE adjusts the exposure gain or exposure time, which will cause changes in ambient brightness, thus affecting the accuracy of the calculated FV value.

[0080] In addition, even if AE is locked during the focusing process, the intensity of ambient light received by the photosensitive element will also change while the motor drives the lens to move. For objects with rich texture details, since their FV values ​​are large, the changes in ambient brightness caused by lens movement have little impact, and the error in the focusing algorithm results is not large. However, for scenes with weak texture details, especially weak texture scenes in dim light, since their FV values ​​are small, the changes in ambient brightness caused by lens movement are more obvious, resulting in large errors in the quasi-focus position calculated by the AF algorithm, resulting in blurred focus or even focus failure.

[0081] In the disclosed embodiment, a focus object with weak texture is defined as a flat area of ​​the image. The flat area can be a solid color scene such as a white wall or white paper. When the focus object is a flat area, since the image texture features within the focus window are very weak, the FV value calculated by the hardware is small, and focus blur or even focus failure is more likely to occur.

[0082] Figure 2 It is a curve of the lens position and the ambient brightness change when focusing on a flat area in an example scenario of the present disclosure, wherein the horizontal axis represents the lens position and the vertical axis represents the ambient brightness received by the photosensitive element.

[0083] exist Figure 2 In the example, the smaller the lens position is, the smaller the object distance is, and thus the image distance between the lens and the photosensitive element is larger. It can be seen that even if the external ambient light intensity remains unchanged, as the lens position decreases during the focusing process, the actual ambient brightness received by the photosensitive element will gradually decrease, and the FV value calculated by the hardware will also become smaller. In this example, the relationship between the FV value and the lens position during the focusing process is as follows: Figure 3 shown.

[0084] exist Figure 3 In the example, the horizontal axis represents the lens position and the vertical axis represents the FV value. Figure 2 , Figure 3 It can be seen that the smaller the lens position, the smaller the actual ambient brightness received by the photosensitive element, and the smaller the FV value calculated by the hardware. As a result, the motor will continuously drive the lens toward the photosensitive device until it moves to the position closest to the photosensitive element, resulting in blurred images and focus failure.

[0085] It can be seen that the autofocus algorithm in the related technology, when targeting scenes with smaller FV values ​​such as dark light or flat areas, is easily affected by changes in ambient brightness caused by lens movement during the focusing process, which can easily lead to large errors in FV calculation, resulting in blurred focus or even focus failure.

[0086] It is worth noting that the above-mentioned process of discovering defects in the relevant technology is also part of the creative labor of the present disclosure. That is, in the absence of direct disclosure in the prior art, the above-mentioned process of discovering that the changes in ambient brightness caused by the movement of the lens during the focusing process lead to a large calculation error in the FV value for the flat area focusing scene, resulting in blurred focus or focusing failure, is also the result of the creative labor of the inventor of this case.

[0087] Based on the above-mentioned defects, the embodiments of the present disclosure provide an autofocus method, device, camera system, electronic device and storage medium, which aim to compensate the FV value accordingly for different ambient brightness conditions during the focusing process, eliminate or alleviate the FV calculation error caused by the change of ambient brightness due to the movement of the lens, especially for weak texture focusing scenes, and improve the focusing effect and accuracy.

[0088] In a first aspect, an embodiment of the present disclosure provides an autofocus method, which can be applied to a camera system or an electronic device having a camera system. The electronic device described in the present disclosure can be any type of device suitable for implementation, such as a smart phone, a tablet computer, a wearable device, a laptop computer, etc., and the present disclosure does not limit this.

[0089] The autofocus method of the disclosed embodiment, after the lens moves to a certain lens position to obtain the FV value, does not directly search for the quasi-focus position based on the FV value, but needs to further compensate the FV value. The purpose of the compensation is to eliminate or alleviate the FV calculation error caused by the change in ambient brightness due to the change in lens position.

[0090] The data basis for compensating the FV value is the compensation relationship obtained by pre-calibration, and the compensation relationship refers to the corresponding relationship between the ambient brightness and the FV compensation coefficient. It can be understood that when the ambient brightness information when the lens moves to a certain lens position is determined, based on the pre-calibrated compensation relationship, the compensation coefficient corresponding to the current ambient brightness information can be determined, so that the FV value can be compensated based on the compensation coefficient, eliminating or alleviating the FV calculation error caused by the change in ambient brightness caused by the change in lens position.

[0091] It can be seen that the autofocus method of the embodiment of the present disclosure includes at least two stages: one is the stage of pre-calibrating the compensation relationship; the other is the stage of implementing the autofocus algorithm based on the pre-calibrated compensation relationship. For ease of understanding and explanation, the following embodiments of the present disclosure will firstly explain the process of pre-calibrating the compensation relationship, and then explain the process of implementing autofocus based on the compensation relationship.

[0092] 1) Calibration stage

[0093] It can be understood that the purpose of the calibration stage is to determine the corresponding relationship between the ambient brightness information and the compensation coefficient, and the compensation coefficient refers to the coefficient value for correcting and compensating the FV value.

[0094] Combination Figure 3It can be understood that when the focused object is a flat scene, assuming that the ambient brightness does not change during the movement of the lens, the focus window image captured each time the lens moves is the same pure color image, so the calculated FV value should also be the same or very close, that is, as the lens position moves, the FV value should be maintained at an approximately constant value, so that the FV curve should be an approximately horizontal line.

[0095] The reason why it appears Figure 3 The increasing curve shown is because Figure 2 As shown in the figure, the movement of the lens will cause the ambient brightness received by the photosensitive element to change, so that the FV value corresponding to different lens positions will no longer remain constant.

[0096] Based on this, it can be understood that during the focusing process, after the lens moves to a certain lens position and the original FV value is calculated, a compensation value should be compensated on the basis of the original FV value. This compensation value is the product of the slope of the FV value changing with the lens position in the flat area scene and the lens position. This can eliminate or alleviate the FV value calculation error caused by the movement of the lens position.

[0097] In the embodiment of the present disclosure, the slope of the FV value changing with the lens position in the flat area scene is the compensation coefficient described in the present disclosure, and different compensation coefficients are further calibrated for different ambient brightness information to obtain the compensation relationship described in the present disclosure. Figure 4 The compensation relationship calibration process of the embodiment of the present disclosure is described.

[0098] like Figure 4 As shown, in some embodiments, the auto-focus method of the present disclosure example, the process of pre-calibrating and obtaining the compensation relationship includes:

[0099] S410: Preconfigure a focus window size and an ambient brightness information list.

[0100] In the embodiment of the present disclosure, the focus window size needs to be preset before calibration begins, and the focus window is the ROI (Region Of Interest) for capturing the focus image.

[0101] It can be understood that during the autofocus process, when the lens moves to a certain lens position, the camera needs to capture a focus image to calculate the FV value of the current lens position. The size of the focus image is not the entire image, but is generally a small area located in the center of the image. This area is the focus window described in the present disclosure, also called the ROI area.

[0102] For example, in an example, assuming that the camera resolution is 4000 pixels*3000 pixels, the size of the focus window may be, for example, 500 pixels*500 pixels, and the position of the focus window is the center position of the image.

[0103] In an embodiment of the present disclosure, the focus window size configured before calibration may be consistent with the focus window size when the camera system actually takes pictures. For example, the focus window size may be configured to be 500 pixels*500 pixels.

[0104] The purpose of the ambient brightness information list is to give different ambient brightnesses during the calibration process. Therefore, the ambient brightness information list needs to include multiple different ambient brightness information, so that when a certain ambient brightness information is configured for the camera, the camera system can be calibrated according to the ambient brightness information to obtain the corresponding FV curve.

[0105] It can be understood that when the brightness of the external ambient light remains unchanged, the ambient brightness information received by the photosensitive element is affected by the exposure gain (Gain) and brightness parameter (Luma) set by the AE. Therefore, in some embodiments of the present disclosure, the ambient brightness information of the focus window can be represented by (Gain, Luma), so that the ambient brightness information list of the embodiments of the present disclosure can include an exposure gain list (Gain List) and a brightness parameter list (Luma List).

[0106] In the embodiment of the present disclosure, the exposure gain list Gain List may include multiple different exposure gain parameters. Similarly, the brightness parameter list Luma List may include multiple different brightness parameters. These parameters may be a number of discrete values ​​selected based on the exposure gain range and brightness parameter range of the camera system.

[0107] For example, in an example, the maximum exposure gain Gain that can be set for AE in a camera system is 180, so a reference exposure gain list Gain List can be set to [1, 2, 4, 8, 12, 16, 20, 30, 50, 70, 90, 140, 180], and the elements in the list are 13 discrete values ​​selected from the exposure gain range of 0 to 180.

[0108] In this example, the camera system's Luma Range is (0, 10000), so a reference Luma List can be set to [3000, 4000, 5000, 6000, 7000, 9000]. The elements in the list are 6 discrete values ​​selected from the exposure gain range (0, 10000).

[0109] For a certain environment brightness information (Gain, Luma), it can be composed of any element in the exposure gain list Gain List and any element in the brightness parameter list Luma List. For example, in the above example, (1,3000) is one settable environment brightness information, and (1,4000) is another settable environment brightness information.

[0110] Therefore, in the above example, it can be understood that the 13 exposure gains in the exposure gain list Gain List and the 6 brightness parameters in the brightness parameter list Luma List can constitute a total of 13*6=78 pieces of environmental brightness information.

[0111] Of course, those skilled in the art will appreciate that the above ambient brightness information list is only an example, and in other implementations, other values ​​suitable for implementation may be set, and the present disclosure does not limit this.

[0112] S420: for each piece of environmental brightness information, control the camera lens to move with a preset step length, and use the focus window to collect a focus image when each lens position is moved.

[0113] In the disclosed embodiment, after the preparation work of the aforementioned S410 is completed, the calibration process can be started. In some embodiments, the camera system can be fixed using auxiliary tools such as a tripod and a gimbal to avoid test errors caused by shaking. The object to be photographed needs to be set to a flat area scene without complex textures, and can be, for example, a solid color object, which can include, for example, a white wall, white paper, etc.

[0114] During the calibration process, the camera first needs to be given an ambient brightness information. In the example disclosed in the present disclosure, the ambient brightness information can be represented by the aforementioned exposure gain Gain and brightness parameter Luma. For ease of understanding, the following describes the process of calibrating to obtain the compensation coefficient given an ambient brightness information.

[0115] For example, in one example, an exposure gain of 1 is selected from the aforementioned exposure gain list Gain List [1, 2, 4, 8, 12, 16, 20, 30, 50, 70, 90, 140, 180], and a brightness parameter of 3000 is selected from the brightness parameter list Luma List [3000, 4000, 5000, 6000, 7000, 9000], so that the ambient brightness information given in this calibration process is Gain = 1, Luma = 3000.

[0116] Then the exposure gain Gain parameter in AE can be set to 1. However, since the brightness parameter Luma cannot be set directly, the exposure time can be adjusted under a fixed exposure gain Gain to set the brightness parameter Luma to 3000. Those skilled in the art can understand this and will not be elaborated in this disclosure.

[0117] After configuring the camera with the ambient brightness information, you can start controlling the camera lens to move with a preset step length. It can be understood that the lens is driven to move by the voice coil motor VCM, so controlling the voice coil motor VCM can drive the lens to move. In an example, assuming that the movement range of the lens position is 0 to 800, the preset step length can be set to 50, so that the lens moves from the initial position to the end position, and a total of 16 lens positions need to be moved.

[0118] Every time the lens moves to a certain position, a focused image can be captured using the focus window. The size of the focused image is the size of the focus window set above. For example, in one example, the focus window size is 500 pixels * 500 pixels, so that the focused image captured at each lens position is 500 pixels * 500 pixels.

[0119] S430, determining a focus value of each lens position based on the focus image, fitting a straight line equation between the lens position and the focus value according to the focus value of each lens position, and determining a compensation coefficient corresponding to the ambient brightness information based on the slope of the straight line equation.

[0120] In the embodiment of the present disclosure, when the lens moves a lens position, the focus value can be calculated based on the collected focus image, and the focus value is also the FV value. The calculation principle of the FV value is: convolution processing is performed on the focus image, and then the pixels of the feature map after convolution are summed. Those skilled in the art can undoubtedly understand this, and the present disclosure will not repeat it.

[0121] For example, in the previous example, given the ambient brightness information Gain = 1, Luma = 3000, the movement range of the lens position is 0 to 800, and the preset step length is 50. Therefore, each time the lens moves a preset step length, an FV value can be calculated, until the entire movement range is traversed, a total of 16 FV values ​​are obtained. Then, based on the corresponding points of these 16 discrete FV values ​​and the lens position, we can get, for example Figure 3 The relationship diagram shown. Of course, it can be understood that Figure 3 There are more than 16 discrete points in the example, which is only for illustrative purposes.

[0122] In getting Figure 3 After several discrete points are shown, a straight line equation between the lens position and the FV value under the current ambient brightness information can be obtained by straight line fitting. Figure 3 The straight line obtained by fitting several discrete points of the example can be shown as Figure 5 As shown, Figure 5 The equation of the straight line obtained by fitting is expressed as: y=k1x+b1, where y represents the FV value, k1 represents the slope of the straight line, x represents the lens position, and b1 represents the intercept.

[0123] It can be known from the above that the slope k1 of the linear equation is the compensation coefficient corresponding to the environment brightness information Gain=1, Luma=3000.

[0124] S440: Determine a compensation relationship according to a compensation coefficient corresponding to each piece of ambient brightness information.

[0125] The above S420~S430 only takes one ambient brightness information as an example to illustrate the process of calibrating the compensation coefficient. The above S420~S430 processes are repeated for other ambient brightness information in sequence until all ambient brightness information is traversed, thereby obtaining the compensation coefficient corresponding to each ambient brightness information.

[0126] For example, in the previous example, given the ambient brightness information is Gain = 1, Luma = 4000, repeating the above method process to calculate the corresponding compensation coefficient is k2. Given the ambient brightness information is Gain = 1, Luma = 5000, repeating the above method process to calculate the corresponding compensation coefficient is k3... and so on.

[0127] For example, in an example, after traversing all ambient brightness information, the compensation relationship obtained by calibration can be shown in the following Table 1:

[0128] Table 1

[0129]

[0130]

[0131] After the compensation relationship is obtained through calibration, the compensation relationship may be stored in the memory of the camera system or in the memory of the electronic device. The camera system may read the compensation relationship from its own memory or the memory of the electronic device.

[0132] 2) Autofocus stage

[0133] After completing the above compensation relationship calibration, automatic focusing can be performed based on the compensation relationship. Figure 6 Provide explanation.

[0134] like Figure 6 As shown, in some embodiments, the auto-focus method of the present disclosure example includes:

[0135] S610: During the camera focusing process, obtain the focus value and the ambient brightness information when the lens moves to each lens position.

[0136] Combination Figure 1 As can be seen from the example, the camera autofocus process is the process of finding the lens position corresponding to the maximum FV value. Therefore, during the camera focusing process, the voice coil motor VCM drives the lens to continuously move to each lens position, and uses the focus window to capture the focus image at each lens position, and calculates the FV value based on the focus image. For this process, those skilled in the art can undoubtedly understand and fully implement it with reference to the relevant technology, and this disclosure will not elaborate on it.

[0137] The difference between the disclosed implementation and the traditional autofocus algorithm is that when the lens moves to each lens position, in addition to calculating the corresponding FV value, it is also necessary to obtain the corresponding ambient brightness information at the lens position.

[0138] For example, in some embodiments of the present disclosure, the ambient brightness information can be represented by the aforementioned exposure gain Gain and brightness parameter Luma. The exposure gain Gain can be directly obtained by reading the Gain parameter of the current AE, and the brightness parameter Luma can be calculated based on the pixel value of the focused image.

[0139] For example, in an example, when the lens moves to a certain lens position, the focused image acquired by the focus window is 500 pixels * 500 pixels, and the brightness parameter Luma can be expressed as:

[0140] Luma=pixel_sum / pixel_num (1)

[0141] In formula (1), pixel_sum represents the sum of the pixel values ​​of all pixels in the focused image, and pixel_num represents the number of pixels in the focused image. That is, the brightness parameter Luma can be represented by the average pixel value of the focused image.

[0142] Taking a lens position as an example, the FV value and the ambient brightness information (Gain, Luma) of the lens position can be calculated through the above process.

[0143] S620: Determine a target compensation coefficient corresponding to the ambient brightness information of each lens position based on the ambient brightness information and a pre-calibrated compensation relationship.

[0144] In the embodiment of the present disclosure, still taking a lens position as an example, the corresponding ambient brightness information (Gain, Luma) under the lens position is obtained through the aforementioned S610, and then, based on the pre-calibrated compensation relationship, the compensation coefficient corresponding to the ambient brightness information can be determined, and the compensation coefficient is the target compensation coefficient.

[0145] For example, referring to Table 1 above, assuming that the ambient brightness information of a certain lens position is (Gain1, Luma1), the compensation coefficient corresponding to the current lens position can be determined to be k1 through the compensation relationship shown in Table 1, that is, the target compensation coefficient is k1.

[0146] It can be understood that the above only takes one lens position as an example. As the lens moves to other lens positions, the ambient brightness information changes with the lens position. The corresponding compensation coefficients can be found through the compensation relationship shown in Table 1.

[0147] It is worth noting that, in some implementations, the ambient brightness information in the compensation relationship is a discrete value, so that during the autofocus process, the ambient brightness information of a certain lens position may not be directly found from the compensation relationship shown in Table 1.

[0148] Therefore, in some implementations, two adjacent ambient brightness information can be first determined from the compensation relationship, and then the compensation relationship can be interpolated to obtain the target compensation coefficient corresponding to the ambient brightness information of the lens position. In the implementation of the present disclosure, the interpolation processing algorithm can adopt a linear interpolation algorithm. The specific principles and processes of the linear interpolation algorithm can be understood and fully implemented by those skilled in the art with reference to the relevant technology. Through the linear interpolation algorithm, it is possible to determine the target compensation coefficient corresponding to any ambient brightness information according to the discrete compensation coefficient, and the present disclosure will not elaborate on this.

[0149] S630: For each lens position, based on the position parameter corresponding to the lens position and the target compensation coefficient, the focus value is compensated to obtain a target focus value.

[0150] In the embodiment of the present disclosure, still taking a lens position as an example, the FV value and target compensation coefficient corresponding to the lens position can be obtained through the above method process. Combined with the above, it can be known that the target compensation coefficient can be understood as the slope of the linear equation of the FV value and the lens position under the condition of the ambient brightness information.

[0151] Therefore, in the embodiment of the present disclosure, the process of compensating the FV value based on the target compensation coefficient can be expressed as:

[0152] Compensated_FV = FV - coeff * lens_postion (2)

[0153] In formula (2), Compensated_FV represents the target focus value after compensation processing, FV represents the focus value calculated by the hardware in S610, coeff represents the target compensation coefficient, and lens_position represents the position parameter corresponding to the lens position, that is, the parameter of the current lens position.

[0154] Combining the above Figure 3 , Figure 5 As can be seen from the description, assuming that the ambient brightness information does not change during the lens movement, the FV values ​​corresponding to different lens positions obtained in the flat area scene should be the same or very close. In the embodiment of the present disclosure, as shown in formula (2), the initial FV value is compensated (-coeff*lens_position), which is equivalent to Figure 5 The k1x term is subtracted from the straight line equation shown, thereby correcting the incremental straight line compensation to an approximately horizontal straight line, thereby eliminating or alleviating the FV calculation error caused by the change in ambient brightness due to the change in lens position.

[0155] The above description only takes one lens position as an example. For other lens positions of the lens movement, the above-mentioned S610 to S630 method processes are repeated in sequence to achieve compensation of the FV value of each lens position and obtain the target focus value corresponding to each lens position.

[0156] S640: Determine the in-focus position of the lens based on the target focus values ​​of all lens positions during the focusing process.

[0157] In the embodiment of the present disclosure, after the FV value of each lens position is compensated through the above process, the target FV value corresponding to each lens position is obtained, so that Figure 1 The method process is similar. All lens positions are traversed to complete the focus scan, and the lens position corresponding to the largest target FV value is selected as the quasi-focus position. Figure 7 Provide explanation.

[0158] like Figure 7 As shown, in some embodiments, the process of determining the in-focus position in the auto-focus method of the present disclosure example includes:

[0159] S641. Based on the target focus values ​​corresponding to all lens positions during the focusing process, a relationship curve between the lens position and the target focus value is obtained by fitting.

[0160] S642: Based on the relationship curve, determine the lens position corresponding to the peak value of the target focus value as the in-focus position.

[0161] In the disclosed embodiment, during the focusing process, the voice coil motor VCM drives the lens to continuously move to the corresponding lens position. Each time the lens position is moved, the target FV value corresponding to the lens position can be calculated through the aforementioned method process.

[0162] and Figure 1 Similarly, in one example, during the process of the lens moving from lens position A to lens position D, the target FV value gradually increases, and then the target FV value decreases when the lens continues to move to lens position E. Then, the lens moves from lens position E to F, G, H, and D in sequence, and during the process of moving from lens position E to lens position H, the target FV value gradually increases, and then the target FV value decreases when the lens continues to move to lens position D.

[0163] Then, the corresponding relationship curve can be fitted according to the discrete target FV values ​​corresponding to the lens positions A to H, and the peak value of the target FV value can be determined according to the relationship curve. Then, the lens position corresponding to the peak value of the target FV value is determined as the final quasi-focus position, and the quasi-focus position is configured to the voice coil motor VCM, and the voice coil motor VCM is controlled to drive the lens to move to the quasi-focus position to complete the autofocus process.

[0164] From the above, it can be seen that in the embodiments of the present disclosure, during the autofocus process, a corresponding compensation coefficient is determined based on the ambient brightness information of each lens position, and the compensation coefficient is used to implement compensation correction of the FV value of the lens position, thereby eliminating or alleviating the FV calculation error caused by the change in ambient brightness due to lens movement, especially for weak texture focusing scenes, thereby improving the focusing effect and accuracy.

[0165] It is worth noting that in the autofocus method of the above-mentioned embodiment, only the FV calculation error caused by the change in ambient brightness caused by lens movement is compensated. In fact, in addition to the change in ambient brightness caused by lens movement during the autofocus process, there may be other factors that cause changes in ambient brightness. For example, the AE algorithm will also make real-time adjustments to brightness parameters (such as Gain, exposure time, etc.) during the focusing process, resulting in changes in ambient brightness, which in turn causes FV calculation errors.

[0166] Therefore, in some embodiments of the present disclosure, in the aforementioned S610, after obtaining the FV value corresponding to each lens position and before performing the compensation operation of S620, the FV value may be further normalized to normalize the FV values ​​of different lens positions to a similar brightness level, thereby further eliminating or alleviating the FV calculation error caused by the change in ambient brightness received by the photosensitive element. Figure 8 Provide explanation.

[0167] like Figure 8As shown, in some embodiments, the auto-focus method of the disclosed example further includes:

[0168] S810: For each lens position, determine a brightness parameter based on the sum of all pixel values ​​in the focus window and the number of pixels.

[0169] S820: For each lens position, normalize the focus value based on the brightness parameter to obtain a normalized focus value.

[0170] In combination with the above-mentioned S610, the ambient brightness information includes the brightness parameter Luma. When the lens moves to a certain lens position, based on the focus image acquired by the focus window, the brightness parameter Luma corresponding to the lens position can be calculated according to formula (1). That is, referring to formula (1), the brightness parameter Luma can be obtained by dividing the sum of the pixel values ​​of all pixels in the focus image by the number of pixels in the focus image.

[0171] Still taking the lens position as an example, after obtaining the brightness parameter Luma, the process of normalizing the FV value can be expressed as:

[0172] Normalized_FV=FV / Luma(3)

[0173] In formula (3), Normalized_FV represents the FV value after normalization processing, FV represents the focus value calculated by the hardware in S610, and Luma represents the brightness parameter.

[0174] After the original FV value is normalized to brightness by formula (3), the FV values ​​at different lens positions can be normalized to similar brightness levels, further eliminating or alleviating the FV calculation error caused by the change in ambient brightness received by the photosensitive element.

[0175] After the FV value is brightness normalized, the aforementioned method process of S620 to S640 may be continued to be executed to perform compensation processing on the focus value Normalized_FV after normalization processing. Those skilled in the art may understand it by referring to the aforementioned, and the present disclosure will not elaborate on it.

[0176] The above is only an example of the process of normalizing the FV value using one lens position as an example. For other lens positions, repeat the process in sequence. Figure 8 The method process is sufficient, and this disclosure will not elaborate on it.

[0177] From the above, it can be seen that in the embodiment of the present disclosure, during the autofocus process, the corresponding compensation coefficient is determined based on the ambient brightness information of each lens position, and the compensation coefficient is used to achieve compensation correction of the FV value of the lens position, thereby eliminating or alleviating the FV calculation error caused by the change in ambient brightness caused by the movement of the lens, especially for weak texture focus scenes, improving the focusing effect and accuracy. In addition, before the FV value is compensated, after the FV value is brightness normalized, the FV values ​​of different lens positions can be normalized to similar brightness levels, further eliminating or alleviating the FV calculation error caused by the change in ambient brightness received by the photosensitive element, and improving the autofocus effect.

[0178] In a second aspect, an embodiment of the present disclosure provides an autofocus device, which can be applied to a camera system or an electronic device having a camera system. The electronic device described in the present disclosure can be any type of device suitable for implementation, such as a smart phone, a tablet computer, a wearable device, a laptop computer, etc., and the present disclosure does not limit this.

[0179] like Fig. 9 As shown, in some embodiments, the auto-focusing device of the present disclosure example includes:

[0180] The FV acquisition module 10 is configured to acquire the focus value and the ambient brightness information when the lens moves to each lens position during the camera focusing process;

[0181] A compensation determination module 20 is configured to determine a target compensation coefficient corresponding to the ambient brightness information of each lens position based on the ambient brightness information and a pre-calibrated compensation relationship, wherein the compensation relationship represents a corresponding relationship between the ambient brightness information and the compensation coefficient of the focus value;

[0182] The compensation processing module 30 is configured to perform compensation processing on the focus value for each lens position based on the position parameter corresponding to the lens position and the target compensation coefficient to obtain a target focus value;

[0183] The focus determination module 40 is configured to determine the in-focus position of the lens based on the target focus values ​​of all lens positions during the focusing process.

[0184] In some implementations, the ambient brightness information includes a brightness parameter, and the FV acquisition module 10 is configured as follows:

[0185] For each lens position, determining the brightness parameter based on the sum of all pixel values ​​in the focus window and the number of pixels;

[0186] For each lens position, the focus value is normalized based on the brightness parameter to obtain a focus value after normalization.

[0187] In some implementations, the ambient brightness information includes a brightness parameter and an exposure gain, and the compensation determination module 20 is configured as follows:

[0188] Based on the brightness parameter and the exposure gain, the compensation relationship is interpolated to obtain the target compensation coefficient corresponding to the brightness parameter and the exposure gain.

[0189] In some embodiments, the compensation processing module 30 is configured to:

[0190] Based on the product of the target compensation coefficient and the position parameter, the focus value is compensated to obtain the target focus value.

[0191] In some implementations, the focus determination module 40 is configured to:

[0192] Based on the target focus values ​​corresponding to all lens positions during the focusing process, a relationship curve between the lens position and the target focus value is obtained by fitting;

[0193] Based on the relationship curve, a lens position corresponding to a peak value of the target focus value is determined as the in-focus position.

[0194] In some implementations, the auto-focusing device of the example of the present disclosure further includes a calibration module, and the calibration module is configured to:

[0195] Pre-configuring a focus window size and an ambient brightness information list, wherein the ambient brightness information list includes a plurality of different ambient brightness information;

[0196] For each piece of environmental brightness information, the camera lens is controlled to move with a preset step length, and a focus image is collected by using the focus window when each lens position is moved, wherein the focus image is an image of a pure color object;

[0197] Determine a focus value corresponding to each lens position based on the focus image, obtain a straight line equation between the lens position and the focus value according to the focus value of each lens position, and determine a compensation coefficient corresponding to the ambient brightness information based on the slope of the straight line equation;

[0198] The compensation relationship is determined according to the compensation coefficient corresponding to each piece of ambient brightness information.

[0199] In some embodiments, the ambient brightness information list includes a brightness parameter list and an exposure gain list, the brightness parameter list includes multiple brightness parameters, the exposure gain list includes multiple exposure gains, and the ambient brightness information includes any brightness parameter and any exposure gain.

[0200] From the above, it can be seen that in the embodiment of the present disclosure, during the autofocus process, the corresponding compensation coefficient is determined based on the ambient brightness information of each lens position, and the compensation coefficient is used to achieve compensation correction of the FV value of the lens position, thereby eliminating or alleviating the FV calculation error caused by the change in ambient brightness caused by the movement of the lens, especially for weak texture focus scenes, improving the focusing effect and accuracy. In addition, before the FV value is compensated, after the FV value is brightness normalized, the FV values ​​of different lens positions can be normalized to similar brightness levels, further eliminating or alleviating the FV calculation error caused by the change in ambient brightness received by the photosensitive element, and improving the autofocus effect.

[0201] In a third aspect, an embodiment of the present disclosure provides a camera system, including:

[0202] Lens;

[0203] an actuator for driving the lens to move during focusing; and

[0204] The controller includes a processor and a memory, wherein the memory stores computer instructions, and the computer instructions are used to enable the processor to execute the method described in any of the above embodiments.

[0205] In a fourth aspect, an embodiment of the present disclosure provides an electronic device, comprising the camera system described in any of the above embodiments.

[0206] In a fifth aspect, an embodiment of the present disclosure provides a storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in any of the above embodiments.

[0207] Fig.10 The structure block diagram of the electronic device in some embodiments of the present disclosure is shown in FIG. The electronic device may be any electronic device in the aforementioned embodiments. Fig.10 The principles related to electronic devices and storage media in some embodiments of the present disclosure are described.

[0208] Reference Fig.10 , the electronic device 1800 may include one or more of the following components: a processing component 1802 , a memory 1804 , a power component 1806 , a multimedia component 1808 , an audio component 1810 , an input / output (I / O) interface 1812 , a sensor component 1816 , and a communication component 1818 .

[0209] The processing component 1802 generally controls the overall operation of the electronic device 1800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1802 may include one or more processors 1820 to execute instructions. In addition, the processing component 1802 may include one or more modules to facilitate interaction between the processing component 1802 and other components. For example, the processing component 1802 may include a multimedia module to facilitate interaction between the multimedia component 1808 and the processing component 1802. For another example, the processing component 1802 may read executable instructions from a memory to implement electronic device related functions.

[0210] The memory 1804 is configured to store various types of data to support operations on the electronic device 1800. Examples of such data include instructions for any application or method operating on the electronic device 1800, contact data, phone book data, messages, pictures, videos, etc. The memory 1804 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 memory, flash memory, magnetic disk or optical disk.

[0211] The power supply component 1806 provides power to the various components of the electronic device 1800. The power supply component 1806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1800.

[0212] The multimedia component 1808 includes a display screen that provides an output interface between the electronic device 1800 and the user. In some embodiments, the multimedia component 1808 includes a front camera and / or a rear camera. When the electronic device 1800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0213] The audio component 1810 is configured to output and / or input audio signals. For example, the audio component 1810 includes a microphone (MIC), and when the electronic device 1800 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1804 or sent via the communication component 1818. In some embodiments, the audio component 1810 also includes a speaker for outputting audio signals.

[0214] I / O interface 1812 provides an interface between processing component 1802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0215] The sensor assembly 1816 includes one or more sensors for providing various aspects of status assessment for the electronic device 1800. For example, the sensor assembly 1816 can detect the open / closed state of the electronic device 1800, the relative positioning of components, such as the display and keypad of the electronic device 1800, and the sensor assembly 1816 can also detect the position change of the electronic device 1800 or a component of the electronic device 1800, the presence or absence of user contact with the electronic device 1800, the orientation or acceleration / deceleration of the electronic device 1800, and the temperature change of the electronic device 1800. The sensor assembly 1816 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1816 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1816 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0216] The communication component 1818 is configured to facilitate wired or wireless communication between the electronic device 1800 and other devices. The electronic device 1800 can access a wireless network based on a communication standard, such as Wi-Fi, 2G, 3G, 4G, 5G or 6G, or a combination thereof. In an exemplary embodiment, the communication component 1818 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1818 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0217] In an exemplary embodiment, the electronic device 1800 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.

[0218] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the embodiments. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.

Claims

1. An automatic focusing method, characterized in that: include: During the camera focusing process, the focus value and ambient brightness information are obtained when the lens moves to each lens position; Determining a target compensation coefficient corresponding to the ambient brightness information at each lens position based on the ambient brightness information and a pre-calibrated compensation relationship, wherein the compensation relationship represents a corresponding relationship between the ambient brightness information and the compensation coefficient of the focus value; For each lens position, based on the position parameter corresponding to the lens position and the target compensation coefficient, the focus value is compensated to obtain a target focus value; Based on the target focus values ​​of all lens positions during the focusing process, the in-focus position of the lens is determined.

2. The method according to claim 1, characterized in that The ambient brightness information includes a brightness parameter, and obtaining the ambient brightness information of each lens position includes: For each lens position, determining the brightness parameter based on the sum of all pixel values ​​in the focus window and the number of pixels; Before determining the target compensation coefficient corresponding to the ambient brightness at each lens position based on the ambient brightness and the pre-calibrated compensation relationship, the method further includes: For each lens position, the focus value is normalized based on the brightness parameter to obtain a focus value after normalization.

3. The method according to claim 1, characterized in that The ambient brightness information includes a brightness parameter and an exposure gain, and determining a target compensation coefficient corresponding to the ambient brightness information at each lens position based on the ambient brightness information and a pre-calibrated compensation relationship includes: Based on the brightness parameter and the exposure gain, the compensation relationship is interpolated to obtain the target compensation coefficient corresponding to the brightness parameter and the exposure gain.

4. The method according to claim 1, characterized in that: The compensating the focus value based on the position parameter corresponding to the lens position and the target compensation coefficient to obtain the target focus value includes: Based on the product of the target compensation coefficient and the position parameter, the focus value is compensated to obtain the target focus value.

5. The method according to claim 1, characterized in that The determining the in-focus position of the lens based on the target focus value of all lens positions during the focusing process includes: Based on the target focus values ​​corresponding to all lens positions during the focusing process, a relationship curve between the lens position and the target focus value is obtained by fitting; Based on the relationship curve, a lens position corresponding to a peak value of the target focus value is determined as the in-focus position.

6. The method according to any one of claims 1 to 5, characterized in that: The compensation relationship is calibrated in the following manner: Pre-configuring a focus window size and an ambient brightness information list, wherein the ambient brightness information list includes a plurality of different ambient brightness information; For each piece of environmental brightness information, the camera lens is controlled to move with a preset step length, and a focus image is collected by using the focus window when each lens position is moved, wherein the focus image is an image of a pure color object; Determine a focus value corresponding to each lens position based on the focus image, obtain a straight line equation between the lens position and the focus value according to the focus value of each lens position, and determine a compensation coefficient corresponding to the ambient brightness information based on the slope of the straight line equation; The compensation relationship is determined according to the compensation coefficient corresponding to each piece of ambient brightness information.

7. The method according to claim 6, characterized in that The ambient brightness information list includes a brightness parameter list and an exposure gain list, the brightness parameter list includes multiple brightness parameters, the exposure gain list includes multiple exposure gains, and the ambient brightness information includes any brightness parameter and any exposure gain.

8. An automatic focusing device, characterized in that: include: The FV acquisition module is configured to acquire the focus value and the ambient brightness information when the lens moves to each lens position during the camera focusing process; a compensation determination module configured to determine a target compensation coefficient corresponding to the ambient brightness information of each lens position based on the ambient brightness information and a pre-calibrated compensation relationship, wherein the compensation relationship represents a corresponding relationship between the ambient brightness information and the compensation coefficient of the focus value; A compensation processing module is configured to, for each lens position, perform compensation processing on the focus value based on a position parameter corresponding to the lens position and the target compensation coefficient to obtain a target focus value; The focus determination module is configured to determine the in-focus position of the lens based on the target focus values ​​of all lens positions during the focusing process.

9. A camera system, characterized in that: include: Lens; An actuator, used to drive the lens to move during focusing; as well as A controller comprises a processor and a memory, wherein the memory stores computer instructions, and the computer instructions are used to enable the processor to execute the method according to any one of claims 1 to 7.

10. An electronic device, characterized in that: Comprising a camera system according to claim 9.

11. A storage medium, characterized in that: Computer instructions are stored, and the computer instructions are used to make a computer execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Automatic focusing system and automatic focusing method

    CN101344702A

  • System and method for executing automatic focusing in low-brightness scene

    CN102096174A

  • Device and method for generating lens shading compensation table suitable for photographic environment

    CN102281389A

  • Camera auto-focus apparatus and method

    CN108333849A

  • Focusing control method and device, image sensor, electronic equipment and computer readable storage medium

    CN113891006A