Movatterモバイル変換


[0]ホーム

URL:


CN112866551B - Focusing method and device, electronic equipment and computer readable storage medium - Google Patents

Focusing method and device, electronic equipment and computer readable storage medium
Download PDF

Info

Publication number
CN112866551B
CN112866551BCN201911102669.0ACN201911102669ACN112866551BCN 112866551 BCN112866551 BCN 112866551BCN 201911102669 ACN201911102669 ACN 201911102669ACN 112866551 BCN112866551 BCN 112866551B
Authority
CN
China
Prior art keywords
phase difference
image
difference value
target
focusing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911102669.0A
Other languages
Chinese (zh)
Other versions
CN112866551A (en
Inventor
颜光宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp LtdfiledCriticalGuangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201911102669.0ApriorityCriticalpatent/CN112866551B/en
Publication of CN112866551ApublicationCriticalpatent/CN112866551A/en
Application grantedgrantedCritical
Publication of CN112866551BpublicationCriticalpatent/CN112866551B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

Translated fromChinese

本申请涉及一种对焦方法和装置、电子设备、计算机可读存储介质,通过获取第一拍摄姿态对应的检测图像的第一相位差值和第二相位差值,根据两个相位差各自对应的置信度确定电子设备的对焦方式;当对焦方式为相位检测自动对焦时,检测电子设备的第二拍摄姿态及其相对于第一拍摄姿态的偏转数据;根据偏转数据、第一相位差值和第二相位差值确定目标方向及对应的目标相位差;根据目标相位差控制电子设备进行对焦。本申请根据电子设备的偏转数据和两个相位差的置信度确定出目标方向及其对应的目标相位差值,无需重新计算电子设备发生角度偏转后的两个方向的相位差值,降低了对焦算法的计算复杂度,提升了电子设备处于偏转姿态的对焦速率。

Figure 201911102669

The present application relates to a focusing method and device, an electronic device, and a computer-readable storage medium. By acquiring a first phase difference value and a second phase difference value of a detected image corresponding to a first shooting attitude, according to the corresponding phase differences of the two phase differences The confidence determines the focusing mode of the electronic device; when the focusing mode is phase detection autofocus, the second shooting posture of the electronic device and its deflection data relative to the first shooting posture are detected; according to the deflection data, the first phase difference value and the first shooting posture; The two phase difference values determine the target direction and the corresponding target phase difference; the electronic device is controlled to focus according to the target phase difference. In the present application, the target direction and its corresponding target phase difference value are determined according to the deflection data of the electronic device and the confidence of the two phase differences, and there is no need to recalculate the phase difference value of the two directions after the angle deflection of the electronic device occurs, which reduces the focus The computational complexity of the algorithm improves the focusing rate of the electronic device in the deflection attitude.

Figure 201911102669

Description

Translated fromChinese
对焦方法和装置、电子设备、计算机可读存储介质Focusing method and apparatus, electronic device, computer-readable storage medium

技术领域technical field

本申请涉及影像领域,特别是涉及一种对焦方法和装置、电子设备、计算机可读存储介质。The present application relates to the field of imaging, and in particular, to a focusing method and device, an electronic device, and a computer-readable storage medium.

背景技术Background technique

在拍摄图像时,为了保证图像拍摄清晰,通常需要对电子设备进行对焦,所谓对焦指的是调节镜头与图像传感器之间的距离的过程。当前,比较常见的对焦方式包括相位检测自动对焦(英文:phase detection auto focus;简称:PDAF)。When capturing an image, in order to ensure that the image is clearly captured, it is usually necessary to focus the electronic device. The so-called focusing refers to the process of adjusting the distance between the lens and the image sensor. Currently, a relatively common focusing method includes phase detection auto focus (English: phase detection auto focus; PDAF for short).

相关技术中,为了进行相位检测自动对焦,通常可以在图像传感器包括的像素点中成对地设置一些相位检测像素点(也可称为遮蔽像素点),其中,每个相位检测像素点对中的一个相位检测像素点进行左侧遮挡,另一个相位检测像素点进行右侧遮挡,这样,就可以将射向每个相位检测像素点对的成像光束分离成左右两个部分,通过对比左右两部分成像光束所成的像,即可得到相位差,在得到相位差后即可根据该相位差进行对焦,这里所谓的相位差指的是从不同方向射入的成像光线在成像位置上的差异。In the related art, in order to perform phase-detection auto-focusing, some phase-detection pixels (also referred to as shading pixels) can usually be set in pairs among the pixels included in the image sensor, wherein each phase-detection pixel is centered. One phase detection pixel is occluded on the left, and the other phase detection pixel is occluded on the right. In this way, the imaging beam directed to each phase detection pixel pair can be separated into two parts, left and right. By comparing the left and right The phase difference can be obtained from the image formed by part of the imaging beam. After the phase difference is obtained, focusing can be performed according to the phase difference. The so-called phase difference here refers to the difference in the imaging position of the imaging light entering from different directions. .

然而,当电子设备的拍摄角度产生偏转时,需要重新利用上述相位检测像素点方式获取两个方向的相位差,导致对焦速率低。However, when the shooting angle of the electronic device is deflected, it is necessary to re-use the above-mentioned phase detection pixel method to obtain the phase difference between the two directions, resulting in a low focusing rate.

发明内容SUMMARY OF THE INVENTION

本申请实施例提供一种对焦方法、装置、电子设备、计算机可读存储介质,可以提高对焦的准确度。The embodiments of the present application provide a focusing method, an apparatus, an electronic device, and a computer-readable storage medium, which can improve the focusing accuracy.

一种对焦方法,应用于电子设备,所述电子设备包括图像传感器,所述图像传感器包括阵列排布的多个像素点组,每个所述像素点组包括阵列排布的 M*N个像素点;每个像素点对应一个感光单元,其中,M和N均为大于或等于 2的自然数,所述方法包括:A focusing method, applied to an electronic device, the electronic device comprising an image sensor, the image sensor comprising a plurality of pixel point groups arranged in an array, each of the pixel point groups comprising M*N pixels arranged in an array point; each pixel corresponds to a photosensitive unit, wherein M and N are both natural numbers greater than or equal to 2, and the method includes:

获取第一拍摄姿态对应的检测图像的相位差值,所述相位差值包括第一方向的第一相位差值和第二方向的第二相位差值,所述第一方向与所述第二方向成预设夹角;Obtain a phase difference value of the detection image corresponding to the first shooting attitude, where the phase difference value includes a first phase difference value in a first direction and a second phase difference value in a second direction, the first direction and the second phase difference value The direction is a preset angle;

根据所述第一相位差值对应的第一置信度和所述第二相位差值对应的第二置信度确定所述电子设备的对焦方式;Determine the focusing mode of the electronic device according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value;

当所述对焦方式为相位检测自动对焦时,检测所述电子设备的第二拍摄姿态,获取所述第二拍摄姿态相对于所述第一拍摄姿态的偏转数据;When the focusing mode is phase detection auto-focusing, detecting a second shooting posture of the electronic device, and acquiring deflection data of the second shooting posture relative to the first shooting posture;

根据所述偏转数据、所述第一相位差值和所述第二相位差值确定目标方向,获取所述第二拍摄姿态对应的目标图像中所述目标方向对应的目标相位差;Determine the target direction according to the deflection data, the first phase difference value and the second phase difference value, and obtain the target phase difference corresponding to the target direction in the target image corresponding to the second shooting posture;

根据所述目标相位差控制所述电子设备进行对焦。The electronic device is controlled to focus according to the target phase difference.

13.一种对焦装置,其特征在于,应用于电子设备,所述电子设备包括图像传感器,所述图像传感器包括阵列排布的多个像素点组,每个所述像素点组包括阵列排布的M*N个像素点;每个像素点对应一个感光单元,其中,M和N 均为大于或等于2的自然数,所述对焦装置包括:13. A focusing device, characterized in that it is applied to an electronic device, the electronic device comprising an image sensor, the image sensor comprising a plurality of pixel point groups arranged in an array, each of the pixel point groups comprising an array arrangement M*N pixels; each pixel corresponds to a photosensitive unit, wherein, M and N are both natural numbers greater than or equal to 2, and the focusing device includes:

第一获取模块,用于获取第一拍摄姿态对应的检测图像的相位差值,所述相位差值包括第一方向的第一相位差值和第二方向的第二相位差值,所述第一方向与所述第二方向成预设夹角;The first acquisition module is configured to acquire the phase difference value of the detected image corresponding to the first shooting attitude, the phase difference value includes the first phase difference value in the first direction and the second phase difference value in the second direction, the first phase difference value A direction forms a preset angle with the second direction;

第一确定模块,用于根据所述第一相位差值对应的第一置信度和所述第二相位差值对应的第二置信度确定所述电子设备的对焦方式;a first determining module, configured to determine the focusing mode of the electronic device according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value;

第二获取模块,用于根据所述第一相位差值对应的第一置信度和所述第二相位差值对应的第二置信度确定所述电子设备的对焦方式;a second acquiring module, configured to determine the focusing mode of the electronic device according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value;

第二确定模块,用于根据所述偏转数据、所述第一相位差值和所述第二相位差值确定目标方向,并获取所述第二拍摄姿态对应的目标图像中所述目标方向对应的目标相位差;The second determination module is configured to determine the target direction according to the deflection data, the first phase difference value and the second phase difference value, and obtain the target direction corresponding to the target image in the target image corresponding to the second shooting posture The target phase difference of ;

对焦模块,用于根据所述目标相位差控制所述电子设备进行对焦。A focusing module, configured to control the electronic device to focus according to the target phase difference.

一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行如所述的对焦方法的步骤。An electronic device includes a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the focusing method.

一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如所述对焦方法的步骤。A computer-readable storage medium on which a computer program is stored, the computer program implementing the steps of the focusing method when executed by a processor.

上述对焦方法和装置、电子设备、计算机可读存储介质,通过获取第一拍摄姿态对应的检测图像的相位差值,所述相位差值包括第一方向的第一相位差值和第二方向的第二相位差值,根据所述第一相位差值对应的第一置信度和所述第二相位差值对应的第二置信度确定所述电子设备的对焦方式;当所述对焦方式为相位检测自动对焦时,检测所述电子设备的第二拍摄姿态,获取所述第二拍摄姿态相对于所述第一拍摄姿态的偏转数据;根据所述偏转数据、所述第一相位差值和所述第二相位差值确定目标方向,获取所述第二拍摄姿态对应的目标图像中所述目标方向对应的目标相位差;根据所述目标相位差控制所述电子设备进行对焦。本申请提供的方案根据电子设备的偏转数据和两个相位差的置信度确定出目标方向并获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差值,无需重新计算电子设备发生角度偏转后的两个方向的相位差值,降低了对焦算法的计算复杂度,提升了电子设备发生角度偏转时的对焦速率。The above-mentioned focusing method and device, electronic device, and computer-readable storage medium obtain the phase difference value of the detected image corresponding to the first shooting attitude, and the phase difference value includes the first phase difference value in the first direction and the phase difference value in the second direction. For the second phase difference value, the focusing mode of the electronic device is determined according to the first confidence degree corresponding to the first phase difference value and the second confidence degree corresponding to the second phase difference value; when the focusing mode is phase When detecting auto focus, the second shooting posture of the electronic device is detected, and the deflection data of the second shooting posture relative to the first shooting posture is obtained; according to the deflection data, the first phase difference value and the The second phase difference value is used to determine the target direction, and the target phase difference corresponding to the target direction in the target image corresponding to the second shooting posture is acquired; and the electronic device is controlled to focus according to the target phase difference. The solution provided by this application determines the target direction according to the deflection data of the electronic device and the confidence of the two phase differences, and obtains the target phase difference value corresponding to the target direction in the target image corresponding to the second shooting posture, without recalculating the angle of occurrence of the electronic device The phase difference value in the two directions after the deflection reduces the computational complexity of the focusing algorithm and improves the focusing rate when the electronic device is angularly deflected.

附图说明Description of drawings

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.

图1为相位检测自动对焦的原理示意图;Figure 1 is a schematic diagram of the principle of phase detection autofocus;

图2为在图像传感器包括的像素点中成对地设置相位检测像素点的示意图;2 is a schematic diagram of setting phase detection pixels in pairs in pixels included in an image sensor;

图3为一个实施例中图像传感器的部分结构示意图;3 is a schematic diagram of a partial structure of an image sensor in one embodiment;

图4为一个实施例中像素点的结构示意图;4 is a schematic structural diagram of a pixel point in one embodiment;

图5为一个实施例中成像设备的结构示意图;5 is a schematic structural diagram of an imaging device in one embodiment;

图6为一个实施例中像素点组上设置滤光片的示意图;6 is a schematic diagram of a filter set on a pixel point group in one embodiment;

图7为一个实施例中对焦方法的流程图;7 is a flow chart of a focusing method in one embodiment;

图8为一个实施例中步骤据偏转角度、第一相位差值对应的第一置信度和第二相位差值对应的第二置信度从第一方向和第二方向中确定出目标方向的流程图;FIG. 8 is a process of determining the target direction from the first direction and the second direction according to the deflection angle, the first confidence degree corresponding to the first phase difference value, and the second confidence degree corresponding to the second phase difference value in one embodiment. picture;

图9为一个实施例中步骤:根据检测图像的场景信息获取第一置信度和第二置信度的流程图;9 is a flowchart of steps in one embodiment: obtaining a first confidence level and a second confidence level according to scene information of a detected image;

图10为一个实施例中步骤:获取检测图像的相位差值的流程图;10 is a flow chart of steps in one embodiment: acquiring the phase difference value of the detected image;

图11为一个实施例中步骤:步骤根据第一切分图像和第二切分图像对应的相位关系获取第一相位差值和根据第三切分图像和第四切分图像对应的相位关系获取第二相位差值的流程图;Fig. 11 shows the steps in one embodiment: the step is to obtain the first phase difference value according to the phase relationship corresponding to the first segmented image and the second segmented image, and to obtain the phase relationship corresponding to the third segmented image and the fourth segmented image. The flow chart of the second phase difference value;

图12为一个实施例中对焦装置的结构框图;12 is a structural block diagram of a focusing device in one embodiment;

图13为一个实施例中电子设备的框图。Figure 13 is a block diagram of an electronic device in one embodiment.

具体实施方式Detailed ways

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application.

可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本申请的范围的情况下,可以将第一方向称为第二方向,且类似地,可将第二方向称为第一方向。第一方向和第二方向两者都是方向,但其不是同一方向。It will be understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, a first direction could be termed a second direction, and, similarly, a second direction could be termed a first direction, without departing from the scope of this application. Both the first direction and the second direction are directions, but they are not the same direction.

在拍摄图像时,为了保证运动物体的图像拍摄清晰,通常需要对电子设备进行对焦,对焦指的是当目标摄像头对拍摄对象进行对焦之后,在后续的拍摄过程中保持对拍摄对象的对焦的过程。例如,在电子设备拍摄图像的预览过程中,对拍摄对象进行对焦之后,在后续获取的预览图像中仍然保持对拍摄对象的对焦,则获取的预览图像中的拍摄对象仍是清晰的成像。所谓“对焦”指的是调节电子设备的镜头与图像传感器之间的距离,从而使图像传感器成像清晰的过程。其中,相位检测自动对焦(英文:phase detection autofocus;简称:PDAF) 是一种比较常见的自动对焦技术。When shooting images, in order to ensure clear images of moving objects, it is usually necessary to focus the electronic equipment. Focusing refers to the process of maintaining focus on the subject during subsequent shooting processes after the target camera focuses on the subject. . For example, in the preview process of the image captured by the electronic device, after focusing on the subject, the subject still remains in focus in the subsequently acquired preview image, and the subject in the acquired preview image is still clearly imaged. The so-called "focusing" refers to the process of adjusting the distance between the lens of the electronic device and the image sensor, so as to make the image of the image sensor clear. Among them, phase detection autofocus (English: phase detection autofocus; PDAF for short) is a relatively common autofocus technology.

下面,本申请实施例将对PDAF技术的原理进行简要说明。Below, the embodiment of the present application will briefly describe the principle of the PDAF technology.

图1为相位检测自动对焦(phase detection auto focus,PDAF)的原理示意图。如图1所示,M1为电子设备处于合焦状态时,图像传感器所处的位置,其中,合焦状态指的是成功对焦的状态。当图像传感器位于M1位置时,由物体 W反射向镜头Lens的不同方向上的成像光线g在图像传感器上会聚,也即是,由物体W反射向镜头Lens的不同方向上的成像光线g在图像传感器上的同一位置处成像,此时,图像传感器成像清晰。FIG. 1 is a schematic diagram of the principle of phase detection auto focus (PDAF). As shown in FIG. 1 , M1 is the position of the image sensor when the electronic device is in the in-focus state, where the in-focus state refers to the state of successful focusing. When the image sensor is located at the M1 position, the imaging rays g reflected by the object W in different directions to the lens converge on the image sensor, that is, the imaging rays g reflected by the object W in different directions to the lens are in the image The image is imaged at the same position on the sensor, and at this time, the image of the image sensor is clear.

M2和M3为电子设备不处于合焦状态时,图像传感器所可能处于的位置,如图1所示,当图像传感器位于M2位置或M3位置时,由物体W反射向镜头 Lens的不同方向上的成像光线g会在不同的位置成像。请参考图1,当图像传感器位于M2位置时,由物体W反射向镜头Lens的不同方向上的成像光线g在位置A和位置B分别成像,当图像传感器位于M3位置时,由物体W反射向镜头Lens的不同方向上的成像光线g在位置C和位置D分别成像,此时,图像传感器成像不清晰。M2 and M3 are the possible positions of the image sensor when the electronic device is not in focus. As shown in Figure 1, when the image sensor is at the M2 position or the M3 position, the object W reflects on the lens in different directions. The imaging ray g will be imaged at different positions. Please refer to Fig. 1, when the image sensor is located at the M2 position, the imaging light g reflected by the object W in different directions to the lens is imaged at the position A and the position B respectively. When the image sensor is located at the M3 position, the object W is reflected to Imaging rays g in different directions of the lens are imaged at positions C and D respectively, and at this time, the image of the image sensor is not clear.

在PDAF技术中,可以获取从不同方向射入镜头的成像光线在图像传感器中所成的像在位置上的差异,例如,如图1所示,可以获取位置A和位置B的差异,或者,获取位置C和位置D的差异;在获取到从不同方向射入镜头的成像光线在图像传感器中所成的像在位置上的差异之后,可以根据偏转数据、以及摄像机中镜头与图像传感器之间的几何关系,得到离焦距离,所谓离焦距离指的是图像传感器当前所处的位置与合焦状态时图像传感器所应该处于的位置的距离;电子设备可以根据得到的离焦距离进行对焦。In PDAF technology, the difference in position of the image formed by the imaging light entering the lens from different directions in the image sensor can be obtained. For example, as shown in Figure 1, the difference between position A and position B can be obtained, or, Obtain the difference between the position C and the position D; after obtaining the difference in the position of the image formed by the imaging light entering the lens from different directions in the image sensor, it can be determined according to the deflection data and the difference between the lens and the image sensor in the camera. The so-called defocus distance refers to the distance between the current position of the image sensor and the position where the image sensor should be in the in-focus state; the electronic device can focus according to the obtained defocus distance.

由此可知,合焦时,计算得到的PD值为0,反之算出的值越大,表示离合焦点的位置越远,值越小,表示离合焦点越近。采用PDAF对焦时,通过计算出PD值,再根据标定得到PD值与离焦距离之间的对应关系,可以求得离焦距离,然后根据离焦距离控制镜头移动达到合焦点,以实现对焦。It can be seen that when focusing is achieved, the calculated PD value is 0. On the contrary, the larger the calculated value, the farther the position of the clutch focus is, and the smaller the value, the closer the clutch focus is. When PDAF is used for focusing, by calculating the PD value, and then obtaining the corresponding relationship between the PD value and the defocusing distance according to the calibration, the defocusing distance can be obtained, and then the lens movement can be controlled according to the defocusing distance to achieve the focus, so as to achieve focusing.

相关技术中,可以在图像传感器包括的像素点中成对地设置一些相位检测像素点,如图2所示,图像传感器中可以设置有相位检测像素点对(以下称为像素点对)A,像素点对B和像素点对C。其中,在每个像素点对中,一个相位检测像素点进行左侧遮挡(英文:LeftShield),另一个相位检测像素点进行右侧遮挡(英文:Right Shield)。In the related art, some phase detection pixel points may be set in pairs in the pixel points included in the image sensor. As shown in FIG. 2, the image sensor may be provided with a phase detection pixel point pair (hereinafter referred to as a pixel point pair) A, Pixel pair B and pixel pair C. Among them, in each pixel point pair, one phase detection pixel point performs left occlusion (English: LeftShield), and the other phase detection pixel point performs right occlusion (English: Right Shield).

对于进行了左侧遮挡的相位检测像素点而言,射向该相位检测像素点的成像光束中仅有右侧的光束才能在该相位检测像素点的感光部分(也即是未被遮挡的部分)上成像,对于进行了右侧遮挡的相位检测像素点而言,射向该相位检测像素点的成像光束中仅有左侧的光束才能在该相位检测像素点的感光部分 (也即是未被遮挡的部分)上成像。这样,就可以将成像光束分为左右两个部分,通过对比左右两部分成像光束所成的像,即可得到相位差。For the phase detection pixel that has been blocked on the left side, only the right beam of the imaging light beam directed to the phase detection pixel point can reach the photosensitive part (that is, the unblocked part) of the phase detection pixel point. ), for the phase detection pixel that has been blocked on the right side, only the left beam of the imaging beam directed to the phase detection pixel can be in the photosensitive part of the phase detection pixel (that is, not occluded part). In this way, the imaging beam can be divided into left and right parts, and the phase difference can be obtained by comparing the images formed by the left and right imaging beams.

