Focusing method and device, electronic device, computer readable storage medium
By masking part of the pixel area in the color interpolation area of the photosensitive area of the photoelectric sensor of the camera device to obtain the phase difference and adjust the focus, the contradiction between the phase focusing speed and the imaging quality is solved, and fast focusing and high-quality imaging are achieved.
Patent Information
- Application Number
- CN202211287599.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-20
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-10-20
AI Technical Summary
While existing camera devices have improved focusing speed, their imaging quality is relatively poor, especially the phase focusing method causes part of the light signal to be blocked, affecting the imaging effect.
The color interpolation area in the photosensitive area of the photoelectric sensor of the camera device is used as the target area, and part or all of the pixel area is blocked to obtain the phase difference of the light signal, and the focus is adjusted according to the phase difference to avoid affecting the imaging effect.
While improving the focusing speed, the imaging quality of the camera device is guaranteed, and the focusing accuracy is improved through the comprehensive calculation of multiple phase differences.
Smart Images

Figure CN115696040B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of photography, in particular to a focusing method and device, electronic equipment and computer readable storage medium. BACKGROUND
[0002] Nowadays, the camera usually realizes automatic focusing through contrast focusing or phase focusing, thereby reducing the operation steps of the user.
[0003] However, it is found in practice that the focusing speed of contrast focusing is slow, and the phase focusing with relatively fast focusing speed will result in poor imaging quality of the camera. In this regard, it is found that a focusing method which can improve the focusing speed and ensure the imaging quality has become an urgent problem to be solved. SUMMARY
[0004] The embodiments of the present application disclose a focusing method and device, electronic equipment and computer readable storage medium, which can improve the focusing speed while ensuring the imaging quality of the camera.
[0005] The first aspect of the embodiments of the present application discloses a focusing method, comprising:
[0006] obtaining a first phase difference between light signals respectively collected by each two matched first pixel regions in a target region, the target region being part or all of a color interpolation region included in a photosensitive region of a photosensitive sensor of a camera, the light signals collected by the color interpolation region being used for color interpolation calculation, and part of the two matched first pixel regions being shielded respectively, so that the light signals respectively passing through the two first pixel regions have a phase difference;
[0007] adjusting the focus of the camera according to the first phase difference.
[0008] As an optional implementation, in the first aspect of the embodiments of the present application, the photosensitive region further includes an imaging region, and the light signals collected by the imaging region are used for generating an image; before adjusting the focus of the camera according to the first phase difference, the method further comprises:
[0009] obtaining a second phase difference between light signals respectively collected by each two matched second pixel regions in the imaging region, and part of the two matched second pixel regions being shielded respectively;
[0010] and the adjusting the focus of the camera according to the first phase difference comprises:
[0011] adjusting the focus of the camera according to the first phase difference and the second phase difference.
[0012] As an optional embodiment, in the first aspect of the embodiment of the present application, the imaging area includes at least two matching second pixel areas, and the total area of the at least two matching second pixel areas is less than or equal to the area of the imaging area.
[0013] As an optional implementation, in the first aspect of the embodiment of the present application, the imaging area is located at the center of the photosensitive area, and the target area is an annular area surrounding the imaging area.
[0014] As an optional embodiment, in the first aspect of the embodiment of the present application, the imaging area is a rectangular area, and the target area includes at least a first sub-area, a second sub-area, a third sub-area and a fourth sub-area, the first sub-area and the second sub-area each consist of at least one row of first pixel areas, the first sub-area is located above the imaging area, the second sub-area is located below the imaging area, the third sub-area and the fourth sub-area each consist of at least two columns of first pixel areas, the third sub-area is located to the left of the imaging area, and the fourth sub-area is located to the right of the imaging area.
[0015] As an optional implementation manner, in the first aspect of the embodiment of the present application, there are multiple first phase differences, and adjusting the focus of the shooting device according to the first phase differences includes:
[0016] A target average value between a plurality of the first phase differences is calculated, and the focus of the photographing device is adjusted according to the target average value.
[0017] As an optional implementation manner, in the first aspect of the embodiment of the present application, calculating the average value between the multiple first phase differences includes:
[0018] Assigning a corresponding first weight to each of the first phase differences, and determining a first weighted average value based on the plurality of first phase differences and the first weights corresponding to the respective first phase differences, wherein the closer the two first pixel regions corresponding to the first phase differences are to the center of the photosensitive region, the greater the first weight corresponding to the first phase difference;
[0019] The first weighted average value is used as a target average value among the plurality of first phase differences.
[0020] As an optional implementation manner, in the first aspect of the embodiment of the present application, adjusting the focus of the shooting device according to the first phase difference includes:
[0021] If the first phase difference is less than or equal to a target threshold, then the focus of the camera is not adjusted;
[0022] If the first phase difference is greater than a target threshold, the focus of the photographing device is adjusted until the first phase difference is less than or equal to the target threshold.
[0023] A second aspect of an embodiment of the present application discloses a focusing device, comprising:
[0024] a first acquisition unit, configured to acquire a first phase difference between light signals respectively collected by each two matching first pixel regions in a target area, wherein the target area is part or all of a color interpolation area included in a photosensitive area of a photosensor of the imaging device, and the light signals collected by the color interpolation area are used for color interpolation calculation, and wherein each of the two matching first pixel regions has a partially obscured area, so that a phase difference exists between the light signals respectively passing through the two first pixel regions;
[0025] An adjusting unit is configured to adjust the focus of the photographing device according to the first phase difference.
[0026] A third aspect of the present application discloses an electronic device, including:
[0027] a memory storing executable program code;
[0028] a processor coupled to the memory;
[0029] The processor calls the executable program code stored in the memory to execute the focusing method disclosed in the first aspect of the embodiment of the present application.
[0030] A fourth aspect of an embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the focusing method disclosed in the first aspect of the embodiment of the present application.
[0031] The fifth aspect of the embodiments of the present application discloses a computer program product. When the computer program product is run on a computer, the computer is caused to execute part or all of the steps of any one of the methods of the first aspect of the embodiments of the present application.
[0032] The sixth aspect of the embodiments of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes part or all of the steps of any one of the methods of the first aspect of the embodiments of the present application.
[0033] Compared with the related art, the embodiments of the present application have the following beneficial effects:
[0034] In an embodiment of the present application, part or all of a color interpolation region included in a photosensitive area of a photosensor of a camera device can be used as a target region. The target region includes a first pixel region, wherein two matching first pixel regions each have a portion of the region obscured, so that there is a phase difference between the light signals passing through the two first pixel regions. The focus of the camera device can then be determined based on the first phase difference. In this embodiment of the present application, the obscured first pixel region is located in the color interpolation region, and the light signals collected through the color interpolation region are only used for color interpolation calculations and do not affect subsequent imaging effects. This improves focusing speed while maintaining the imaging quality of the camera device. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 is a schematic diagram of a phase focusing disclosed in an embodiment of the present application;
[0037] Figure 2 is a schematic diagram of another phase focusing disclosed in an embodiment of the present application;
[0038] Figure 3 This is a flowchart of a focusing method disclosed in an embodiment of the present application;
[0039] Figure 4 This is a flowchart of a focusing method disclosed in an embodiment of the present application;
[0040] Figure 5 is a schematic diagram of a photosensitive area disclosed in an embodiment of the present application;
[0041] Figure 6 This is a flowchart of a focusing method disclosed in an embodiment of the present application;
[0042] Figure 7 is a structural schematic diagram of a focusing device disclosed in an embodiment of the present application;
[0043] Figure 8 This is a structural diagram of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0045] It should be noted that the terms "first," "second," "third," and "fourth" in the specification and claims of this application are used to distinguish different objects rather than to describe a specific order. The terms "including" and "having," as well as any variations thereof, in the embodiments of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or are inherent to these processes, methods, products, or apparatuses.
[0046] The embodiments of the present application disclose a focusing method and device, an electronic device, and a computer-readable storage medium, which can improve the focusing speed while ensuring the imaging quality of the camera device.
[0047] The technical solution of this application will be described in detail below with reference to specific embodiments.
[0048] In order to more clearly illustrate a focusing method and device, electronic device, and computer-readable storage medium disclosed in the embodiments of the present application. First, the focusing technology in the related art is introduced. In the related art, focusing technology includes contrast focusing, phase focusing, etc.; among them, contrast focusing is to detect the contrast of the image captured by the photoelectric sensor of the camera device, and then determine the position with the largest contrast in the image as the focus. However, searching for the position with the largest contrast usually requires detecting each pixel point of the entire image one by one, which requires a large amount of calculation, resulting in a slow focusing speed.
[0049] The other is phase focusing, see Figure 1 , Figure 1 is a schematic diagram of a phase focusing disclosed in an embodiment of the present application. Optionally, the photosensitive area of the photoelectric sensor of the camera device may include multiple pixel areas. It should be noted that a pixel area is the area occupied by a pixel point in the photosensitive area, such as Figure 1 In order to make the light signal passing through the photosensitive area form a phase difference, it is necessary to shield part of one of the pixel areas ( Figure 1 The black part in the middle of the pixel is masked by another adjacent pixel area, thereby obtaining complete phase difference information. Figure 1The A pixel region 110 and the B pixel region 120 are partially shielded, and thus the light signal L1 and the light signal L2 will form a phase difference 130 after passing through the A pixel region 110 and the B pixel region 120 respectively. Figure 1 If the phase difference 130 is significantly greater than 0, it can be determined that the focus is inaccurate, and the camera device can perform a focus adjustment operation. Figure 2 , Figure 2 This is a schematic diagram of another phase focusing disclosed in an embodiment of the present application. If the phase difference 140 is 0, it can be determined that the focus is accurate, and the current focus position is used as the focus.
[0050] Compared with contrast focusing, phase focusing requires less calculation and thus has a faster focusing speed. However, in practice, it is found that although focusing is faster using phase focusing, masking part of the pixel area in the photosensitive area will cause part of the light signal to be blocked, which will affect the subsequent imaging quality of the camera device.
[0051] To this end, in an embodiment of the present application, part or all of a color interpolation region included in a photosensitive region of a photosensor of an imaging device may be used as a target region, wherein a portion of a first pixel region, including the first pixel region, is obscured. In other words, the obscured first pixel region is located in the color interpolation region, and the light signal collected by the color interpolation region is only used for color interpolation calculations and does not affect subsequent imaging effects. Furthermore, since the first phase difference can be determined based on the target region, the imaging region in the photosensitive region may no longer be provided with partially obscured pixel regions, or the number of partially obscured pixel regions provided in the imaging region may be reduced, thereby improving focusing speed while maintaining imaging quality of the imaging device.
[0052] Based on this, the focusing method disclosed in the embodiments of the present application is introduced below.
[0053] See also Figure 3 , Figure 3 : is a flowchart of a focusing method disclosed in an embodiment of the present application. Optionally, the method may include the following steps:
[0054] 302. Obtain a first phase difference between light signals respectively collected by each two matching first pixel areas in the target area, where the target area is part or all of a color interpolation area included in a light-sensitive area of a photoelectric sensor of a camera device, and light signals collected by the color interpolation area are used to perform color interpolation calculations. Part of each of the two matching first pixel areas is obscured.
[0055] In the embodiment of the present application, the camera device may include a monocular camera, a binocular camera, or a wide-angle camera, etc., which is not limited here. The camera device may include a photoelectric sensor, which is used to collect light signals, and then the processor of the camera device can perform imaging operations based on the collected light signals.
[0056] Among them, the photoelectric sensor may include a photosensitive area for receiving light signals; the photosensitive area may include a color interpolation area. After the light signal is collected by the color interpolation area and sent to the processor, the processor can perform color difference calculation based on the light signal to determine the hue value of the image.
[0057] It should be noted that for RGB images, it is usually necessary to obtain the RGB colors, that is, the three colors of red, green and blue, on a pixel at the same time to determine the hue value of the pixel. In the related art, filters are usually used for acquisition, that is, the red filter transmits the red wavelength, the green filter transmits the green wavelength, and the blue filter transmits the blue wavelength. In this regard, if the RGB value of a pixel is obtained at the same time, three filters are required, which is expensive and difficult to manufacture, because the three filters must ensure that each pixel is aligned, in order to simplify the production process and reduce production costs. In this regard, the related art introduces a color interpolation method, that is, each pixel only outputs the hue value of one color through one filter, and the hue values of the other two colors are obtained by color interpolation calculation using the hue values of adjacent pixels. For example, a first pixel, a second pixel, and a third pixel are adjacent; wherein the first pixel outputs a red hue value, the second pixel outputs a green hue value, and the third pixel outputs a blue hue value; then the green hue value and the blue hue value of the first pixel can be calculated by color interpolation using the green hue value output by the second pixel and the blue hue value output by the third pixel. Optionally, the color interpolation calculation method may include bilinear interpolation, constant color ratio method, gradient-based algorithm, or adaptive interpolation method, etc., which are not limited here.
[0058] As can be seen, the light signals collected by the color interpolation region are primarily used to determine the hue value of the pixel points. Even if a portion of the pixel area in the color interpolation region is masked, it will not affect the subsequent processor's determination of the hue value of the pixel area. In other words, masking a portion of the pixel area in the color interpolation region will not affect the subsequent imaging effect.
[0059] Optionally, in the embodiment of the present application, part or all of the color interpolation area can be used as the target area, and the target area includes one or more pairs of matching first pixel areas, and part of the two matching first pixel areas are respectively shielded; then, when the light signal passes through the two matching first pixel areas, as described above Figure 1According to the principle shown, the first phase difference between the light signals respectively collected by the two matching first pixel areas can be obtained.
[0060] It should be further explained that the light signal collected by the first pixel area in the target area can also be used to perform color interpolation calculation to improve the accuracy of the subsequently determined hue value.
[0061] 304. Adjust the focus of the camera according to the first phase difference.
[0062] See also Figure 2 In an ideal state, if the focus is accurate, the projection positions of the light signals on the photosensitive area after passing through the two matching first pixel areas are completely overlapped, that is, the first phase difference is 0. On the contrary, if the first phase difference is not 0, it means that the focus is inaccurate.
[0063] In practice, it has been found that due to variations in the size and shape of components such as the photoelectric sensors in an imaging device, the position where the light signal is projected onto the photosensitive area may also vary slightly. This means that even with accurate focus, the projected positions of the light signal on the photosensitive area after passing through two matching first pixel areas may not completely overlap, resulting in a phase difference.
[0064] Alternatively, when the acquired first phase difference is less than or equal to a target threshold, the focus may be determined to be accurate, and the camera device may not adjust the focus. Alternatively, the target threshold may be set by a developer based on extensive development experience or by a user based on actual usage needs, and is not limited here.
[0065] Optionally, if the first phase difference is greater than the target threshold, it can be determined that the focus is inaccurate. The camera device can adjust the focus through the zoom module and reacquire a new first phase difference until the new first phase difference is less than or equal to the target threshold, and determine that the focus is accurate.
[0066] By implementing the methods disclosed in the above embodiments, part or all of a color interpolation region included in the photosensitive area of the photoelectric sensor of the camera device can be used as a target area. The target area includes a first pixel region, wherein two matching first pixel regions each have a partially obscured area, so that there is a phase difference between the light signals passing through the two first pixel regions. The focus of the camera device can then be determined based on the first phase difference. In this embodiment of the present application, the obscured first pixel region is located in the color interpolation region, and the light signals collected through the color interpolation region are only used for color interpolation calculations and do not affect subsequent imaging effects. This improves focusing speed while maintaining the imaging quality of the camera device.
[0067] See also Figure 4 , Figure 4 : is a flowchart of a focusing method disclosed in an embodiment of the present application. Optionally, the method may include the following steps:
[0068] 402. Obtain a first phase difference between light signals respectively collected by each two matching first pixel areas in the target area, where the target area is part or all of a color interpolation area included in a light-sensitive area of a photoelectric sensor of a camera device, and light signals collected by the color interpolation area are used to perform color interpolation calculations. Part of each of the two matching first pixel areas is obscured.
[0069] 404 . Obtain a second phase difference between light signals collected by every two matching second pixel regions in the imaging area.
[0070] As an optional embodiment, the photosensitive area of the photosensor may further include an imaging area; the light signal collected by the imaging area is used to generate an image. It will be appreciated that the more phase differences acquired, the more reference factors that can be used to determine whether focus is accurate, and the higher the accuracy of the subsequent determination of focus accuracy.
[0071] Alternatively, the partially matched second pixel areas in the imaging area can be partially masked so that there is a phase difference between the light signals passing through the two second pixel areas. A second phase difference can then be obtained between the light signals collected by each two matching second pixel areas in the imaging area. The principle for obtaining the second phase difference is similar to that for obtaining the first phase difference described above and will not be elaborated on here. The focus of the camera can then be adjusted based on the first and second phase differences to improve focusing accuracy.
[0072] It is understood that the second phase difference requires the light signals collected by at least two matching second pixel areas to be determined. Optionally, the imaging area may include at least two matching second pixel areas. Optionally, the total area of the at least two matching second pixel areas may be smaller than the area of the imaging area. It is understood that part of the second pixel area is blocked, so the light signal collected by the second pixel area is incomplete, which will affect the subsequent imaging quality. To this end, part of the imaging area can be blocked as the second pixel area to ensure the subsequent imaging effect as quickly as possible while improving the focusing accuracy.
[0073] Optionally, the total area of the at least two matching second pixel regions may be equal to the area of the imaging region, so that more second phase differences can be acquired subsequently, thereby improving the focusing accuracy.
[0074] As an optional implementation, the imaging area may be located at the center of the photosensitive area, and the target area may be an annular area surrounding the imaging area.
[0075] When implementing the above method, since the target area is an annular area surrounding the imaging area located at the center of the photosensitive area, the first pixel areas in the target area can be distributed in various directions of the photosensitive area, thereby avoiding the situation where the first pixel areas are all in the same direction, and improving the reference value of the first phase difference subsequently determined based on the first pixel areas.
[0076] See also Figure 5 , Figure 5 Schematic diagram of a photosensitive area disclosed in an embodiment of the present application. Optionally, the imaging area 510 may be a rectangular area, and the target area may include at least a first sub-area 520, a second sub-area 530, a third sub-area 540, and a fourth sub-area 550. The first sub-area 520 and the second sub-area 530 may each be composed of at least one row of first pixel regions, the first sub-area 520 may be located above the imaging area 510, the second sub-area 530 may be located below the imaging area 510, the third sub-area 540 and the fourth sub-area 550 may each be composed of at least two columns of first pixel regions, the third sub-area 540 may be located to the left of the imaging area 510, and the fourth sub-area 550 may be located to the right of the imaging area 510.
[0077] It should be noted that Figure 5 The first sub-region 520 and the second sub-region 530 may each consist of a row of first pixel regions, and the third sub-region 540 and the fourth sub-region 550 may each consist of two columns of first pixel regions for illustration, which should not constitute a limitation to the embodiments of the present application.
[0078] Since the first phase difference requires at least two horizontally adjacent first pixel areas to be determined, optionally, the third sub-area 540 and the fourth sub-area 550 located in the left and right directions of the imaging area 510 can each be composed of at least two columns of first pixel areas, so that the first phase difference corresponding to the third sub-area 540 and the fourth sub-area 550 can be determined subsequently; and since the first pixel areas in the first sub-area 520 and the second sub-area 530 can be arranged horizontally, at least one row of first pixel areas can determine the first phase difference corresponding to the first sub-area 520 and the second sub-area 530, respectively.
[0079] By implementing the above method, if the first sub-region 520 and the second sub-region 530 can each be composed of a row of first pixel regions, and the third sub-region 540 and the fourth sub-region 550 can each be composed of two columns of first pixel regions, then the computational complexity of the processor of the shooting device can be reduced as much as possible while determining the first phase difference of the target region.
[0080] As an optional embodiment, a third phase difference can be determined based on the light signal collected by the first pixel area included in the first sub-area 520; and, a fourth phase difference can be determined based on the light signal collected by the first pixel area included in the second sub-area 530; and, a fifth phase difference can be determined based on the light signal collected by the first pixel area included in the third sub-area 540; and, a sixth phase difference can be determined based on the light signal collected by the first pixel area included in the fourth sub-area 550.
[0081] Furthermore, a second average value of the second phase difference, the third phase difference, the fourth phase difference, the fifth phase difference and the sixth phase difference corresponding to the imaging area may be calculated, and the focus of the shooting device may be adjusted according to the second average value.
[0082] By implementing the above method, the focus of the shooting device can be adjusted by the average value of the phase difference of the light signals collected at different positions in the photosensitive area, thereby improving the accuracy of adjusting the focus.
[0083] It should be noted that Figure 5 The illustrations are only provided for the convenience of explanation and should not be construed as limiting the embodiments of the present application.
[0084] 406. Adjust the focus of the photographing device according to the first phase difference and the second phase difference.
[0085] Optionally, the focus of the camera may be adjusted according to the first phase difference, or according to the second phase difference. In another embodiment, the average of the first phase difference and the second phase difference may be calculated, and the focus of the camera may be adjusted according to the average.
[0086] The method of adjusting the focus of the camera according to the second phase difference or the average of the first and second phase differences is similar to the method of adjusting the focus of the camera according to the first phase difference, and is not limited here.
[0087] By implementing the above method, the focus of the shooting device can be adjusted in combination with the first phase difference of the target area and the second phase difference of the imaging area; and since the reference factors for determining whether the focus is accurate are increased, the accuracy of subsequent determination of whether the focus is accurate is improved.
[0088] Optionally, a corresponding second weight can be assigned to each first phase difference and second phase difference, and then a second weighted average value can be determined based on the first phase difference, the second phase difference, and the second weights corresponding to each first phase difference and second phase difference. The closer the two first pixel regions corresponding to each first phase difference are to the center of the photosensitive area, the greater the second weight corresponding to the first phase difference; and the closer the two second pixel regions corresponding to each second phase difference are to the center of the photosensitive area, the greater the second weight corresponding to the second phase difference. The focus of the camera can then be adjusted based on the second weighted average value.
[0089] Since the phase difference collected based on the pixel area closer to the center of the photosensitive area is more accurate, the phase difference collected based on the pixel area closer to the center of the photosensitive area can be given a higher weight, and then the above method can be implemented to improve the accuracy of subsequent adjustment of the focus of the shooting device based on the second weighted average value.
[0090] In implementing the methods disclosed in the above embodiments, the masked first pixel area is located in the color interpolation area, and the light signal collected through the color interpolation area is only used for color interpolation calculation and does not affect the subsequent imaging effect, thereby improving the focusing speed while ensuring the imaging quality of the camera device; further, the focus of the camera device can be adjusted according to the first phase difference and the second phase difference to improve the focusing accuracy; further, a portion of the imaging area can be masked as the second pixel area to ensure the subsequent imaging effect as quickly as possible while improving the focusing accuracy; further, because the target area is an annular area surrounding the imaging area located at the center of the photosensitive area, the first pixel areas in the target area can be distributed in various directions of the photosensitive area, thereby avoiding the situation where the first pixel areas are all in the same direction, and improving the reference value of the first phase difference subsequently determined based on the first pixel areas; further, the focus of the camera device can be adjusted by taking the average value of the phase difference of the light signals collected at different positions in the photosensitive area, thereby improving the accuracy of the focus adjustment.
[0091] See also Figure 6 , Figure 6 : is a flowchart of a focusing method disclosed in an embodiment of the present application. Optionally, the method may include the following steps:
[0092] 602. Obtain a first phase difference between light signals respectively collected by each two matching first pixel areas in the target area, where the target area is part or all of a color interpolation area included in a light-sensitive area of a photoelectric sensor of a camera device, and light signals collected by the color interpolation area are used to perform color interpolation calculations. Part of each of the two matching first pixel areas is obscured.
[0093] Optionally, the ratio of the target area to the color interpolation area may be positively correlated with the computing performance of the camera's processor. Specifically, the higher the computing performance of the camera's processor, the larger the ratio of the target area to the color interpolation area. Conversely, the lower the computing performance of the camera's processor, the smaller the ratio of the target area to the color interpolation area.
[0094] Alternatively, the ratio of the target area to the color interpolation area can be determined based on the computing performance of the camera's processor, where the processor's computing performance determines the processor's maximum computational effort. This allows for obtaining as many first phase differences as possible without damaging the camera's processor, thereby improving the accuracy of subsequent focus adjustment of the camera based on the first phase differences.
[0095] In another embodiment, the ratio of the target area to the color interpolation area may be negatively correlated with the focusing speed. That is, the larger the ratio of the target area to the color interpolation area, the slower the focusing speed; conversely, the smaller the ratio of the target area to the color interpolation area, the faster the focusing speed.
[0096] Alternatively, the ratio of the target area to the color interpolation area can be determined based on the focus speed set by the user, thereby ensuring that the focus speed meets the user's needs as much as possible while ensuring the imaging quality of the camera device.
[0097] In one embodiment, the current shooting scene of the camera device may be acquired, and the ratio of the target area to the color interpolation area may be adjusted according to the shooting scene.
[0098] Optionally, if the current shooting scene of the camera device is a code scanning scene, for example, scanning a QR code, scanning a barcode, etc.; since the code scanning scene requires a faster focusing speed and does not require very good imaging quality, the ratio of the target area area to the color interpolation area area can be reduced to increase the focusing speed.
[0099] Optionally, if the current shooting scene of the camera device is a portrait or landscape shooting scene, the ratio of the target area to the color interpolation area can be increased to improve the imaging quality of the camera device.
[0100] By implementing the above method, the ratio of the target area to the color interpolation area can be adjusted according to the current shooting scene of the camera device, so that the focusing speed and imaging quality of the camera device are consistent with the current shooting scene, thereby improving the user experience.
[0101] 604、Calculate a target average value among the plurality of first phase differences, and adjust the focus of the photographing apparatus according to the target average value.
[0102] Optionally, the matched first pixel region in the light sensing region can have multiple pairs, and the first phase difference acquired for each pair can be different. It can be understood that, since the multiple pairs of matched first pixel regions are located at different positions in the light sensing region, the refraction angle of the light signal passing through the first pixel regions at different positions can be different, and the multiple first phase differences acquired can be different. A target average value among the multiple first phase differences can be calculated, and the focus of the photographing apparatus can be adjusted according to the target average value, thereby improving the accuracy of subsequent focus adjustment.
[0103] As an optional implementation, a corresponding first weight can be assigned to each first phase difference, and a first weighted average value can be determined according to the multiple first phase differences and the first weight corresponding to each first phase difference, wherein the closer the two first pixel regions corresponding to the first phase difference are to the center of the light sensing region, the greater the first weight corresponding to the first phase difference is. The first weighted average value can be taken as the target average value among the multiple first phase differences, and the focus of the photographing apparatus can be adjusted according to the target average value.
[0104] Since the phase difference acquired according to the pixel region closer to the center of the light sensing region is more accurate, a higher weight can be assigned to the phase difference acquired according to the pixel region closer to the center of the light sensing region, and the accuracy of subsequent adjustment of the focus of the photographing apparatus according to the first weighted average value can be improved by implementing the above method.
[0105] By implementing the method disclosed in each of the above embodiments, the first pixel region that is shielded is located in the color interpolation region, and the light signal acquired through the color interpolation region is only used for color interpolation calculation and does not affect the subsequent imaging effect, so that the imaging quality of the photographing apparatus can be ensured while the focusing speed is improved; the ratio of the target region area to the color interpolation region area can be adjusted according to the photographing scene in which the photographing apparatus is currently located, so that the focusing speed and the imaging quality of the photographing apparatus meet the current photographing scene, thereby improving the user experience; a target average value among the multiple first phase differences can be calculated, and the focus of the photographing apparatus can be adjusted according to the target average value, thereby improving the accuracy of subsequent focus adjustment.
[0106] Please refer to Figure 7 , Figure 7 is a structural schematic diagram of a focusing device disclosed by the embodiments of the present application. Optionally, the device can include a first acquisition unit 702 and an adjustment unit 704, wherein:
[0107] A first acquisition unit 702 is configured to acquire a first phase difference between light signals respectively collected by each two matching first pixel regions in a target area, where the target area is part or all of a color interpolation area included in a photosensitive area of a photosensor of the imaging device, and the light signals collected by the color interpolation area are used for color interpolation calculation. Partial areas of each of the two matching first pixel regions are obscured, resulting in a phase difference between the light signals respectively passing through the two first pixel regions.
[0108] The adjusting unit 704 is configured to adjust the focus of the camera according to the first phase difference.
[0109] By implementing the above-described device, a color interpolation region included in the photosensitive area of the photoelectric sensor of the imaging device can be partially or entirely used as a target region. The target region includes a first pixel region, wherein two matching first pixel regions each have a partially obscured region, so that a phase difference exists between the light signals passing through the two first pixel regions. The focus of the imaging device can then be determined based on the first phase difference. In this embodiment of the present application, the obscured first pixel region is located in the color interpolation region, and the light signals collected through the color interpolation region are only used for color interpolation calculations and do not affect subsequent imaging effects. This improves focusing speed while maintaining the imaging quality of the imaging device.
[0110] As an optional embodiment, the photosensitive area may further include an imaging area, and the light signal collected by the imaging area is used to generate an image; Figure 7 The device shown may further include a second acquisition unit (not shown), wherein:
[0111] a second acquisition unit, configured to acquire, before adjusting the focus of the camera according to the first phase difference, a second phase difference between light signals respectively collected by each two matching second pixel regions in the imaging area, wherein each of the two matching second pixel regions has a partially obscured area;
[0112] The adjustment unit is further configured to adjust the focus of the photographing device according to the first phase difference and the second phase difference.
[0113] By implementing the above device, the second phase difference between the light signals collected by each two matching second pixel areas in the imaging area can be obtained, and the focus of the shooting device can be adjusted according to the first phase difference and the second phase difference to improve the focusing accuracy.
[0114] As an optional implementation, the imaging area includes at least two matching second pixel areas, and the total area of the at least two matching second pixel areas is smaller than or equal to the area of the imaging area.
[0115] By implementing the above device, a portion of the imaging area can be shielded as the second pixel area, so as to ensure the subsequent imaging effect as quickly as possible while improving the focusing accuracy.
[0116] As an optional implementation, the imaging area is located at the center of the photosensitive area, and the target area is an annular area surrounding the imaging area.
[0117] When implementing the above-mentioned device, since the target area is an annular area surrounding the imaging area located at the center of the photosensitive area, the first pixel areas in the target area can be distributed in various directions of the photosensitive area, thereby avoiding the situation where the first pixel areas are all in the same direction, and improving the reference value of the first phase difference subsequently determined based on the first pixel areas.
[0118] As an optional embodiment, the imaging area is a rectangular area, and the target area includes at least a first sub-area, a second sub-area, a third sub-area and a fourth sub-area, the first sub-area and the second sub-area each consist of at least one row of first pixel areas, the first sub-area is located above the imaging area, the second sub-area is located below the imaging area, the third sub-area and the fourth sub-area each consist of at least two columns of first pixel areas, the third sub-area is located to the left of the imaging area, and the fourth sub-area is located to the right of the imaging area.
[0119] By implementing the above device, the focus of the shooting device can be adjusted by the average value of the phase difference of the light signals collected at different positions in the photosensitive area, thereby improving the accuracy of adjusting the focus.
[0120] As an optional implementation, there are multiple first phase differences; and the adjustment unit 704 is further configured to calculate a target average value among the multiple first phase differences, and adjust the focus of the shooting device according to the target average value.
[0121] By implementing the above device, a target average value between multiple first phase differences can be calculated, and then the focus of the shooting device can be adjusted according to the target average value, thereby improving the accuracy of subsequent focus adjustment.
[0122] As an optional embodiment, the adjustment unit 704 is also used to assign a corresponding first weight to each first phase difference, and determine a first weighted average value based on multiple first phase differences and the first weights corresponding to each first phase difference, wherein, the closer the two first pixel areas corresponding to the first phase difference are to the center of the photosensitive area, the greater the first weight corresponding to the first phase difference; and, the first weighted average value is used as the target average value between multiple first phase differences.
[0123] By implementing the above device, a higher weight can be assigned to the phase difference collected from the pixel area closer to the center of the photosensitive area, and further implementing the above method can improve the accuracy of subsequent adjustment of the focus of the shooting device according to the first weighted average value.
[0124] As an optional embodiment, the adjustment unit 704 is also used to not adjust the focus of the shooting device when the first phase difference is less than or equal to the target threshold; and, when the first phase difference is greater than the target threshold, adjust the focus of the shooting device until the first phase difference is less than or equal to the target threshold.
[0125] By implementing the above device, it is possible to determine whether the focus of the camera device is aligned based on the first phase difference, so as to improve the focusing speed while ensuring the imaging quality of the camera device.
[0126] See also Figure 8 , Figure 8 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application. Figure 8 As shown, the electronic device may include:
[0127] A memory 801 storing executable program code;
[0128] a processor 802 coupled to the memory 801;
[0129] The processor 802 calls the executable program code stored in the memory 801 to execute the focusing method disclosed in the above embodiments.
[0130] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the focusing method disclosed in the above embodiments.
[0131] An embodiment of the present application further discloses an application publishing platform, wherein the application publishing platform is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes part or all of the steps of the method in the above method embodiments.
[0132] It should be understood that the references to "one embodiment" or "an embodiment" throughout the specification mean that the specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present application. Therefore, the references to "in one embodiment" or "in an embodiment" throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present application.
[0133] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0134] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one place or distributed across multiple network units. Some or all of these units may be selected based on actual needs to achieve the objectives of this embodiment.
[0135] In addition, the functional units in the embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0136] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a memory and includes several requests for a computer device (which can be a personal computer, server or network device, etc., specifically a processor in a computer device) to execute some or all of the steps of the above-mentioned methods of various embodiments of the present application.
[0137] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0138] The above is a detailed introduction to a focusing method and device, electronic device, and computer-readable storage medium disclosed in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A focusing method, characterized in that: The method comprises: Obtaining a first phase difference between light signals respectively collected by each two matching first pixel regions in a target area, where the target area is part or all of a color interpolation area included in a photosensitive area of a photosensor of a camera device, and light signals collected by the color interpolation area are used for color interpolation calculation, and where portions of the two matching first pixel regions are respectively blocked, resulting in a phase difference between the light signals respectively passing through the two first pixel regions; adjusting the focus of the photographing device according to the first phase difference; The photosensitive area further includes an imaging area, and the light signal collected by the imaging area is used to generate an image. The imaging area includes at least two matching second pixel areas, and the total area of the at least two matching second pixel areas is less than or equal to the area of the imaging area. The imaging area is located at the center of the photosensitive area, and the target area is an annular area surrounding the imaging area. Before adjusting the focus of the shooting device according to the first phase difference, the method further includes: Acquire a second phase difference between light signals respectively collected by every two matching second pixel regions in the imaging area, where each of the two matching second pixel regions has a partially obscured area; Furthermore, adjusting the focus of the photographing device according to the first phase difference includes: The focus of the photographing device is adjusted according to the first phase difference and the second phase difference.
2. The method according to claim 1, characterized in that The imaging area is a rectangular area, and the target area includes at least a first sub-area, a second sub-area, a third sub-area and a fourth sub-area. The first sub-area and the second sub-area each consist of at least one row of first pixel areas. The first sub-area is located above the imaging area, and the second sub-area is located below the imaging area. The third sub-area and the fourth sub-area each consist of at least two columns of first pixel areas. The third sub-area is located to the left of the imaging area, and the fourth sub-area is located to the right of the imaging area.
3. The method according to claim 1, characterized in that There are multiple first phase differences, and adjusting the focus of the shooting device according to the first phase differences includes: A target average value between a plurality of the first phase differences is calculated, and the focus of the photographing device is adjusted according to the target average value.
4. The method according to claim 3, characterized in that The calculating an average value of the plurality of first phase differences comprises: Assigning a corresponding first weight to each of the first phase differences, and determining a first weighted average value based on the plurality of first phase differences and the first weights corresponding to the respective first phase differences, wherein the closer the two first pixel regions corresponding to the first phase differences are to the center of the photosensitive region, the greater the first weight corresponding to the first phase difference; The first weighted average value is used as a target average value among the plurality of first phase differences.
5. The method according to claim 1, wherein The adjusting the focus of the photographing device according to the first phase difference includes: If the first phase difference is less than or equal to a target threshold, then the focus of the camera is not adjusted; If the first phase difference is greater than a target threshold, the focus of the photographing device is adjusted until the first phase difference is less than or equal to the target threshold.
6. A focusing device, characterized in that: The device comprises: a first acquisition unit, configured to acquire a first phase difference between light signals respectively collected by each two matching first pixel regions in a target area, wherein the target area is part or all of a color interpolation area included in a photosensitive area of a photosensor of a camera, and the light signals collected by the color interpolation area are used for color interpolation calculation, and wherein each of the two matching first pixel regions has a partially obscured area, so that a phase difference exists between the light signals respectively passing through the two first pixel regions; The photosensitive area further includes an imaging area, and light signals collected by the imaging area are used to generate an image. The imaging area includes at least two matching second pixel areas, and the total area of the at least two matching second pixel areas is less than or equal to the area of the imaging area. The imaging area is located at the center of the photosensitive area, and the target area is an annular area surrounding the imaging area. The device further includes: a second acquisition unit, configured to acquire a second phase difference between light signals respectively collected by every two matching second pixel areas in the imaging area before adjusting the focus of the shooting device according to the first phase difference, wherein each of the two matching second pixel areas has a partially obscured area. An adjusting unit is configured to adjust the focus of the photographing device according to the first phase difference and the second phase difference.
7. An electronic device, characterized in that: The method comprises a memory storing executable program code and a processor coupled to the memory; wherein the processor calls the executable program code stored in the memory to execute the method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Focusing method and device, electronic equipment and computer readable storage medium
CN112866552A
Focusing control method and device thereof, imaging equipment, electronic equipment and computer readable storage medium
CN113660415A