然而,由于图像传感器中设置的相位检测像素点通常较为稀疏,因此,通过相位检测像素点只能获取到水平的相位差,无法计算水平纹理的场景,计算得到的PD值会产生混淆而得不出正确的结果,例如拍摄场景为一条水平线,根据PD特性会得到左右两张图像,但无法计算出PD值。However, since the phase detection pixels set in the image sensor are usually sparse, only the horizontal phase difference can be obtained through the phase detection pixels, and the horizontal texture cannot be calculated in the scene, and the calculated PD value will be confused and cannot be obtained. The correct result is obtained. For example, the shooting scene is a horizontal line, and the left and right images will be obtained according to the PD characteristics, but the PD value cannot be calculated.

为了解决相位检测自动对焦针对一些水平纹理的场景无法计算得出PD值实现对焦的情况,本申请实施例中提供了一种成像组件,可以用来检测输出第一相位差值和第二相位差值,针对水平纹理场景,可采用第二相位差值来实现对焦。In order to solve the situation that the phase detection autofocus cannot calculate the PD value to achieve focusing for some horizontal textured scenes, the embodiment of the present application provides an imaging component, which can be used to detect and output the first phase difference value and the second phase difference value value, for horizontal texture scenes, the second phase difference value can be used to achieve focus.

在一个实施例中,本申请提供了一种成像组件。成像组件包括图像传感器。图像传感器可以为金属氧化物半导体元件(英文:Complementary Metal Oxide Semiconductor;简称:CMOS)图像传感器、电荷耦合元件(英文:Charge-coupled Device;简称:CCD)、量子薄膜传感器或者有机传感器等。In one embodiment, the present application provides an imaging assembly. The imaging assembly includes an image sensor. The image sensor may be a metal-oxide-semiconductor (Complementary Metal Oxide Semiconductor; CMOS for short) image sensor, a charge-coupled device (Charge-coupled Device; CCD for short), a quantum thin film sensor, an organic sensor, or the like.

图3为一个实施例中图像传感器的一部分的结构示意图。图像传感器300 包括阵列排布的多个像素点组Z,每个像素点组Z包括阵列排布的多个像素点 D,每个像素点D对应一个感光单元。每个像素点D包括阵列排布的多个子像素点d。也就是每个感光单元可以由多个阵列排布的感光元件组成。其中,感光元件是一种能够将光信号转化为电信号的元件。在一个实施例中,感光元件可为光电二极管。本实施例中,每个像素点组Z包括2*2阵列排布的4个像素点 D,每个像素点可包括2*2阵列排布的4个子像素点d。其中,每个像素点组形成2*2PD,可以直接接收光信号,进行光电转换,可以同时输出左右和上下的信号。每个颜色通道可以由4个子像素点组成。FIG. 3 is a schematic structural diagram of a portion of an image sensor in one embodiment. The image sensor 300 includes a plurality of pixel point groups Z arranged in an array, each pixel point group Z includes a plurality of pixel points D arranged in an array, and each pixel point D corresponds to a photosensitive unit. Each pixel point D includes a plurality of sub-pixel points d arranged in an array. That is, each photosensitive unit may be composed of a plurality of photosensitive elements arranged in an array. Among them, the photosensitive element is an element that can convert optical signals into electrical signals. In one embodiment, the photosensitive element may be a photodiode. In this embodiment, each pixel point group Z includes 4 pixel points D arranged in a 2*2 array, and each pixel point may include 4 sub-pixel points d arranged in a 2*2 array. Among them, each pixel point group forms 2*2PD, which can directly receive optical signals, perform photoelectric conversion, and output left and right and up and down signals at the same time. Each color channel can be composed of 4 sub-pixels.

如图4所示,以每个像素点包括子像素点1、子像素点2、子像素点3和子像素点4为例,可将子像素点1和子像素点2合成,子像素点3和子像素点4 合成,形成上下方向的PD像素对,检测水平边缘,得到第二相位差值,即竖直方向的PD值;将子像素点1和子像素点3合成,子像素点2和子像素点4合成,形成左右方向的PD像素对,可以检测竖直边缘,得到第一相位差值,即水平方向的PD值。As shown in Figure 4, taking each pixel point includingsub-pixel point 1,sub-pixel point 2,sub-pixel point 3 andsub-pixel point 4 as an example,sub-pixel point 1 andsub-pixel point 2 can be synthesized, andsub-pixel point 3 andsub-pixel point 2 can be synthesized. Pixel points 4 are synthesized to form PD pixel pairs in the up and down direction, and the horizontal edge is detected to obtain the second phase difference value, that is, the PD value in the vertical direction; thesub-pixel point 1 and thesub-pixel point 3 are synthesized, and thesub-pixel point 2 and the sub-pixel point. 4. Synthesize to form PD pixel pairs in the left and right directions, and vertical edges can be detected to obtain the first phase difference value, that is, the PD value in the horizontal direction.

图5为一个实施例中电子设备的结构示意图。如图5所示,该电子设备包括微透镜50、滤光片52和成像组件54。微透镜50、滤光片52和成像组件54 依次位于入射光路上,即微透镜50设置在滤光片52之上,滤光片52设置在成像组件54上。FIG. 5 is a schematic structural diagram of an electronic device in one embodiment. As shown in FIG. 5 , the electronic device includes amicrolens 50 , afilter 52 and animaging assembly 54 . Themicrolens 50 , thefilter 52 and theimaging component 54 are located on the incident light path in sequence, that is, themicrolens 50 is arranged on thefilter 52 , and thefilter 52 is arranged on theimaging component 54 .

滤光片52可包括红、绿、蓝三种,分别只能透过红色、绿色、蓝色对应波长的光线。一个滤光片52设置在一个像素点上。Thefilter 52 can include three types of red, green and blue, and can only transmit light with wavelengths corresponding to red, green, and blue, respectively. Onefilter 52 is arranged on one pixel.

成像组件54包括图3中的图像传感器。Imaging assembly 54 includes the image sensor of FIG. 3 .

透镜50用于接收入射光,并将入射光传输给滤光片52。滤光片52对入射光进行平滑处理后,将平滑处理后的光以像素为基础入射到成像组件54上。Thelens 50 is used to receive incident light and transmit the incident light to thefilter 52 . After thefilter 52 smoothes the incident light, the smoothed light is incident on theimaging element 54 on a pixel basis.

图像传感器中的感光单元通过光电效应将从滤光片52入射的光转换成电荷信号,并生成与电荷信号一致的像素信号。电荷信号与接收的光强度相一致。The photosensitive unit in the image sensor converts the light incident from thefilter 52 into a charge signal through the photoelectric effect, and generates a pixel signal consistent with the charge signal. The charge signal corresponds to the received light intensity.

图6为一个实施例中像素点组上设置滤光片的示意图。像素点组Z包括按照两行两列的阵列排布方式进行排布的4个像素点D,其中,第一行第一列的像素点的颜色通道为绿色,也即是,第一行第一列的像素点上设置的滤光片为绿色滤光片;第一行第二列的像素点的颜色通道为红色,也即是,第一行第二列的像素点上设置的滤光片为红色滤光片;第二行第一列的像素点的颜色通道为蓝色,也即是,第二行第一列的像素点上设置的滤光片为蓝色滤光片;第二行第二列的像素点的颜色通道为绿色,也即是,第二行第二列的像素点上设置的滤光片为绿色滤光片。FIG. 6 is a schematic diagram of setting a filter on a pixel point group in an embodiment. The pixel point group Z includes 4 pixel points D arranged in an array arrangement of two rows and two columns, wherein the color channel of the pixel points in the first row and the first column is green, that is, the first row The filter set on the pixel points in one column is a green filter; the color channel of the pixel points in the first row and the second column is red, that is, the filter set on the pixel points in the first row and the second column The color channel of the pixel point in the second row and the first column is blue, that is, the filter set on the pixel point in the second row and the first column is a blue filter; The color channel of the pixel points in the second row and the second column is green, that is, the filter set on the pixel point in the second row and the second column is a green filter.

图7为一个实施例中对焦方法的流程图。如图7所示,对焦方法包括步骤 702至步骤708。FIG. 7 is a flowchart of a focusing method in one embodiment. As shown in FIG. 7 , the focusing method includessteps 702 to 708.

步骤702、获取第一拍摄姿态对应的检测图像的相位差值,相位差值包括第一方向的第一相位差值和第二方向的第二相位差值,第一方向与第二方向成预设夹角。Step 702: Obtain the phase difference value of the detected image corresponding to the first shooting attitude, where the phase difference value includes the first phase difference value in the first direction and the second phase difference value in the second direction, and the first direction and the second direction are in a predetermined relationship. Set the angle.

其中,第一拍摄姿态可以为基准姿态,第一方向与第二方向成预设夹角,如90°、60°、45°等任意角度,其中,如第一方向与第二方向可以是垂直方向、水平方向或倾斜方向。检测图像为电子设备处于第一拍摄姿态下获取拍摄场景中目标检测区域的图像,检测图像为感兴趣区域对应的图像,检测图像可以包括感兴趣区域的大部分区域,检测图像还可以覆盖感兴趣区域。感兴趣区域可以是包括:主体,如人、花、猫、狗、牛、蓝天、白云、背景等各种对象的区域。相位差值包括第一相位差值和第二相位差值,第一相位差值指的是第一方向对应的相位值,第二相位差值指的是第二方向对应的相位值。当第一相位差值是指水平方向上的相位差值,则第二相位差值是指垂直方向上的相位差值。The first shooting posture may be a reference posture, and the first direction and the second direction form a preset angle, such as any angle of 90°, 60°, 45°, etc., wherein, for example, the first direction and the second direction may be vertical Orientation, Horizontal Or Oblique Orientation. The detection image is an image of the target detection area in the shooting scene obtained by the electronic device in the first shooting posture, and the detection image is an image corresponding to the area of interest. The detection image can include most of the area of interest, and the detection image can also cover the area of interest. area. The region of interest may be an area including subjects, such as people, flowers, cats, dogs, cows, blue sky, white clouds, backgrounds, and other objects. The phase difference value includes a first phase difference value and a second phase difference value, the first phase difference value refers to the phase value corresponding to the first direction, and the second phase difference value refers to the phase value corresponding to the second direction. When the first phase difference value refers to the phase difference value in the horizontal direction, the second phase difference value refers to the phase difference value in the vertical direction.

具体的,获取检测图像的相位差值的具体过程是:电子设备对检测图像进行切分处理,根据按照第一方向切分的上图和下图;根据第二方向进行切分处理的左图和右图;电子设备根据上图和下图中相互匹配的像素的位置差异计算得到第一相位差值。根据左图和右图相互匹配的像素的位置差异得到第二相位差值。Specifically, the specific process of obtaining the phase difference value of the detection image is: the electronic device performs segmentation processing on the detection image, according to the upper and lower images segmented according to the first direction; the left image is segmented according to the second direction. and the right picture; the electronic device calculates the first phase difference value according to the position difference of the pixels matching each other in the upper picture and the lower picture. The second phase difference value is obtained according to the position difference of the pixels matching each other in the left image and the right image.

在本申请实施例中,“相互匹配的像素的位置差异”指的是:相互匹配的像素中位于左图中的像素的位置和位于右图中的像素的位置的差异;或者相互匹配的像素中位于上图中的像素的位置和位于下图中的像素的位置的差异。相互匹配的像素分别对应于从不同方向射入镜头的成像光线在图像传感器中所成的不同的像。例如,左图中的像素a与右图中的像素b相互匹配,其中,该像素a 可以对应于图1中在A位置处所成的像,像素b可以对应于图1中在B位置处所成的像。由于相互匹配的像素分别对应于从不同方向射入镜头的成像光线在图像传感器中所成的不同的像,因此,根据相互匹配的像素的位置差异,即可确定该相互匹配的像素的相位差。In the embodiments of the present application, "the difference in the position of the pixels that match each other" refers to: the difference between the positions of the pixels located in the left picture and the positions of the pixels located in the right picture in the pixels that match each other; or the pixels that match each other The difference between the position of the pixel in the upper image and the position of the pixel in the lower image. Pixels that match each other correspond to different images formed in the image sensor by imaging light rays entering the lens from different directions. For example, pixel a in the left image matches with pixel b in the right image, where pixel a may correspond to the image formed at position A in FIG. 1 , and pixel b may correspond to the image formed at position B in FIG. 1 . 's image. Since the pixels that match each other correspond to different images formed by the imaging light entering the lens from different directions in the image sensor, the phase difference of the pixels that match each other can be determined according to the position difference of the pixels that match each other. .

步骤704、根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式。Step 704: Determine the focusing mode of the electronic device according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value.

其中,第一置信度用于表征第一相位差值的准确度,第二置信度用于表征第二相位差值的准确度。对焦方式包括相位检测自动对焦(英文:phase detection auto focus;简称:PDAF)、反差自动对焦等方式。The first confidence level is used to characterize the accuracy of the first phase difference value, and the second confidence level is used to characterize the accuracy of the second phase difference value. The focusing methods include phase detection auto focus (English: phase detection auto focus; abbreviated as PDAF), contrast auto focus, and the like.

具体的,根据第一置信度和第二置信度确定电子设备的对焦方式的过程是:当第一置信度和第二置信度满足置信度条件时,则确定电子设备的对焦方式为 PDAF;当第一置信度和第二置信度不满足置信度条件时,则确定电子设备的对焦方式为反差自动对焦。置信度条件有工程师根据实际需求进行设定,可以是第一置信度大于第一阈值和/或者第二置信度大于第二阈值,也可以是第一置信度和第二置信度中较大值大于第三阈值;还可以是第一置信度和第二置信度中较小值大于第四阈值;还可以是第一置信度和第二置信度的差值大于第五阈值等,此处不作限定。其中,第一阈值、第二阈值、第三阈值、第四阈值和第五阈值仅用于举例说明,可以为相同值,也可以为不同值,可以任意设置,此处不再赘述。Specifically, the process of determining the focusing mode of the electronic device according to the first confidence degree and the second confidence degree is: when the first confidence degree and the second confidence degree satisfy the confidence degree condition, then determine that the focusing mode of the electronic device is PDAF; When the first confidence level and the second confidence level do not satisfy the confidence level condition, it is determined that the focusing mode of the electronic device is contrast autofocusing. The confidence condition is set by the engineer according to the actual needs. It can be that the first confidence level is greater than the first threshold and/or the second confidence level is greater than the second threshold, or it can be the larger of the first confidence level and the second confidence level. is greater than the third threshold; it can also be that the smaller value of the first confidence level and the second confidence level is greater than the fourth threshold; it can also be that the difference between the first confidence level and the second confidence level is greater than the fifth threshold, etc. limited. The first threshold, the second threshold, the third threshold, the fourth threshold and the fifth threshold are only used for illustration, and may be the same value or different values, which may be arbitrarily set, and will not be repeated here.

步骤706、当对焦方式为相位检测自动对焦时,检测电子设备的第二拍摄姿态,获取第二拍摄姿态相对于第一拍摄姿态的偏转数据。Step 706: When the focusing mode is phase detection auto-focusing, detect the second shooting posture of the electronic device, and obtain deflection data of the second shooting posture relative to the first shooting posture.

具体的,第二拍摄姿态可以为在第一拍摄姿态上存在一定程度的角度、高度或深度等偏转。可以分别利用陀螺仪获取第一拍摄姿态对应的数据和第二拍摄姿态对应的数据,通过比较第一拍摄姿态对应的数据和第二拍摄姿态对应的数据得到偏转数据。偏转数据可以包括:角度偏转、高度偏移和/或深度偏移等。Specifically, the second shooting posture may be a certain degree of deflection, such as angle, height, or depth, on the first shooting posture. The data corresponding to the first shooting attitude and the data corresponding to the second shooting attitude can be obtained by using the gyroscope respectively, and the deflection data can be obtained by comparing the data corresponding to the first shooting attitude and the data corresponding to the second shooting attitude. The deflection data may include: angular deflection, height offset, and/or depth offset, among others.

步骤708、根据偏转数据、第一相位差值和第二相位差值确定目标方向,获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差。Step 708 : Determine the target direction according to the deflection data, the first phase difference value and the second phase difference value, and acquire the target phase difference corresponding to the target direction in the target image corresponding to the second shooting posture.

具体的,根据偏转数据、第一相位差值和第二相位差值确定目标方向,具体过程如下:当偏移数据小于或等于偏差阈值时,则从第一相位差值和第二相位差值中确定置信度较大的相位差为目标相位差。当偏移数据大于偏差阈值时,根据偏移数据获取目标方向及目标方向对应的目标相位差。其中,目标方向对应的目标相位差指的是:目标图像中目标方向对应的目标相位差,目标图像为电子设备处于第二拍摄姿态下对应获取的图像,目标图像可以包括感兴趣区域的大部分区域,还可以覆盖感兴趣区域。“根据偏移数据获取目标方向及目标方向对应的目标相位差”过程如下:判断偏移数据是否满足偏转预设条件,当偏转数据满足偏转预设条件时,则从第一方向和第二方向中确定一个方向作为目标方向,进一步的,需要在第二拍摄姿态下获取目标图像,并获取目标图像中目标方向的目标相位差即可;当偏转数据不满足偏转预设条件时,则需要在第二拍摄姿态下获取目标图像,并得到目标图像的上图与下图的相位差及其置信度,目标图像的左图与右图的相位差及其置信度,选择置信度较大值对应的相位差值作为目标相位差。其中,预设条件为角度、高度等设条件,可以是角度偏差或者高度阈值的范围阈值,具体数值可由工程师根据实际需求进行设定,此处不做限定。Specifically, the target direction is determined according to the deflection data, the first phase difference value and the second phase difference value, and the specific process is as follows: when the offset data is less than or equal to the deviation threshold, the first phase difference value and the second phase difference value are determined from the The phase difference with larger confidence is determined as the target phase difference. When the offset data is greater than the deviation threshold, the target direction and the target phase difference corresponding to the target direction are obtained according to the offset data. The target phase difference corresponding to the target direction refers to: the target phase difference corresponding to the target direction in the target image, the target image is an image correspondingly obtained by the electronic device in the second shooting posture, and the target image may include most of the region of interest area, and can also cover areas of interest. The process of "acquiring the target direction and the target phase difference corresponding to the target direction according to the offset data" is as follows: judging whether the offset data meets the preset deflection conditions, and when the deflection data meets the preset deflection conditions, the first direction and the second direction One direction is determined as the target direction. Further, it is necessary to obtain the target image in the second shooting posture, and to obtain the target phase difference of the target direction in the target image; when the deflection data does not meet the deflection preset conditions, it is necessary to The target image is acquired in the second shooting attitude, and the phase difference and confidence of the upper and lower images of the target image are obtained. The phase difference and confidence of the left and right images of the target image are selected. The larger value of the confidence corresponds to The phase difference value is used as the target phase difference. Among them, the preset conditions are set conditions such as angle and height, which can be the range threshold of angle deviation or height threshold, and the specific value can be set by the engineer according to actual needs, which is not limited here.

步骤710、根据目标相位差控制电子设备进行对焦。Step 710: Control the electronic device to focus according to the target phase difference.

具体的,由于目标相位差值与目标离焦距离值之间的对应关系可通过标定得到,已知目标相位差值和目标相位差值与目标离焦距离值的标定关系,即可得到目标离焦距离。控制镜头根据目标离焦距离值对目标主体进行对焦。Specifically, since the corresponding relationship between the target phase difference value and the target defocus distance value can be obtained by calibration, knowing the calibration relationship between the target phase difference value and the target phase difference value and the target defocus distance value, the target distance can be obtained. focal distance. Control the lens to focus on the target subject according to the target defocus distance value.

对于存在水平纹理的拍摄场景,因水平方向上的PD像素对无法得到水平方向的相位差值,可比对竖直方向上的PD像素对,计算竖直方向上相位差值,根据竖直方向的相位差值计算离焦距离值,再根据竖直方向上的离焦距离值控制镜头移动以实现对焦。For the shooting scene with horizontal texture, since the PD pixel pair in the horizontal direction cannot obtain the phase difference value in the horizontal direction, the PD pixel pair in the vertical direction can be compared to calculate the phase difference value in the vertical direction. The phase difference value calculates the defocus distance value, and then controls the lens movement to achieve focusing according to the defocus distance value in the vertical direction.

对于存在竖直纹理的拍摄场景,因竖直方向上的PD像素对无法得到竖直方向的相位差值,可比对水平方向上的PD像素对,计算水平方向上的水平方向的相位差值,根据水平方向的相位差值计算离焦距离值,再根据水平方向上的离焦距离值控制镜头移动以实现对焦。For shooting scenes with vertical texture, since the PD pixel pair in the vertical direction cannot obtain the phase difference value in the vertical direction, the PD pixel pair in the horizontal direction can be compared to calculate the phase difference value in the horizontal direction in the horizontal direction. Calculate the defocus distance value according to the phase difference value in the horizontal direction, and then control the lens movement to achieve focusing according to the defocus distance value in the horizontal direction.

上述对焦方法通过获取第一拍摄姿态对应的检测图像的相位差值,相位差值包括第一方向的第一相位差值和第二方向的第二相位差值,根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式;当对焦方式为相位检测自动对焦时,检测电子设备的第二拍摄姿态,获取第二拍摄姿态相对于第一拍摄姿态的偏转数据;根据偏转数据、第一相位差值和第二相位差值确定目标方向,获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差;根据目标相位差控制电子设备进行对焦。本申请提供的方案根据电子设备的偏转数据和两个相位差的置信度确定出目标方向并获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差值,无需重新计算电子设备发生角度偏转后的两个方向的相位差值,降低了对焦算法的计算复杂度,提升了电子设备发生角度偏转时的对焦速率。The above focusing method obtains the phase difference value of the detected image corresponding to the first shooting attitude, the phase difference value includes the first phase difference value in the first direction and the second phase difference value in the second direction, and the phase difference value corresponding to the first phase difference value is obtained. The first confidence level and the second confidence level corresponding to the second phase difference value determine the focusing mode of the electronic device; when the focusing mode is phase detection auto-focusing, the second shooting posture of the electronic device is detected, and the second shooting posture is obtained relative to the first shooting posture. 1. The deflection data of the shooting attitude; determine the target direction according to the deflection data, the first phase difference value and the second phase difference value, and obtain the target phase difference corresponding to the target direction in the target image corresponding to the second shooting attitude; control the electronic device according to the target phase difference device to focus. The solution provided by this application determines the target direction according to the deflection data of the electronic device and the confidence of the two phase differences, and obtains the target phase difference value corresponding to the target direction in the target image corresponding to the second shooting posture, without recalculating the angle of occurrence of the electronic device The phase difference value in the two directions after the deflection reduces the computational complexity of the focusing algorithm and improves the focusing rate when the electronic device is angularly deflected.

在其中一个实施例中,偏转数据至少包括偏转角度,根据偏转数据、第一相位差值和第二相位差值确定目标方向,包括:据偏转角度、第一相位差值对应的第一置信度和第二相位差值对应的第二置信度从第一方向和第二方向中确定出目标方向。In one embodiment, the deflection data includes at least a deflection angle, and the target direction is determined according to the deflection data, the first phase difference value and the second phase difference value, including: a first confidence level corresponding to the deflection angle and the first phase difference value The second confidence level corresponding to the second phase difference value determines the target direction from the first direction and the second direction.

具体的,根据拍摄角度、第一相位差值和第二相位差值确定目标方向,具体过程如下:当第二拍摄姿态对应的角度与第一拍摄姿态对应的角度的偏差大于角度偏差阈值时,则获取第二拍摄姿态对应的角度相对于第一拍摄姿态对应的角度的便宜角度,根据偏转角度获取目标方向及目标方向对应的目标相位差。判断偏转角度是否满足偏转预设条件,当偏转数据满足偏转预设条件时,则从第一方向和第二方向中确定一个方向作为目标方向,进一步的,需要在第二拍摄姿态下获取目标图像,并获取目标图像中目标方向的目标相位差即可。当偏转数据不满足偏转预设条件时,则需要在第二拍摄姿态下获取目标图像,并得到目标图像的上图与下图的相位差及其置信度,目标图像的左图与右图的相位差及其置信度,选择置信度较大值对应的相位差值作为目标相位差。其中,预设条件为角度预设条件,可以是角度偏差的范围阈值,可以根据实际需求进行设定。Specifically, the target direction is determined according to the shooting angle, the first phase difference value and the second phase difference value, and the specific process is as follows: when the deviation between the angle corresponding to the second shooting posture and the angle corresponding to the first shooting posture is greater than the angle deviation threshold, Then, the cheap angle of the angle corresponding to the second shooting posture relative to the angle corresponding to the first shooting posture is obtained, and the target direction and the target phase difference corresponding to the target direction are obtained according to the deflection angle. It is judged whether the deflection angle satisfies the deflection preset condition, and when the deflection data meets the deflection preset condition, one direction is determined from the first direction and the second direction as the target direction, and further, the target image needs to be acquired in the second shooting posture , and obtain the target phase difference of the target direction in the target image. When the deflection data does not meet the deflection preset conditions, the target image needs to be acquired in the second shooting attitude, and the phase difference and confidence of the upper image and the lower image of the target image are obtained. The left image and the right image of the target image Phase difference and its confidence, select the phase difference value corresponding to the larger confidence value as the target phase difference. The preset condition is an angle preset condition, which may be a range threshold of angle deviation, which may be set according to actual needs.

在其中一个实施例中,如图8所示,步骤根据偏转角度、第一相位差值对应的第一置信度和第二相位差值对应的第二置信度从第一方向和第二方向中确定出目标方向,包括:步骤802和步骤804。In one of the embodiments, as shown in FIG. 8 , the step is based on the deflection angle, the first confidence level corresponding to the first phase difference value, and the second confidence level corresponding to the second phase difference value from the first direction and the second direction. Determining the target direction includes: step 802 andstep 804 .

步骤802、当偏转角度处于第一角度范围内时,将第一置信度和第二置信度中选择较大置信度对应的相位差值的方向作为目标方向。Step 802: When the deflection angle is within the first angle range, select the direction of the phase difference value corresponding to the larger confidence degree among the first confidence degree and the second confidence degree as the target direction.

具体的,第一角度阈值可以是[0°-x,0°+x]或者[180°-x,180°+x],x 为0-5°、0-8°或0-10°内的任意值。当第一方向的目标相位差对应的第一置信度大于第二方向的目标相位差对应的第二置信度时,则第一方向为目标方向,获取当前拍摄角度对应的目标图像,并获取目标图像中第一方向对应的相位差值及相位差值,根据该相位差值进行对焦。当第一方向的目标相位差对应的第一置信度小于第二方向的目标相位差对应的第二置信度时,则第二方向为目标方向,获取当前拍摄角度对应的目标图像,并获取目标图像中第二方向对应的相位差值及相位差值,根据该相位差值进行对焦。Specifically, the first angle threshold may be [0°-x, 0°+x] or [180°-x, 180°+x], where x is within 0-5°, 0-8° or 0-10° any value of . When the first confidence level corresponding to the target phase difference in the first direction is greater than the second confidence level corresponding to the target phase difference in the second direction, the first direction is the target direction, the target image corresponding to the current shooting angle is acquired, and the target The phase difference value and the phase difference value corresponding to the first direction in the image are focused according to the phase difference value. When the first confidence level corresponding to the target phase difference in the first direction is smaller than the second confidence level corresponding to the target phase difference in the second direction, the second direction is the target direction, the target image corresponding to the current shooting angle is acquired, and the target The phase difference value and the phase difference value corresponding to the second direction in the image are focused according to the phase difference value.

步骤804、当偏转角度处于第二角度范围内时,将第一置信度和第二置信度中选择较小置信度对应的相位差值的方向作为目标方向。Step 804: When the deflection angle is within the second angle range, select the direction of the phase difference value corresponding to the smaller confidence degree among the first confidence degree and the second confidence degree as the target direction.

具体的,第一角度阈值可以是[90°-y,90°+y]或者[270°-z,270°+z],y, z可以为0-5°、0-8°或0-10°内的任意值。当第一方向的目标相位差对应的第一置信度大于第二方向的目标相位差对应的第二置信度时,则确定第二方向为目标方向,获取当前拍摄角度对应的目标图像,并获取目标图像中第二方向对应的相位差值及相位差值,根据该相位差值进行对焦。当第一方向的目标相位差对应的第一置信度小于第二方向的目标相位差对应的第二置信度时,则确定第一方向为目标方向,获取当前拍摄角度对应的目标图像,并获取目标图像中第一方向对应的相位差值及相位差值,根据该相位差值进行对焦。Specifically, the first angle threshold may be [90°-y, 90°+y] or [270°-z, 270°+z], and y, z may be 0-5°, 0-8° or 0- Any value within 10°. When the first confidence degree corresponding to the target phase difference in the first direction is greater than the second confidence degree corresponding to the target phase difference in the second direction, the second direction is determined as the target direction, the target image corresponding to the current shooting angle is acquired, and the The phase difference value and the phase difference value corresponding to the second direction in the target image are focused according to the phase difference value. When the first confidence degree corresponding to the target phase difference in the first direction is smaller than the second confidence degree corresponding to the target phase difference in the second direction, the first direction is determined as the target direction, the target image corresponding to the current shooting angle is acquired, and the The phase difference value and the phase difference value corresponding to the first direction in the target image are focused according to the phase difference value.

在其中一个实施例中,根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式之前,方法还包括:根据检测图像的场景信息获取第一置信度和第二置信度。In one of the embodiments, before determining the focusing mode of the electronic device according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value, the method further includes: acquiring according to scene information of the detected image The first confidence level and the second confidence level.

具体的,场景信息可以包括图像亮度和图像边缘等信息。当场景信息对应的检测图像的图像亮度满足亮度阈值时,可以利用检测图像的图像边缘如垂直边缘和/或水平边缘来获取第一置信度和第二置信度。Specifically, the scene information may include information such as image brightness and image edges. When the image brightness of the detected image corresponding to the scene information satisfies the brightness threshold, the first confidence level and the second confidence level can be obtained by using the image edge of the detected image, such as a vertical edge and/or a horizontal edge.

在其中一个实施例中,如图9所示,步骤根据检测图像的场景信息获取第一置信度和第二置信度,包括:步骤902和步骤904。其中,场景信息包括:图像边缘,图像边缘包括:水平边缘和垂直边缘。第一方向对水平方向,第二方向对应垂直方向。In one of the embodiments, as shown in FIG. 9 , the step of obtaining the first confidence level and the second confidence level according to the scene information of the detected image includes: step 902 andstep 904 . The scene information includes: image edges, and the image edges include: horizontal edges and vertical edges. The first direction corresponds to the horizontal direction, and the second direction corresponds to the vertical direction.

步骤902、对检测图像进行水平边缘检测获取获取水平边缘的像素点数目,并根据水平边缘的像素点数目确定第二置信度。Step 902: Perform horizontal edge detection on the detected image to obtain the number of pixels on the horizontal edge, and determine a second confidence level according to the number of pixels on the horizontal edge.

具体的,通过索贝尔算子的水平边缘检测算子进行水平边缘检测,获取的水平边缘的像素点数目来定义垂直方向对应的第二置信度,水平边缘的像素点数目越多,第二置信度越大。Specifically, the horizontal edge detection is performed by the horizontal edge detection operator of the Sobel operator, and the obtained number of pixels on the horizontal edge defines the second confidence level corresponding to the vertical direction. the greater the degree.

步骤904、对检测图像进行垂直边缘检测获取获取垂直边缘的像素点数目,并根据垂直边缘的像素点数目确定第一置信度。Step 904: Perform vertical edge detection on the detected image to obtain the number of pixels on the vertical edge, and determine the first confidence level according to the number of pixels on the vertical edge.

具体的,通过索贝尔算子的垂直边缘检测算子进行垂直边缘检测,获取的垂直边缘的像素点数目来定义水平方向对应的第一置信度,垂直边缘的像素点数目越多,第一置信度越大。Specifically, the vertical edge detection is performed by the vertical edge detection operator of the Sobel operator, and the acquired number of pixels on the vertical edge defines the first confidence level corresponding to the horizontal direction. the greater the degree.

在其中一个实施例中,根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式,包括:当第一置信度和第二置信度中的较大值大于置信度阈值时,确定对焦方式为相位检测自动对焦。In one of the embodiments, the focusing mode of the electronic device is determined according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value, including: when the first confidence level and the second confidence level When the larger value in is greater than the confidence threshold, it is determined that the focusing method is phase detection AF.

具体的,置信度阈值可以由工程师根据实际需求进行设定,如设置为0.3、 0.5、0.6或0.8等数值,此处不作限定。当第一置信度和第二置信度中的较大值为第一置信度,若第一置信度大于置信度阈值时,则确定电子设备的对焦方式为相位检测自动对焦。当第一置信度和第二置信度中的较大值为第二置信度,若第二置信度大于置信度阈值时,则确定电子设备的对焦方式为相位检测自动对焦。Specifically, the confidence threshold can be set by an engineer according to actual needs, for example, a value such as 0.3, 0.5, 0.6, or 0.8, which is not limited here. When the larger of the first confidence level and the second confidence level is the first confidence level, and if the first confidence level is greater than the confidence level threshold, it is determined that the focusing mode of the electronic device is phase detection autofocus. When the larger of the first confidence level and the second confidence level is the second confidence level, and if the second confidence level is greater than the confidence level threshold, it is determined that the focusing mode of the electronic device is phase detection autofocus.

在其中一个实施例中,方法还包括:当第一置信度和第二置信度小于或等于置信度阈值时,确定对焦方式为反差对焦,并控制电子设备进行反差对焦。In one embodiment, the method further includes: when the first confidence level and the second confidence level are less than or equal to a confidence level threshold, determining that the focusing mode is contrast focusing, and controlling the electronic device to perform contrast focusing.

具体的,当第一置信度和第二置信度小于或等于置信度阈值时,标识第一置信度和第二置信度中的较大值小于等于置信度阈值,则确定电子设备的对焦方式为反差对焦,并控制电子设备进行反差对焦。Specifically, when the first confidence level and the second confidence level are less than or equal to the confidence level threshold, it is indicated that the larger value of the first confidence level and the second confidence level is less than or equal to the confidence level threshold, and the focusing method of the electronic device is determined as Contrast focus, and control electronics for contrast focus.

在其中一个实施例中,步骤根据目标相位差控制电子设备进行对焦,包括:根据目标相位差值获取目标离焦距离,根据目标离焦距离控制电子设备的镜头移动以进行对焦。In one embodiment, the step of controlling the electronic device to focus according to the target phase difference includes: acquiring the target defocus distance according to the target phase difference value, and controlling the lens movement of the electronic device to focus according to the target defocus distance.

具体的,目标图像包括第一相位差值和第二相位差值,根据目标方向确定出目标相位值,根据目标相位差值可以获取目标离焦距离。举例来说,当目标方向为第一方向,则计算目标图像的第一相位差值,然后根据确定的目标相位差值从相位差值与离焦距离值之间的映射关系得到对应的目标离焦距离值。目标离焦距离指的是图像传感器当前所处的位置与合焦状态时图像传感器所应该处于的位置的距离;电子设备可以根据得到的目标离焦距离控制镜头移动至合焦位置进行对焦。Specifically, the target image includes a first phase difference value and a second phase difference value, the target phase value is determined according to the target direction, and the target defocus distance can be obtained according to the target phase difference value. For example, when the target direction is the first direction, the first phase difference value of the target image is calculated, and then the corresponding target distance is obtained from the mapping relationship between the phase difference value and the defocus distance value according to the determined target phase difference value. focal distance value. The target defocus distance refers to the distance between the current position of the image sensor and the position where the image sensor should be in the in-focus state; the electronic device can control the lens to move to the in-focus position for focusing according to the obtained target defocus distance.

在其中一个实施例中,步骤根据目标相位差值获取目标离焦距离,包括:根据已标定的离焦函数和目标相位差值计算目标离焦距离,已标定的离焦函数用于表征目标相位差值和目标离焦距离的关系。In one embodiment, the step of obtaining the target defocus distance according to the target phase difference value includes: calculating the target defocus distance according to the calibrated defocus function and the target phase difference value, and the calibrated defocus function is used to represent the target phase The relationship between the difference and the target defocus distance.

具体的,目标离焦距离值与目标相位差值之间的对应关系如下: defocus=PD*slope(DCC),其中,离焦系数(Defocus Conversion Coefficient, DCC)可以由标定得到,PD为目标相位差值。根据已标定的离焦函数和目标相位差值能够计算得到目标离焦距离,根据目标离焦距离控制电子设备的镜头移动以进行对焦。其中,目标相位差值与离焦距离值的对应关系的标定过程包括:将摄像模组的有效对焦行程切分为N(N≥3)等份,即(近焦DAC-远焦DAC) /N,以此覆盖马达的对焦范围;在每个对焦DAC(DAC可为0至1023)位置进行对焦,并记录当前对焦DAC位置的相位差;完成马达对焦行程后取一组N 个的对焦DAC与获得的PD值进行做比;生成N个相近的比值K,将DAC与 PD组成的二维数据进行拟合得到斜率为K的直线。Specifically, the corresponding relationship between the target defocus distance value and the target phase difference value is as follows: defocus=PD*slope(DCC), where the defocus coefficient (Defocus Conversion Coefficient, DCC) can be obtained by calibration, and PD is the target phase difference. The target defocus distance can be calculated according to the calibrated defocus function and the target phase difference value, and the lens of the electronic device is controlled to move to focus according to the target defocus distance. Among them, the calibration process of the corresponding relationship between the target phase difference value and the defocus distance value includes: dividing the effective focusing stroke of the camera module into N (N≥3) equal parts, namely (near focus DAC-far focus DAC) / N, so as to cover the focusing range of the motor; focus at each focusing DAC (DAC can be 0 to 1023) position, and record the phase difference of the current focusing DAC position; after completing the motor focusing stroke, take a group of N focusing DACs Compare with the obtained PD value; generate N similar ratios K, and fit the two-dimensional data composed of DAC and PD to obtain a straight line with a slope of K.

在其中一个实施例中,如图10所示,步骤获取目标检测区域图像的相位差值,包括:步骤1002和步骤1004。In one embodiment, as shown in FIG. 10 , the step of acquiring the phase difference value of the target detection area image includes:step 1002 andstep 1004 .

步骤1002、按照第一方向将检测图像切分为第一切分图像和第二切分图像。根据第一切分图像和第二切分图像对应的相位关系获取第一相位差值。Step 1002: Divide the detection image into a first segmented image and a second segmented image according to the first direction. The first phase difference value is acquired according to the phase relationship corresponding to the first segmented image and the second segmented image.

具体的,电子设备可以沿行的方向(图像坐标系中的x轴方向)对该目标图像进行切分处理,在沿行的方向对目标图像进行切分处理的过程中,切分处理的每一分割线都与行的方向垂直。沿行的方向对目标图像进行切分处理后得到的第一切分图像和第二切分图像,可以分别称为左图和右图。根据左图和右图中“相互匹配的像素”的相位差异,获取第一相位差值。Specifically, the electronic device can perform segmentation processing on the target image along the row direction (the x-axis direction in the image coordinate system). A dividing line is perpendicular to the direction of the line. The first segmented image and the second segmented image obtained after segmenting the target image along the row direction may be referred to as the left image and the right image, respectively. The first phase difference value is obtained according to the phase difference of the "mutually matched pixels" in the left and right images.

步骤1004、按照第二方向将检测图像切分为第三切分图像和第四切分图像。根据第三切分图像和第四切分图像对应的相位关系获取第二相位差值。Step 1004: Divide the detection image into a third segmented image and a fourth segmented image according to the second direction. The second phase difference value is acquired according to the phase relationship corresponding to the third segmented image and the fourth segmented image.

具体的,电子设备可以沿列的方向(图像坐标系中的y轴方向)对该目标图像进行切分处理,在沿列的方向对目标图像进行切分处理的过程中,切分处理的每一分割线都与列的方向垂直。沿列的方向对目标图像进行切分处理后得到的第一切分图像和第二切分图像可以分别称为上图和下图。Specifically, the electronic device can perform segmentation processing on the target image along the direction of the column (the y-axis direction in the image coordinate system). A dividing line is perpendicular to the direction of the columns. The first segmented image and the second segmented image obtained after segmenting the target image along the column direction may be referred to as an upper image and a lower image, respectively.

在一个实施例中,第一方向为行方向,第二方向为列方向。步骤:按照第一方向将检测图像切分为第一切分图像和第二切分图像,包括:按照第一方向对检测图像进行切分处理,得到多个图像区域,每个图像区域包括检测图像中的一行像素。从多个图像区域中获取多个第一切分图像区域和多个第二切分图像区域,第一切分图像区域包括检测图像中偶数行的像素,第二切分图像区域包括检测图像中奇数行的像素。利用多个第一切分图像区域拼接成第一切分图像,利用多个第二切分图像区域组成第二切分图像。In one embodiment, the first direction is the row direction and the second direction is the column direction. Step: dividing the detection image into a first segmented image and a second segmented image according to the first direction, including: performing segmentation processing on the detection image according to the first direction to obtain a plurality of image areas, each image area including detection A row of pixels in the image. Obtain a plurality of first segmented image regions and a plurality of second segmented image regions from a plurality of image regions, where the first segmented image region includes pixels in even rows in the detection image, and the second segmented image region includes pixels in the detection image Odd rows of pixels. A first segmented image is formed by splicing a plurality of first segmented image regions, and a second segmented image is formed by utilizing a plurality of second segmented image regions.

具体的,第一方向为行方向,按照第一方向对检测图像进行切分处理,能够得到多个图像区域,每个图像区域包括检测图像中的一行像素。从多个图像区域中获取多个第一切分图像区域和多个第二切分图像区域,第一切分图像区域指的是检测图像中偶数行的像素,第二切分图像区域指的是检测图像中奇数行的像素。将多个第一切分图像区域按照在检测图像中的位置依次进行拼接得到第一切分图像,将多个第二切分图像区域按照在检测图像中的位置依次进行拼接得到第二切分图像。Specifically, the first direction is the row direction, and the detection image is segmented according to the first direction to obtain a plurality of image areas, each image area includes a row of pixels in the detection image. Obtain multiple first segmented image areas and multiple second segmented image areas from multiple image areas, where the first segmented image area refers to the pixels of the even-numbered lines in the detected image, and the second segmented image area refers to is the pixel that detects odd rows in the image. The first segmented image is obtained by splicing a plurality of first segmented image regions in sequence according to their positions in the detection image, and the second segmented image is obtained by splicing a plurality of second segmented image regions in sequence according to their positions in the detection image. image.

步骤按照第二方向将检测图像切分为第三切分图像和第四切分图像,包括:按照第二方向对检测图像进行切分处理,得到多个图像区域,每个图像区域包括检测图像中的一列像素。从多个图像区域中获取多个第三切分图像区域和多个第四切分图像区域,第三切分图像区域包括检测图像中偶数列的像素,第四切分图像区域包括检测图像中奇数列的像素。利用多个第三切分图像区域拼接成第三切分图像,利用多个第四切分图像区域组成第四切分图像。The step of dividing the detection image into a third segmentation image and a fourth segmentation image according to the second direction includes: performing segmentation processing on the detection image according to the second direction to obtain a plurality of image areas, each image area including the detection image A column of pixels in . Obtain multiple third segmented image areas and multiple fourth segmented image areas from the multiple image areas, where the third segmented image area includes pixels in even-numbered columns in the detection image, and the fourth segmented image area includes pixels in the detection image Pixels of odd columns. A third segmented image is formed by splicing a plurality of third segmented image regions, and a fourth segmented image is formed by utilizing a plurality of fourth segmented image regions.

具体的,第二方向为列方向,按照第列方向对检测图像进行切分处理,能够得到多个图像区域,每个图像区域包括检测图像中的一列像素。从多个图像区域中获取多个第三切分图像区域和多个第四切分图像区域,第三切分图像区域指的是检测图像中偶数列的像素,第四切分图像区域指的是检测图像中奇数列的像素。将多个第三切分图像区域按照在检测图像中的位置依次进行拼接得到第三切分图像,将多个第四切分图像区域按照在检测图像中的位置依次进行拼接得到第四切分图像。Specifically, the second direction is the column direction, and the detection image is segmented according to the column direction to obtain a plurality of image areas, and each image area includes a column of pixels in the detection image. Obtain multiple third segmented image areas and multiple fourth segmented image areas from multiple image areas. is to detect pixels in odd columns in the image. The third segmented image is obtained by splicing a plurality of third segmented image regions in sequence according to their positions in the detection image, and the fourth segmented image is obtained by splicing a plurality of fourth segmented image regions in sequence according to their positions in the detection image. image.

在其中一个实施例中,如图11,步骤根据第一切分图像和第二切分图像对应的相位关系获取第一相位差值和根据第三切分图像和第四切分图像对应的相位关系获取第二相位差值,包括:步骤1102和步骤1104。In one of the embodiments, as shown in FIG. 11 , the steps are to obtain the first phase difference value according to the phase relationship corresponding to the first segmented image and the second segmented image and the phase corresponding to the third segmented image and the fourth segmented image. The relationship to obtain the second phase difference value includes:step 1102 andstep 1104 .

步骤1102、根据第一切分图像和第二切分图像中相互匹配的像素的位置差异,确定相互匹配的像素的相位差值。根据相互匹配的像素的相位差值确定第一相位差值。Step 1102: Determine the phase difference value of the matched pixels according to the position difference of the matched pixels in the first segmented image and the second segmented image. The first phase difference value is determined according to the phase difference values of the pixels that match each other.

具体的,当第一切分图像包括的是偶数行的像素,第二切分图像包括的是奇数行的像素,第一切分图像中的像素a与第二切分图像中的像素b相互匹配,则根据相互匹配的像素a和像素b的相位差,可以确定第一相位差值。Specifically, when the first segmented image includes even-numbered rows of pixels, and the second segmented image includes odd-numbered rows of pixels, pixel a in the first segmented image and pixel b in the second segmented image are mutually exclusive. If they match, the first phase difference value can be determined according to the phase difference between the matched pixel a and the pixel b.

步骤1104、根据第三切分图像和第四切分图像中相互匹配的像素的位置差异,确定相互匹配的像素的相位差值。根据相互匹配的像素的相位差值确定第二相位差值。Step 1104: Determine the phase difference value of the matched pixels according to the position difference of the matched pixels in the third segmented image and the fourth segmented image. The second phase difference value is determined according to the phase difference values of the pixels that match each other.

具体当第一切分图像包括的是偶数列的像素,第二切分图像包括的是奇数列的像素,第一切分图像中的像素a与第二切分图像中的像素b相互匹配,则根据相互匹配的像素a和像素b的相位差,可以确定第二相位差值。Specifically, when the first segmented image includes even-numbered columns of pixels, and the second segmented image includes odd-numbered columns of pixels, pixel a in the first segmented image and pixel b in the second segmented image match each other, Then, the second phase difference value can be determined according to the phase difference between pixel a and pixel b that match each other.

应该理解的是,虽然图7-11的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图7-11中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the steps in the flowcharts of FIGS. 7-11 are shown in sequence according to the arrows, these steps are not necessarily executed in the sequence shown by the arrows. Unless explicitly stated herein, the execution of these steps is not strictly limited to the order, and the steps may be executed in other orders. Moreover, at least a part of the steps in FIGS. 7-11 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed and completed at the same time, but may be executed at different times. These sub-steps or stages are not necessarily completed at the same time. The order of execution of the steps is not necessarily sequential, but may be performed alternately or alternately with other steps or at least a part of sub-steps or stages of other steps.

本申请实施例提供一种对焦焦装置,应用于电子设备,如图12所示,对焦装置包括:第一获取模块1202、第一确定模块1204、第二获取模块1206、第二确定模块1208和对焦模块1210。An embodiment of the present application provides a focusing device, which is applied to an electronic device. As shown in FIG. 12 , the focusing device includes: afirst acquisition module 1202 , afirst determination module 1204 , asecond acquisition module 1206 , asecond determination module 1208 and Focusingmodule 1210.

第一获取模块1202,用于获取第一拍摄姿态对应的检测图像的相位差值,相位差值包括第一方向的第一相位差值和第二方向的第二相位差值,第一方向与第二方向成预设夹角。Thefirst acquisition module 1202 is configured to acquire the phase difference value of the detected image corresponding to the first shooting attitude, the phase difference value includes the first phase difference value in the first direction and the second phase difference value in the second direction, the first direction and The second direction forms a preset angle.

其中,第一拍摄姿态可以为基准姿态,第一方向与第二方向成预设夹角,如90°、60°、45°等任意角度,其中,如第一方向与第二方向可以是垂直方向、水平方向或倾斜方向。检测图像为电子设备处于第一拍摄姿态下获取拍摄场景中目标检测区域的图像,检测图像为感兴趣区域对应的图像,检测图像可以包括感兴趣区域的大部分区域,检测图像还可以覆盖感兴趣区域。感兴趣区域可以是包括:主体,如人、花、猫、狗、牛、蓝天、白云、背景等各种对象的区域。相位差值包括第一相位差值和第二相位差值,第一相位差值指的是第一方向对应的相位值,第二相位差值指的是第二方向对应的相位值。当第一相位差值是指水平方向上的相位差值,则第二相位差值是指垂直方向上的相位差值。The first shooting posture may be a reference posture, and the first direction and the second direction form a preset angle, such as any angle of 90°, 60°, 45°, etc., wherein, for example, the first direction and the second direction may be vertical Orientation, Horizontal Or Oblique Orientation. The detection image is an image of the target detection area in the shooting scene obtained by the electronic device in the first shooting posture, and the detection image is an image corresponding to the area of interest. The detection image can include most of the area of interest, and the detection image can also cover the area of interest. area. The region of interest may be an area including subjects, such as people, flowers, cats, dogs, cows, blue sky, white clouds, backgrounds, and other objects. The phase difference value includes a first phase difference value and a second phase difference value, the first phase difference value refers to the phase value corresponding to the first direction, and the second phase difference value refers to the phase value corresponding to the second direction. When the first phase difference value refers to the phase difference value in the horizontal direction, the second phase difference value refers to the phase difference value in the vertical direction.

具体的,第一获取模块1202获取检测图像的相位差值的具体过程是:电子设备对检测图像进行切分处理,根据按照第一方向切分的上图和下图;根据第二方向进行切分处理的左图和右图;电子设备根据上图和下图中相互匹配的像素的位置差异计算得到第一相位差值。根据左图和右图相互匹配的像素的位置差异得到第二相位差值。在本申请实施例中,“相互匹配的像素的位置差异”指的是:相互匹配的像素中位于左图中的像素的位置和位于右图中的像素的位置的差异;或者相互匹配的像素中位于上图中的像素的位置和位于下图中的像素的位置的差异。相互匹配的像素分别对应于从不同方向射入镜头的成像光线在图像传感器中所成的不同的像。例如,左图中的像素a与右图中的像素b相互匹配,其中,该像素a可以对应于图1中在A位置处所成的像,像素b可以对应于图1中在B位置处所成的像。由于相互匹配的像素分别对应于从不同方向射入镜头的成像光线在图像传感器中所成的不同的像,因此,根据相互匹配的像素的位置差异,即可确定该相互匹配的像素的相位差。Specifically, the specific process for the first obtainingmodule 1202 to obtain the phase difference value of the detected image is as follows: the electronic device performs segmentation processing on the detected image, according to the upper and lower images segmented according to the first direction; The left picture and the right picture of the sub-processing; the electronic device calculates and obtains the first phase difference value according to the position difference of the pixels matching each other in the upper picture and the lower picture. The second phase difference value is obtained according to the position difference of the pixels matching each other in the left image and the right image. In the embodiments of the present application, "the difference in the position of the pixels that match each other" refers to: the difference between the positions of the pixels located in the left picture and the positions of the pixels located in the right picture in the pixels that match each other; or the pixels that match each other The difference between the position of the pixel in the upper image and the position of the pixel in the lower image. Pixels that match each other correspond to different images formed in the image sensor by imaging light rays entering the lens from different directions. For example, pixel a in the left image matches with pixel b in the right image, where pixel a may correspond to the image formed at position A in FIG. 1 , and pixel b may correspond to the image formed at position B in FIG. 1 . 's image. Since the pixels that match each other correspond to different images formed by the imaging light entering the lens from different directions in the image sensor, the phase difference of the pixels that match each other can be determined according to the position difference of the pixels that match each other. .

第一确定模块1204,用于根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式。The first determiningmodule 1204 is configured to determine the focusing mode of the electronic device according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value.

其中,第一置信度用于表征第一相位差值的准确度,第二置信度用于表征第二相位差值的准确度。对焦方式包括相位检测自动对焦(英文:phase detection auto focus;简称:PDAF)、反差自动对焦、激光对焦等方式。The first confidence level is used to characterize the accuracy of the first phase difference value, and the second confidence level is used to characterize the accuracy of the second phase difference value. The focusing methods include phase detection auto focus (English: phase detection auto focus; PDAF for short), contrast auto focus, laser focus and the like.

具体的,第一确定模块1204根据第一置信度和第二置信度确定电子设备的对焦方式的过程是:当第一置信度和第二置信度满足置信度条件时,则确定电子设备的对焦方式为PDAF;当第一置信度和第二置信度不满足置信度条件时,则确定电子设备的对焦方式为反差自动对焦或者激光对焦等方式。置信度条件有工程师根据实际需求进行设定,可以是第一置信度大于第一阈值和/或者第二置信度大于第二阈值,也可以是第一置信度和第二置信度中较大值大于第三阈值;还可以是第一置信度和第二置信度中较小值大于第四阈值;还可以是第一置信度和第二置信度的差值大于第五阈值等,此处不作限定。其中,第一阈值、第二阈值、第三阈值、第四阈值和第五阈值仅用于举例说明,可以为相同值,也可以为不同值,可以任意设置,此处不再赘述。Specifically, the process for thefirst determination module 1204 to determine the focusing mode of the electronic device according to the first confidence level and the second confidence level is: when the first confidence level and the second confidence level satisfy the confidence level condition, then determine the focus of the electronic device The method is PDAF; when the first confidence level and the second confidence level do not satisfy the confidence level condition, it is determined that the focusing method of the electronic device is contrast autofocusing or laser focusing. The confidence condition is set by the engineer according to the actual needs. It can be that the first confidence level is greater than the first threshold and/or the second confidence level is greater than the second threshold, or it can be the larger of the first confidence level and the second confidence level. is greater than the third threshold; it can also be that the smaller value of the first confidence level and the second confidence level is greater than the fourth threshold; it can also be that the difference between the first confidence level and the second confidence level is greater than the fifth threshold, etc. limited. The first threshold, the second threshold, the third threshold, the fourth threshold and the fifth threshold are only used for illustration, and may be the same value or different values, which may be arbitrarily set, and will not be repeated here.

第二获取模块1206,用于根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式。The second acquiringmodule 1206 is configured to determine the focusing mode of the electronic device according to the first confidence level corresponding to the first phase difference value and the second confidence level corresponding to the second phase difference value.

具体的,第二拍摄姿态可以为在第一拍摄姿态上存在一定程度的角度、高度或深度等偏转。第二获取模块1206可以分别利用陀螺仪获取第一拍摄姿态对应的数据和第二拍摄姿态对应的数据,通过比较第一拍摄姿态对应的数据和第二拍摄姿态对应的数据得到偏转数据。偏转数据可以包括:角度偏转、高度偏移和/或深度偏移等。Specifically, the second shooting posture may be a certain degree of deflection, such as angle, height, or depth, on the first shooting posture. Thesecond acquisition module 1206 can use the gyroscope to acquire the data corresponding to the first shooting attitude and the data corresponding to the second shooting attitude, respectively, and obtain deflection data by comparing the data corresponding to the first shooting attitude and the data corresponding to the second shooting attitude. The deflection data may include: angular deflection, height offset, and/or depth offset, among others.

第二确定模块1208,用于根据偏转数据、第一相位差值和第二相位差值确定目标方向,并获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差。The second determiningmodule 1208 is configured to determine the target direction according to the deflection data, the first phase difference value and the second phase difference value, and obtain the target phase difference corresponding to the target direction in the target image corresponding to the second shooting posture.

具体的,第二确定模块1208根据偏转数据、第一相位差值和第二相位差值确定目标方向,具体过程如下:当偏移数据小于或等于偏差阈值时,则从第一相位差值和第二相位差值中确定置信度较大的相位差为目标相位差。当偏移数据大于偏差阈值时,根据偏移数据获取目标方向及目标方向对应的目标相位差。其中,目标方向对应的目标相位差指的是:目标图像中目标方向对应的目标相位差,目标图像为电子设备处于第二拍摄姿态下对应获取的图像,目标图像可以包括感兴趣区域的大部分区域,还可以覆盖感兴趣区域。“根据偏移数据获取目标方向及目标方向对应的目标相位差”过程如下:判断偏移数据是否满足偏转预设条件,当偏转数据满足偏转预设条件时,则从第一方向和第二方向中确定一个方向作为目标方向,进一步的,需要在第二拍摄姿态下获取目标图像,并获取目标图像中目标方向的目标相位差即可;当偏转数据不满足偏转预设条件时,则需要在第二拍摄姿态下获取目标图像,并得到目标图像的上图与下图的相位差及其置信度,目标图像的左图与右图的相位差及其置信度,选择置信度较大值对应的相位差值作为目标相位差。其中,预设条件为角度、高度等设条件,可以是角度偏差或者高度阈值的范围阈值,具体数值可由工程师根据实际需求进行设定,此处不做限定。Specifically, the second determiningmodule 1208 determines the target direction according to the deflection data, the first phase difference value and the second phase difference value, and the specific process is as follows: when the offset data is less than or equal to the deviation threshold, then the first phase difference value and Among the second phase difference values, it is determined that the phase difference with greater confidence is the target phase difference. When the offset data is greater than the deviation threshold, the target direction and the target phase difference corresponding to the target direction are obtained according to the offset data. The target phase difference corresponding to the target direction refers to: the target phase difference corresponding to the target direction in the target image, the target image is an image correspondingly obtained by the electronic device in the second shooting posture, and the target image may include most of the region of interest area, and can also cover areas of interest. The process of "obtaining the target direction and the target phase difference corresponding to the target direction according to the offset data" is as follows: judging whether the offset data meets the preset deflection conditions, and when the deflection data meets the preset deflection conditions, the first direction and the second direction One direction is determined as the target direction. Further, it is necessary to obtain the target image in the second shooting posture, and to obtain the target phase difference of the target direction in the target image; when the deflection data does not meet the deflection preset conditions, it is necessary to The target image is acquired in the second shooting attitude, and the phase difference and confidence of the upper and lower images of the target image are obtained, and the phase difference and confidence of the left and right images of the target image. The phase difference value is used as the target phase difference. Among them, the preset conditions are set conditions such as angle, height, etc., which can be the angle deviation or the range threshold of the height threshold. The specific value can be set by the engineer according to the actual needs, which is not limited here.

对焦模块1210,用于根据目标相位差控制电子设备进行对焦。The focusingmodule 1210 is configured to control the electronic device to focus according to the target phase difference.

具体的,由于目标相位差值与目标离焦距离值之间的对应关系可通过标定得到,已知目标相位差值和目标相位差值与目标离焦距离值的标定关系,即可得到目标离焦距离。对焦模块1210控制镜头根据目标离焦距离值对目标主体进行对焦。对于存在水平纹理的拍摄场景,因水平方向上的PD像素对无法得到水平方向的相位差值,可比对竖直方向上的PD像素对,计算竖直方向上相位差值,根据竖直方向的相位差值计算离焦距离值,再根据竖直方向上的离焦距离值控制镜头移动以实现对焦。对于存在竖直纹理的拍摄场景,因竖直方向上的PD像素对无法得到竖直方向的相位差值,可比对水平方向上的PD像素对,计算水平方向上的水平方向的相位差值,根据水平方向的相位差值计算离焦距离值,再根据水平方向上的离焦距离值控制镜头移动以实现对焦。Specifically, since the corresponding relationship between the target phase difference value and the target defocus distance value can be obtained by calibration, knowing the calibration relationship between the target phase difference value and the target phase difference value and the target defocus distance value, the target distance can be obtained. focal distance. The focusingmodule 1210 controls the lens to focus on the target subject according to the target defocus distance value. For the shooting scene with horizontal texture, since the PD pixel pair in the horizontal direction cannot obtain the phase difference value in the horizontal direction, the PD pixel pair in the vertical direction can be compared to calculate the phase difference value in the vertical direction. The phase difference value calculates the defocus distance value, and then controls the lens movement to achieve focusing according to the defocus distance value in the vertical direction. For shooting scenes with vertical texture, since the PD pixel pair in the vertical direction cannot obtain the phase difference value in the vertical direction, the PD pixel pair in the horizontal direction can be compared to calculate the phase difference value in the horizontal direction in the horizontal direction. Calculate the defocus distance value according to the phase difference value in the horizontal direction, and then control the lens movement to achieve focusing according to the defocus distance value in the horizontal direction.

上述对焦装置通过获取第一拍摄姿态对应的检测图像的相位差值,相位差值包括第一方向的第一相位差值和第二方向的第二相位差值,根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式;当对焦方式为相位检测自动对焦时,检测电子设备的第二拍摄姿态,获取第二拍摄姿态相对于第一拍摄姿态的偏转数据;根据偏转数据、第一相位差值和第二相位差值确定目标方向,获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差;根据目标相位差控制电子设备进行对焦。本申请提供的方案根据电子设备的偏转数据和两个相位差的置信度确定出目标方向并获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差值,无需重新计算电子设备发生角度偏转后的两个方向的相位差值,降低了对焦算法的计算复杂度,提升了电子设备发生角度偏转时的对焦速率。The above-mentioned focusing device obtains the phase difference value of the detected image corresponding to the first shooting attitude, and the phase difference value includes the first phase difference value in the first direction and the second phase difference value in the second direction. The first confidence level and the second confidence level corresponding to the second phase difference value determine the focusing mode of the electronic device; when the focusing mode is phase detection auto-focusing, the second shooting posture of the electronic device is detected, and the second shooting posture is obtained relative to the first shooting posture. 1. The deflection data of the shooting attitude; determine the target direction according to the deflection data, the first phase difference value and the second phase difference value, and obtain the target phase difference corresponding to the target direction in the target image corresponding to the second shooting attitude; control the electronic device according to the target phase difference device to focus. The solution provided by this application determines the target direction according to the deflection data of the electronic device and the confidence of the two phase differences, and obtains the target phase difference value corresponding to the target direction in the target image corresponding to the second shooting posture, without recalculating the angle of occurrence of the electronic device The phase difference value in the two directions after the deflection reduces the computational complexity of the focusing algorithm and improves the focusing rate when the electronic device is angularly deflected.

在其中一个实施例中,偏转数据至少包括偏转角度,第二确定模块用于根据所述偏转角度、所述第一相位差值对应的第一置信度和所述第二相位差值对应的第二置信度从所述第一方向和所述第二方向中确定出所述目标方向。In one of the embodiments, the deflection data includes at least a deflection angle, and the second determining module is configured to use the deflection angle, a first confidence level corresponding to the first phase difference value, and a first degree corresponding to the second phase difference value. Two confidence levels determine the target direction from the first direction and the second direction.

在其中一个实施例中,第二确定模块用于当所述偏转角度处于第一角度范围内时,将所述第一置信度和所述第二置信度中选择较大置信度对应的相位差值的方向作为所述目标方向;当所述偏转角度处于第二角度范围内时,将所述第一置信度和所述第二置信度中选择较小置信度对应的相位差值的方向作为所述目标方向。In one embodiment, the second determination module is configured to select a phase difference corresponding to a larger confidence degree from the first confidence degree and the second confidence degree when the deflection angle is within a first angle range The direction of the value is used as the target direction; when the deflection angle is within the second angle range, the direction of the phase difference value corresponding to the smaller confidence degree selected from the first confidence degree and the second confidence degree is used as the target direction.

在其中一个实施例中,对焦装置包括置信度获取模块,用于根据所述检测图像的场景信息获取所述第一置信度和所述第二置信度。In one of the embodiments, the focusing apparatus includes a confidence level acquiring module, configured to acquire the first confidence level and the second confidence level according to scene information of the detected image.

在其中一个实施例中,所述场景信息包括:图像边缘,所述图像边缘包括:水平边缘和垂直边缘;所述第一方向为行方向,所述第二方向为列方向。置信度获取模块用于对所述检测图像进行水平边缘检测获取获取所述水平边缘的像素点数目,并根据所述水平边缘的像素点数目确定所述第二置信度;对所述检测图像进行垂直边缘检测获取获取所述垂直边缘的像素点数目,并根据所述垂直边缘的像素点数目确定所述第一置信度。In one embodiment, the scene information includes: an image edge, and the image edge includes: a horizontal edge and a vertical edge; the first direction is a row direction, and the second direction is a column direction. The confidence level acquisition module is used to perform horizontal edge detection on the detected image to acquire the number of pixels on the horizontal edge, and determine the second confidence level according to the number of pixels on the horizontal edge; The vertical edge detection acquires the number of pixels of the vertical edge, and determines the first confidence level according to the number of pixels of the vertical edge.

在其中一个实施例中,第一确定模块用于当所述第一置信度和所述第二置信度中的较大值大于置信度阈值时,确定所述对焦方式为相位检测自动对焦。In one of the embodiments, the first determination module is configured to determine that the focusing mode is phase detection auto-focusing when the larger value of the first confidence level and the second confidence level is greater than a confidence level threshold.

在其中一个实施例中,第一确定模块还用于当所述第一置信度和所述第二置信度小于或等于所述置信度条件时,确定所述对焦方式为反差对焦,并控制所述电子设备进行反差对焦。In one embodiment, the first determination module is further configured to determine that the focusing mode is contrast focusing when the first confidence level and the second confidence level are less than or equal to the confidence level condition, and control the The electronic device performs contrast focusing.

在其中一个实施例中,对焦模块用于根据所述目标相位差值获取目标离焦距离;根据所述目标离焦距离控制所述电子设备的镜头移动以进行对焦。In one embodiment, the focusing module is configured to acquire the target defocus distance according to the target phase difference value; and control the lens movement of the electronic device to focus according to the target defocus distance.

在其中一个实施例中,对焦模块用于根据已标定的离焦函数和所述目标相位差值计算所述目标离焦距离,所述已标定的离焦函数用于表征所述目标相位差值和所述目标离焦距离的关系。In one embodiment, the focusing module is configured to calculate the target defocus distance according to the calibrated defocus function and the target phase difference value, and the calibrated defocus function is used to represent the target phase difference value and the target defocus distance.

在其中一个实施例中,第一获取模块用于按照所述第一方向将所述检测图像切分为第一切分图像和第二切分图像;根据所述第一切分图像和所述第二切分图像对应的相位关系获取所述第一相位差值;按照所述第二方向将所述检测图像切分为第三切分图像和第四切分图像;根据所述第三切分图像和所述第四切分图像对应的相位关系获取所述第二相位差值。In one of the embodiments, the first acquisition module is configured to divide the detection image into a first segmented image and a second segmented image according to the first direction; according to the first segmented image and the Obtain the first phase difference value according to the phase relationship corresponding to the second segmented image; segment the detection image into a third segmented image and a fourth segmented image according to the second direction; The second phase difference value is obtained from the phase relationship corresponding to the segmented image and the fourth segmented image.

在其中一个实施例中,第一获取模块用于按照所述第一方向对所述检测图像进行切分处理,得到多个图像区域,每个所述图像区域包括所述检测图像中的一行像素;从多个所述图像区域中获取多个第一切分图像区域和多个第二切分图像区域,所述第一切分图像区域包括所述检测图像中偶数行的像素,所述第二切分图像区域包括所述检测图像中奇数行的像素;利用所述多个第一切分图像区域拼接成所述第一切分图像,利用所述多个第二切分图像区域组成所述第二切分图像;按照所述第二方向对所述检测图像进行切分处理,得到多个图像区域,每个所述图像区域包括所述检测图像中的一列像素;从多个所述图像区域中获取多个第三切分图像区域和多个第四切分图像区域,所述第三切分图像区域包括所述检测图像中偶数列的像素,所述第四切分图像区域包括所述检测图像中奇数列的像素;利用所述多个第三切分图像区域拼接成所述第三切分图像,利用所述多个第四切分图像区域组成所述第四切分图像。In one embodiment, the first acquisition module is configured to perform segmentation processing on the detection image according to the first direction to obtain a plurality of image regions, each of which includes a row of pixels in the detection image ; Obtain a plurality of first segmented image areas and a plurality of second segmented image areas from a plurality of described image areas, the first segmented image areas include pixels of even rows in the detection image, and the first segmented image areas The two-segmented image areas include odd-numbered rows of pixels in the detection image; the first segmented image is formed by splicing the multiple first segmented image areas, and the second segmented image area is formed by using the multiple second segmented image areas. the second segmented image; the detection image is segmented according to the second direction to obtain a plurality of image areas, each of which includes a column of pixels in the detection image; A plurality of third segmented image areas and a plurality of fourth segmented image areas are obtained in the image area, the third segmented image areas include pixels in even-numbered columns in the detection image, and the fourth segmented image areas include Pixels in odd-numbered columns in the detection image; the third segmented image is spliced by using the plurality of third segmented image regions, and the fourth segmented image is formed by using the plurality of fourth segmented image regions .

在其中一个实施例中,第一获取模块用于根据所述第一切分图像和所述第二切分图像中相互匹配的像素的位置差异,确定所述相互匹配的像素的相位差值;根据所述相互匹配的像素的相位差值确定第一相位差值;根据所述第三切分图像和所述第四切分图像中相互匹配的像素的位置差异,确定所述相互匹配的像素的相位差值;根据所述相互匹配的像素的相位差值确定第二相位差值。In one of the embodiments, the first acquisition module is configured to determine the phase difference value of the mutually matched pixels according to the position difference of the matched pixels in the first segmented image and the second segmented image; The first phase difference value is determined according to the phase difference values of the mutually matched pixels; the mutually matched pixels are determined according to the position difference of the mutually matched pixels in the third segmented image and the fourth segmented image The second phase difference value is determined according to the phase difference value of the mutually matched pixels.

上述对焦装置中各个模块的划分仅用于举例说明,在其他实施例中,可将对焦装置按照需要划分为不同的模块,以完成上述对焦装置的全部或部分功能。The division of each module in the above focusing device is only used for illustration. In other embodiments, the focusing device may be divided into different modules as required to complete all or part of the functions of the focusing device.

关于对焦装置的具体限定可以参见上文中对于对焦方法的限定,在此不再赘述。上述对焦装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于电子设备中的处理器中,也可以以软件形式存储于电子设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the focusing device, reference may be made to the limitation on the focusing method above, which will not be repeated here. Each module in the above focusing device may be implemented in whole or in part by software, hardware and combinations thereof. The above modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or stored in the memory in the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

一种电子设备,包括存储器及处理器,存储器中储存有计算机程序,计算机程序被处理器执行时,使得处理器执行如对焦方法的步骤。An electronic device includes a memory and a processor, a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes steps such as a focusing method.

在本申请的一个实施例中,提供了一种电子设备,该电子设备可以为电子设备,该电子设备可以为具有数字图像拍摄功能的电子设备,例如,该电子设备可以为智能手机、平板电脑、照相机或者摄像机等。其内部结构图可以如图 13所示。该电子设备包括通过系统总线连接的处理器和存储器。其中,该电子设备的处理器用于提供计算和控制能力。该电子设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质可以存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机程序被处理器执行时以实现本申请实施例提供的一种对焦方法。In an embodiment of the present application, an electronic device is provided, and the electronic device can be an electronic device, and the electronic device can be an electronic device with a digital image capturing function, for example, the electronic device can be a smart phone, a tablet computer , camera or camcorder, etc. Its internal structure diagram can be shown in Figure 13. The electronic device includes a processor and memory connected by a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The nonvolatile storage medium may store an operating system and a computer program. The internal memory provides an environment for the execution of the operating system and computer programs in the non-volatile storage medium. When the computer program is executed by the processor, a focusing method provided by the embodiments of the present application is implemented.

除此以外,虽然图13未示出,该电子设备还可以包括镜头和图像传感器,其中,镜头可以由一组透镜组成,图像传感器可以为金属氧化物半导体元件(英文:ComplementaryMetal Oxide Semiconductor。简称:CMOS)图像传感器、电荷耦合元件(英文:Charge-coupled Device。简称:CCD)、量子薄膜传感器或者有机传感器等。该图像传感器可以通过总线与处理器连接,处理器可以通过图像传感器向其输出的信号来实现本申请实施例提供的一种对焦方法。In addition, although not shown in FIG. 13 , the electronic device may further include a lens and an image sensor, wherein the lens may be composed of a group of lenses, and the image sensor may be a metal oxide semiconductor element (English: Complementary Metal Oxide Semiconductor. Abbreviation: CMOS) image sensor, charge-coupled device (English: Charge-coupled Device. Abbreviation: CCD), quantum thin film sensor or organic sensor, etc. The image sensor may be connected to the processor through a bus, and the processor may implement a focusing method provided by the embodiment of the present application through a signal output to it by the image sensor.

本领域技术人员可以理解,图13中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 13 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may be Include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.

在本申请的一个实施例中,提供了一种电子设备,该电子设备包括存储器和处理器,存储器中存储有计算机程序,处理器执行计算机程序时实现以下步骤:获取检测图像的相位差值,相位差值包括第一相位差值和第二相位差值,第一方向与第二方向成预设夹角;根据第一相位差值对应的第一置信度和第二相位差值对应的第二置信度确定电子设备的对焦方式;当对焦方式为相位检测自动对焦时,获取电子设备拍摄姿态;根据偏转数据、第一相位差值和第二相位差值确定目标方向,获取第二拍摄姿态对应的目标图像中目标方向对应的目标相位差;根据目标相位差控制电子设备进行对焦。In an embodiment of the present application, an electronic device is provided, the electronic device includes a memory and a processor, a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: acquiring a phase difference value of a detected image, The phase difference value includes a first phase difference value and a second phase difference value, and the first direction and the second direction form a preset angle; according to the first confidence level corresponding to the first phase difference value and the first phase difference value corresponding to the second phase difference value. Two confidence levels determine the focusing mode of the electronic device; when the focusing mode is phase detection autofocus, obtain the shooting posture of the electronic device; determine the target direction according to the deflection data, the first phase difference value and the second phase difference value, and obtain the second shooting posture The target phase difference corresponding to the target direction in the corresponding target image; the electronic device is controlled to focus according to the target phase difference.

本实施例提供的计算机可读存储介质,其实现原理和技术效果与上述方法实施例类似,在此不再赘述。The implementation principle and technical effect of the computer-readable storage medium provided in this embodiment are similar to those of the foregoing method embodiments, and details are not described herein again.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程 ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限, RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步 DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM (ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus) 直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium , when the computer program is executed, it may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database or other medium used in the various embodiments provided in this application may include non-volatile and/or volatile memory. Nonvolatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only represent several embodiments of the present application, and the descriptions thereof are relatively specific and detailed, but should not be construed as a limitation on the scope of the patent of the present application. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the scope of protection of the patent of the present application shall be subject to the appended claims.

Claims (15)

CN201911102669.0A2019-11-122019-11-12Focusing method and device, electronic equipment and computer readable storage mediumActiveCN112866551B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201911102669.0ACN112866551B (en)2019-11-122019-11-12Focusing method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201911102669.0ACN112866551B (en)2019-11-122019-11-12Focusing method and device, electronic equipment and computer readable storage medium

Publications (2)

Publication NumberPublication Date
CN112866551A CN112866551A (en)2021-05-28
CN112866551Btrue CN112866551B (en)2022-06-14

Family

ID=75984493

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201911102669.0AActiveCN112866551B (en)2019-11-122019-11-12Focusing method and device, electronic equipment and computer readable storage medium

Country Status (1)

CountryLink
CN (1)CN112866551B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109981965A (en)*2017-12-272019-07-05华为技术有限公司The method and electronic equipment of focusing

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
JP5387856B2 (en)*2010-02-162014-01-15ソニー株式会社 Image processing apparatus, image processing method, image processing program, and imaging apparatus
WO2014006784A1 (en)*2012-07-062014-01-09富士フイルム株式会社Imaging device, and image processing method
CN105007425B (en)*2015-07-232018-07-06广东欧珀移动通信有限公司Contrast type focusing method and mobile terminal
CN109477948B (en)*2016-07-062021-02-19富士胶片株式会社Focus control device, focus control method, focus control program, lens device, and imaging device
JP2018097253A (en)*2016-12-152018-06-21オリンパス株式会社 Focus adjustment device and focus adjustment method
CN106973206B (en)*2017-04-282020-06-05Oppo广东移动通信有限公司Camera shooting module group camera shooting processing method and device and terminal equipment
US20190033555A1 (en)*2017-07-282019-01-31Qualcomm IncorporatedPhase detection autofocus with diagonal line detection
KR20190042353A (en)*2017-10-162019-04-24엘지전자 주식회사Mobile terminal and method for controlling the same

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109981965A (en)*2017-12-272019-07-05华为技术有限公司The method and electronic equipment of focusing

Also Published As

Publication numberPublication date
CN112866551A (en)2021-05-28

Similar Documents

PublicationPublication DateTitle
US11856291B2 (en)Thin multi-aperture imaging system with auto-focus and methods for using same
CN112866542B (en) Focus tracking method and device, electronic device, computer-readable storage medium
CN112866552B (en) Focusing method and device, electronic device, computer-readable storage medium
CN112866549A (en)Image processing method and device, electronic equipment and computer readable storage medium
CN112866675B (en) Depth map generation method and apparatus, electronic device, and computer-readable storage medium
CN112866511B (en) Imaging assembly, focusing method and apparatus, electronic device
CN112866548B (en) Method and device for obtaining phase difference, and electronic device
US20160094776A1 (en)Imaging apparatus and imaging method
CN112866510B (en)Focusing method and device, electronic equipment and computer readable storage medium
CN112866655B (en) Image processing method and device, electronic device, computer-readable storage medium
CN112866545B (en) Focus control method and device, electronic device, computer-readable storage medium
CN112866553A (en)Focusing method and device, electronic equipment and computer readable storage medium
US11375110B2 (en)Image processing apparatus, image pickup apparatus, image processing method, and non-transitory computer-readable storage medium
CN112866547B (en)Focusing method and device, electronic equipment and computer readable storage medium
CN112866551B (en)Focusing method and device, electronic equipment and computer readable storage medium
CN112866543B (en) Focus control method and apparatus, electronic device, computer-readable storage medium
CN112862880B (en)Depth information acquisition method, device, electronic equipment and storage medium
CN112866674B (en)Depth map acquisition method and device, electronic equipment and computer readable storage medium
CN112866554B (en) Focusing method and apparatus, electronic device, computer-readable storage medium
CN112866546A (en) Focusing method and apparatus, electronic device, computer-readable storage medium
CN112866544B (en) Method, device, device and storage medium for obtaining phase difference
JP2016103683A (en)Imaging apparatus

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp