Movatterモバイル変換


[0]ホーム

URL:


CN118474538A - Focusing method and related equipment - Google Patents

Focusing method and related equipment
Download PDF

Info

Publication number
CN118474538A
CN118474538ACN202311155726.8ACN202311155726ACN118474538ACN 118474538 ACN118474538 ACN 118474538ACN 202311155726 ACN202311155726 ACN 202311155726ACN 118474538 ACN118474538 ACN 118474538A
Authority
CN
China
Prior art keywords
electronic device
compensation value
value
threshold
image
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.)
Granted
Application number
CN202311155726.8A
Other languages
Chinese (zh)
Other versions
CN118474538B (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.)
Honor Device Co Ltd
Original Assignee
Honor Device Co 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 Honor Device Co LtdfiledCriticalHonor Device Co Ltd
Priority to CN202311155726.8ApriorityCriticalpatent/CN118474538B/en
Publication of CN118474538ApublicationCriticalpatent/CN118474538A/en
Application grantedgrantedCritical
Publication of CN118474538BpublicationCriticalpatent/CN118474538B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

The embodiment of the application provides a focusing method and related equipment. The method comprises the following steps: at a first moment, the electronic equipment starts a camera application, the inclination angle of the electronic equipment is a first inclination angle, the motor is positioned at a first position, the electronic equipment displays a first image, and the first position corresponds to a first focusing value; at a second moment, the electronic device adjusts the motor to a second position, and the electronic device displays a second image; the sharpness of the second image is higher than the sharpness of the first image; the electronic equipment is provided with a first threshold value corresponding to the first preset interval, the distance between the second position and the first position is positively correlated with a first compensation value, the first compensation value is positively correlated with the first inclination angle, and the first compensation value is smaller than the first threshold value. Therefore, any preset interval is provided with the corresponding compensation value threshold, the accuracy of the compensation value threshold is improved, the accuracy of the compensation value is improved, and further the blurred scene imaged by the camera is reduced.

Description

Translated fromChinese
对焦方法及相关设备Focusing method and related equipment

技术领域Technical Field

本申请涉及终端技术领域,尤其涉及一种对焦方法及相关设备。The present application relates to the field of terminal technology, and in particular to a focusing method and related equipment.

背景技术Background Art

电子设备中可配置有摄像头,用户可基于电子设备进行拍摄照片和录制视频等活动。Electronic devices may be configured with cameras, and users may use the electronic devices to perform activities such as taking photos and recording videos.

可能的实现中,当用户在使用电子设备进行拍摄时,电子设备可对画面中的物体进行对焦,使得被拍摄物体成像清晰。In a possible implementation, when a user uses an electronic device to take a photo, the electronic device can focus on an object in the picture so that the image of the photographed object is clear.

但在一些场景中,电子设备可能无法显示清晰成像。例如,当用户使用电子设备仰拍或俯拍被拍摄物体时,电子设备显示的画面中被拍摄物体成像模糊,影响用户的拍摄体验。However, in some scenarios, the electronic device may not be able to display clear images. For example, when a user uses an electronic device to shoot an object from above or below, the image of the object in the picture displayed by the electronic device is blurred, affecting the user's shooting experience.

发明内容Summary of the invention

本申请实施例提供一种对焦方法及相关设备,应用于终端技术领域,当电子设备处于倾斜状态并拍照时,电子设备可根据倾斜角度的补偿值或预设区间的补偿值阈值对对焦值进行补偿,以提升对焦位置的准确性。The embodiments of the present application provide a focusing method and related equipment, which are applied to the field of terminal technology. When the electronic device is in a tilted state and takes a photo, the electronic device can compensate the focus value according to the compensation value of the tilt angle or the compensation value threshold of a preset interval to improve the accuracy of the focus position.

第一方面,本申请实施例提出一种对焦方法,应用于设置有摄像头和马达的电子设备,马达用于带动摄像头的位置移动,该方法包括:在第一时刻,电子设备启动相机应用,电子设备的倾斜角度为第一倾斜角度,马达位于第一位置处,电子设备显示第一图像,第一位置对应第一对焦值;在第二时刻,电子设备将马达调整到第二位置处,电子设备显示第二图像;第二图像的清晰度高于第一图像的清晰度;其中,第一倾斜角度属于第一预设区间,电子设备设置有第一预设区间对应的第一阈值,第二位置与第一位置的距离与第一补偿值呈正相关,第一补偿值与第一倾斜角度呈正相关,第一补偿值小于第一阈值;第一时刻早于第二时刻;在第三时刻,电子设备调整为第二倾斜角度,马达位于第三位置处,电子设备显示第三图像,第三位置对应第二对焦值,第二倾斜角度与第一倾斜角度不同;第二时刻早于第三时刻;在第四时刻,电子设备将马达调整到第四位置处,电子设备显示第四图像,第四图像的清晰度高于第三图像的清晰度;其中,第二倾斜角度属于第一预设区间,第四位置与第三位置的距离与第二补偿值呈正相关,第二补偿值与第二倾斜角度呈正相关,第二补偿值小于第一阈值;第三时刻早于第四时刻;在第五时刻,电子设备再次调整为第三倾斜角度,马达位于第五位置处,电子设备显示第五图像,第五位置对应第三对焦值,第四时刻早于第五时刻;在第六时刻,电子设备将马达调整到第六位置处,电子设备显示第六图像,第六图像的清晰度高于第五图像的清晰度;其中,第三倾斜角度属于第二预设区间,第二预设区间中的值与第一预设区间中的值不重合,电子设备中还设置有第二预设区间对应的第二阈值,第二阈值与第一阈值不同,第六位置与第五位置的距离与第三补偿值呈正相关,第三补偿值与第三倾斜角度呈正相关,第三补偿值小于第二阈值;第五时刻早于第六时刻。In a first aspect, an embodiment of the present application proposes a focusing method, which is applied to an electronic device provided with a camera and a motor, wherein the motor is used to drive the position of the camera to move, and the method comprises: at a first moment, the electronic device starts a camera application, the tilt angle of the electronic device is a first tilt angle, the motor is located at a first position, the electronic device displays a first image, and the first position corresponds to a first focus value; at a second moment, the electronic device adjusts the motor to a second position, and the electronic device displays a second image; the clarity of the second image is higher than the clarity of the first image; wherein the first tilt angle belongs to a first preset interval, the electronic device is provided with a first threshold corresponding to the first preset interval, the distance between the second position and the first position is positively correlated with the first compensation value, the first compensation value is positively correlated with the first tilt angle, and the first compensation value is less than the first threshold; the first moment is earlier than the second moment; at a third moment, the electronic device is adjusted to a second tilt angle, the motor is located at a third position, the electronic device displays a third image, the third position corresponds to a second focus value, and the second tilt angle is different from the first tilt angle; the second moment is earlier than the third moment; at a fourth moment, the electronic device adjusts the motor to a second position, and the motor is located at a third position, and the electronic device displays a third image, the third position corresponds to a second focus value, and the second tilt angle is different from the first tilt angle; When the electronic device reaches the fourth position, the fourth image is displayed, and the clarity of the fourth image is higher than that of the third image; wherein the second tilt angle belongs to the first preset interval, the distance between the fourth position and the third position is positively correlated with the second compensation value, the second compensation value is positively correlated with the second tilt angle, and the second compensation value is less than the first threshold value; the third moment is earlier than the fourth moment; at the fifth moment, the electronic device is adjusted to the third tilt angle again, the motor is located at the fifth position, the electronic device displays the fifth image, the fifth position corresponds to the third focus value, and the fourth moment is earlier than the fifth moment; at the sixth moment, the electronic device adjusts the motor to the sixth position, the electronic device displays the sixth image, and the clarity of the sixth image is higher than that of the fifth image; wherein the third tilt angle belongs to the second preset interval, the value in the second preset interval does not overlap with the value in the first preset interval, the electronic device is also provided with a second threshold value corresponding to the second preset interval, the second threshold value is different from the first threshold value, the distance between the sixth position and the fifth position is positively correlated with the third compensation value, the third compensation value is positively correlated with the third tilt angle, and the third compensation value is less than the second threshold value; the fifth moment is earlier than the sixth moment.

这样,本申请实施例中,电子设备对倾斜角度进行区域划分,得到多个预设区间。任一预设区间均设置有该预设区间下的补偿值阈值,提升了补偿值阈值的准确度,补偿值小于补偿值阈值时,电子设备得到的补偿值更加准确,从而提升了补偿值的准确度,进而减少摄像头成像模糊的场景。Thus, in the embodiment of the present application, the electronic device divides the tilt angle into regions to obtain a plurality of preset intervals. Each preset interval is provided with a compensation value threshold value under the preset interval, which improves the accuracy of the compensation value threshold value. When the compensation value is less than the compensation value threshold value, the compensation value obtained by the electronic device is more accurate, thereby improving the accuracy of the compensation value, and further reducing the scene of blurred camera imaging.

在一种可能的实现方式中,电子设备还包括马达驱动,在电子设备将马达调整到第二位置处之前,还包括:电子设备根据第一倾斜角度查找第一预设区间对应的第一阈值;电子设备使用第一倾斜角度计算第一补偿值;第一补偿值与第一倾斜角度的正弦值呈正相关;当第一补偿值小于第一阈值时,电子设备基于第一补偿值和第一对焦值得到第二位置;第二位置与第一补偿值和第一对焦值的和呈正相关;电子设备将第二位置下发至马达驱动。这样,当补偿值小于补偿值阈值时,电子设备可使用补偿值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In a possible implementation, the electronic device also includes a motor drive, and before the electronic device adjusts the motor to the second position, it also includes: the electronic device searches for a first threshold value corresponding to a first preset interval according to a first tilt angle; the electronic device calculates a first compensation value using the first tilt angle; the first compensation value is positively correlated with the sine value of the first tilt angle; when the first compensation value is less than the first threshold value, the electronic device obtains a second position based on the first compensation value and the first focus value; the second position is positively correlated with the sum of the first compensation value and the first focus value; the electronic device sends the second position to the motor drive. In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate position of the motor to be adjusted, thereby improving the accuracy of the focus position.

在一种可能的实现方式中,第一补偿值满足下述公式:In a possible implementation, the first compensation value satisfies the following formula:

offset=sinθ×offset0offset = sinθ × offset0

其中,offset为第一补偿值,θ为第一倾斜角度,offset0为预设补偿值阈值。这样,电子设备可使用补偿值计算公式得到补偿值,以便于在后续对焦流程中使用该值提升对焦的准确性。Wherein, offset is the first compensation value, θ is the first tilt angle, and offset0 is the preset compensation value threshold. In this way, the electronic device can use the compensation value calculation formula to obtain the compensation value, so as to use the value in the subsequent focusing process to improve the focusing accuracy.

在一种可能的实现方式中,还包括:在第七时刻,电子设备再次调整为第四倾斜角度,马达位于第七位置处,电子设备显示第七图像,第七位置对应第四对焦值,第六时刻早于第七时刻;在第八时刻,电子设备将马达调整到第八位置处,电子设备显示第八图像,第八图像的清晰度高于第七图像的清晰度;其中,第四倾斜角属于第三预设区间,第三预设区间中的值与第二预设区间中的值不重合,电子设备中还设置有第三预设区间对应的第三阈值,第三阈值与第二阈值不同,第八位置与第七位置的距离与第三阈值呈正相关,第四补偿值大于或等于第三阈值,第四补偿值与第四倾斜角度呈正相关,第七时刻早于第八时刻。这样,电子设备通过补偿值阈值衡量补偿值的准确度,当补偿值大于或等于补偿值阈值时,当前补偿值误差较大,无法使用补偿值修正计算对焦值;这时,可使用补偿值阈值对计算对焦值进行修正,以提升马达待调整位置的准确性。In a possible implementation, it also includes: at the seventh moment, the electronic device is adjusted to the fourth tilt angle again, the motor is located at the seventh position, the electronic device displays the seventh image, the seventh position corresponds to the fourth focus value, and the sixth moment is earlier than the seventh moment; at the eighth moment, the electronic device adjusts the motor to the eighth position, the electronic device displays the eighth image, and the clarity of the eighth image is higher than that of the seventh image; wherein the fourth tilt angle belongs to the third preset interval, the value in the third preset interval does not overlap with the value in the second preset interval, the electronic device is also provided with a third threshold corresponding to the third preset interval, the third threshold is different from the second threshold, the distance between the eighth position and the seventh position is positively correlated with the third threshold, the fourth compensation value is greater than or equal to the third threshold, the fourth compensation value is positively correlated with the fourth tilt angle, and the seventh moment is earlier than the eighth moment. In this way, the electronic device measures the accuracy of the compensation value by the compensation value threshold, and when the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large, and the compensation value cannot be used to correct the calculated focus value; at this time, the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the position to be adjusted by the motor.

在一种可能的实现方式中,在电子设备将马达调整到第八位置之前,还包括:电子设备根据第四倾斜角度查找第三预设区间对应的第三阈值;电子设备使用第四倾斜角度计算第四补偿值;第四补偿值与第四倾斜角度的正弦值呈正相关;当第四补偿值大于或等于第三阈值时,电子设备基于第三阈值和第四对焦值得到第八位置;第八位置与第三阈值和第四对焦值的和呈正相关;电子设备将第八位置下发至马达驱动。这样,当补偿值大于或等于补偿值阈值时,电子设备可使用补偿值阈值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In a possible implementation, before the electronic device adjusts the motor to the eighth position, it also includes: the electronic device searches for the third threshold corresponding to the third preset interval according to the fourth tilt angle; the electronic device calculates the fourth compensation value using the fourth tilt angle; the fourth compensation value is positively correlated with the sine value of the fourth tilt angle; when the fourth compensation value is greater than or equal to the third threshold, the electronic device obtains the eighth position based on the third threshold and the fourth focus value; the eighth position is positively correlated with the sum of the third threshold and the fourth focus value; the electronic device sends the eighth position to the motor driver. In this way, when the compensation value is greater than or equal to the compensation value threshold, the electronic device can use the compensation value threshold and the calculated focus value to obtain a more accurate position of the motor to be adjusted, thereby improving the accuracy of the focus position.

在一种可能的实现方式中,还包括:在第九时刻,电子设备再次调整为第五倾斜角度,马达位于第九位置处,电子设备显示第九图像,第九图像中包括预设的目标物体,目标物体为与电子设备的距离超过距离阈值的物体,第九位置对应第五对焦值,第八时刻早于第九时刻;在第十时刻,电子设备将马达调整到第十位置处,电子设备显示第十图像,第十图像中包括目标物体,第十图像的清晰度高于第九图像的清晰度;电子设备还设置有目标物体在第五倾斜角度下的第四阈值,第十位置与第九位置的距离与第五补偿值呈正相关,第五补偿值与第五倾斜角度呈正相关,第五补偿值小于第四阈值;其中,第五倾斜角度属于第四预设区间,电子设备中还设置有第四预设区间对应的阈值,且第四阈值与第四预设区间对应的阈值不同;第九时刻早于第十时刻。这样,在拍摄目标物体时,电子设备可根据需要的精度调整任一倾斜角度下的补偿值阈值,提升补偿值阈值的精度,从而提升对焦位置的准确度。In a possible implementation, it also includes: at the ninth moment, the electronic device is adjusted to the fifth tilt angle again, the motor is located at the ninth position, the electronic device displays the ninth image, the ninth image includes a preset target object, the target object is an object whose distance from the electronic device exceeds the distance threshold, the ninth position corresponds to the fifth focus value, and the eighth moment is earlier than the ninth moment; at the tenth moment, the electronic device adjusts the motor to the tenth position, the electronic device displays the tenth image, the tenth image includes the target object, and the clarity of the tenth image is higher than the clarity of the ninth image; the electronic device is also provided with a fourth threshold value of the target object at the fifth tilt angle, the distance between the tenth position and the ninth position is positively correlated with the fifth compensation value, the fifth compensation value is positively correlated with the fifth tilt angle, and the fifth compensation value is less than the fourth threshold value; wherein the fifth tilt angle belongs to the fourth preset interval, the electronic device is also provided with a threshold value corresponding to the fourth preset interval, and the fourth threshold value is different from the threshold value corresponding to the fourth preset interval; the ninth moment is earlier than the tenth moment. In this way, when shooting the target object, the electronic device can adjust the compensation value threshold value at any tilt angle according to the required accuracy, improve the accuracy of the compensation value threshold value, and thus improve the accuracy of the focus position.

在一种可能的实现方式中,在电子设备将马达位置调整到第十位置处之前,还包括:电子设备得到第九图像,并判定第九图像中的被拍摄物体是否为目标物体;当第九图像中的被拍摄物体是目标物体时,电子设备根据目标物体和第五倾斜角度查找第四阈值;电子设备使用第五倾斜角度计算第五补偿值;当第五补偿值小于第四阈值时,电子设备基于第五补偿值和第五对焦值得到第十位置;第十位置与第五补偿值和第五对焦值的和呈正相关;电子设备将第十位置下发至马达驱动。这样,当补偿值小于补偿值阈值时,电子设备可使用补偿值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In a possible implementation, before the electronic device adjusts the motor position to the tenth position, it also includes: the electronic device obtains the ninth image and determines whether the photographed object in the ninth image is the target object; when the photographed object in the ninth image is the target object, the electronic device searches for the fourth threshold value according to the target object and the fifth tilt angle; the electronic device calculates the fifth compensation value using the fifth tilt angle; when the fifth compensation value is less than the fourth threshold value, the electronic device obtains the tenth position based on the fifth compensation value and the fifth focus value; the tenth position is positively correlated with the sum of the fifth compensation value and the fifth focus value; the electronic device sends the tenth position to the motor drive. In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

在一种可能的实现方式中,还包括:在第十一时刻,电子设备再次调整为第六倾斜角度,马达位于第十一位置处,电子设备显示第十一图像,第十一图像中包括目标物体,第十一位置对应第六对焦值,第十时刻早于第十一时刻;在第十二时刻,电子设备将马达调整到第十二位置处,电子设备显示第十二图像,第十二图像中包括目标物体,第十二图像的清晰度高于第十一图像的清晰度;电子设备还设置有目标物体在第六倾斜角度下对应的第五阈值,第十二位置与第十一位置的距离与第五阈值呈正相关,第六补偿值大于或等于第五阈值,第六补偿值与第六倾斜角度呈正相关;其中,第六倾斜角度属于第四预设区间,第五阈值与第四预设区间对应的阈值不同,且第五阈值与第四阈值不同;第十一时刻早于第十二时刻。这样,在拍摄目标物体时,电子设备可根据需要的精度调整任一倾斜角度下的补偿值阈值,提升补偿值阈值的精度;电子设备通过该补偿值阈值衡量补偿值的准确度,当补偿值大于或等于补偿值阈值时,当前补偿值误差较大,无法使用补偿值修正计算对焦值;可使用补偿值阈值对计算对焦值进行修正,以提升马达待调整位置的准确性。In a possible implementation, it also includes: at the eleventh moment, the electronic device is adjusted to the sixth tilt angle again, the motor is located at the eleventh position, the electronic device displays the eleventh image, the eleventh image includes the target object, the eleventh position corresponds to the sixth focus value, and the tenth moment is earlier than the eleventh moment; at the twelfth moment, the electronic device adjusts the motor to the twelfth position, the electronic device displays the twelfth image, the twelfth image includes the target object, and the clarity of the twelfth image is higher than the clarity of the eleventh image; the electronic device is also provided with a fifth threshold corresponding to the target object at the sixth tilt angle, the distance between the twelfth position and the eleventh position is positively correlated with the fifth threshold, the sixth compensation value is greater than or equal to the fifth threshold, and the sixth compensation value is positively correlated with the sixth tilt angle; wherein the sixth tilt angle belongs to the fourth preset interval, the fifth threshold is different from the threshold corresponding to the fourth preset interval, and the fifth threshold is different from the fourth threshold; the eleventh moment is earlier than the twelfth moment. In this way, when shooting the target object, the electronic device can adjust the compensation value threshold at any tilt angle according to the required accuracy to improve the accuracy of the compensation value threshold; the electronic device measures the accuracy of the compensation value through the compensation value threshold. When the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large and the compensation value cannot be used to correct the calculated focus value; the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the motor position to be adjusted.

在一种可能的实现方式中,在电子设备将马达位置调整到第十二位置处之前,还包括:电子设备得到第十一图像,并判定第十一图像中的被拍摄物体是否为目标物体;当第十一图像中的被拍摄物体是目标物体时,电子设备根据目标物体和第六倾斜角度查找第五阈值;电子设备使用第六倾斜角度计算第六补偿值;当第六补偿值大于或等于第五阈值时,电子设备基于第五阈值和第六对焦值得到第十二位置;第十二位置与第五阈值和第六对焦值的和呈正相关;电子设备将第十二位置下发至马达驱动。这样,当补偿值大于或等于补偿值阈值时,电子设备可使用补偿值阈值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In a possible implementation, before the electronic device adjusts the motor position to the twelfth position, it also includes: the electronic device obtains the eleventh image and determines whether the photographed object in the eleventh image is the target object; when the photographed object in the eleventh image is the target object, the electronic device searches for the fifth threshold value according to the target object and the sixth tilt angle; the electronic device calculates the sixth compensation value using the sixth tilt angle; when the sixth compensation value is greater than or equal to the fifth threshold value, the electronic device obtains the twelfth position based on the fifth threshold value and the sixth focus value; the twelfth position is positively correlated with the sum of the fifth threshold value and the sixth focus value; the electronic device sends the twelfth position to the motor drive. In this way, when the compensation value is greater than or equal to the compensation value threshold value, the electronic device can use the compensation value threshold value and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

在一种可能的实现方式中,第一倾斜角度与惯性测量单元IMU数据相关,IMU数据是电子设备基于陀螺仪传感器得到的;In a possible implementation, the first tilt angle is related to inertial measurement unit IMU data, where the IMU data is obtained by the electronic device based on a gyroscope sensor;

第一倾斜角度满足下述任一公式:The first inclination angle satisfies any of the following formulas:

或者;or;

或者;or;

其中,gSensor.x为电子设备处于第一倾斜角度时x轴方向的角速度,gSensor.y为电子设备处于第一倾斜角度时y轴方向的角速度,gSensor.z为电子设备处于第一倾斜角度时z轴方向的角速度。这样,电子设备可使用倾斜角度计算公式得到当前倾斜角度,以便于在后续对焦流程中使用该值提升对焦的准确性。Among them, gSensor.x is the angular velocity of the electronic device in the x-axis direction when the electronic device is at the first tilt angle, gSensor.y is the angular velocity of the electronic device in the y-axis direction when the electronic device is at the first tilt angle, and gSensor.z is the angular velocity of the electronic device in the z-axis direction when the electronic device is at the first tilt angle. In this way, the electronic device can use the tilt angle calculation formula to obtain the current tilt angle, so that the value can be used in the subsequent focusing process to improve the accuracy of focusing.

第二方面,本申请实施例提供一种终端设备,终端设备也可以称为终端(terminal)、用户设备(user equipment,UE)、移动台(mobile station,MS)、移动终端(mobile terminal,MT)等。终端设备可以是手机(mobile phone)、智能电视、穿戴式设备、平板电脑(Pad)、带无线收发功能的电脑、虚拟现实(virtual reality,VR)终端设备、增强现实(augmented reality,AR)终端设备、工业控制(industrial control)中的无线终端、无人驾驶(self-driving)中的无线终端、远程手术(remote medical surgery)中的无线终端、智能电网(smart grid)中的无线终端、运输安全(transportation safety)中的无线终端、智慧城市(smart city)中的无线终端、智慧家庭(smart home)中的无线终端等等。In a second aspect, an embodiment of the present application provides a terminal device, which may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device may be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc.

该终端设备包括:包括:处理器和存储器;存储器存储计算机执行指令;处理器执行存储器存储的计算机执行指令,使得终端设备执行如第一方面的方法。The terminal device comprises: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the method of the first aspect.

第三方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序。计算机程序被处理器执行时实现如第一方面的方法。In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the method of the first aspect is implemented.

第四方面,本申请实施例提供一种计算机程序产品,计算机程序产品包括计算机程序,当计算机程序被运行时,使得计算机执行如第一方面的方法。In a fourth aspect, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the method of the first aspect.

第五方面,本申请实施例提供了一种芯片,芯片包括处理器,处理器用于调用存储器中的计算机程序,以执行如第一方面所述的方法。In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor, the processor being used to call a computer program in a memory to execute the method described in the first aspect.

应当理解的是,本申请的第二方面至第五方面与本申请的第一方面的技术方案相对应,各方面及对应的可行实施方式所取得的有益效果相似,不再赘述。It should be understood that the second to fifth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为可能的实现中的一种对焦方法;FIG1 is a focusing method in a possible implementation;

图2为本申请实施例提供的电子设备100的结构示意图;FIG. 2 is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application;

图3为本申请实施例提供的电子设备100的软件结构框图;FIG3 is a software structure block diagram of the electronic device 100 provided in an embodiment of the present application;

图4为本申请实施例提供的一种拍摄场景的示意图;FIG4 is a schematic diagram of a shooting scene provided in an embodiment of the present application;

图5为本申请实施例提供的处于非倾斜状态下的电子设备100的示意图;FIG5 is a schematic diagram of an electronic device 100 in a non-tilted state provided by an embodiment of the present application;

图6为本申请实施例提供的处于倾斜状态下的电子设备100的示意图;FIG6 is a schematic diagram of an electronic device 100 in a tilted state provided by an embodiment of the present application;

图7为本申请实施例提供的一种对焦方法的流程示意图;FIG7 is a schematic diagram of a flow chart of a focusing method provided in an embodiment of the present application;

图8为本申请实施例提供的倾斜角度的示意图;FIG8 is a schematic diagram of the tilt angle provided in an embodiment of the present application;

图9为本申请实施例提供的一种划分预设区间的示意图;FIG9 is a schematic diagram of dividing a preset interval provided in an embodiment of the present application;

图10为本申请实施例提供的另一种对焦方法的流程示意图;FIG10 is a schematic diagram of a flow chart of another focusing method provided in an embodiment of the present application;

图11为本申请实施例提供的一种对焦方法的流程示意图;FIG11 is a schematic diagram of a flow chart of a focusing method provided in an embodiment of the present application;

图12为本申请实施例示出的装置结构示意图。FIG. 12 is a schematic diagram of the device structure shown in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

为了便于清楚描述本申请实施例的技术方案,以下,对本申请实施例中所涉及的部分术语和技术进行简单介绍:In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:

1、对焦1. Focus

对焦是指相机通过调整物距和焦距使得被拍摄物体成像清晰的过程。电子设备通过调整聚焦镜头的位置获得最高的图片频率成分,以得到更高的图片对比度。其中,对焦是一个不断积累的过程,电子设备比较镜头在不同位置下拍摄的图片的对比度,从而获得图片的对比度最大时镜头的位置,进而确定对焦的焦距。Focusing refers to the process of adjusting the object distance and focal length of the camera to make the image of the object clear. The electronic device obtains the highest frequency component of the picture by adjusting the position of the focusing lens to obtain a higher picture contrast. Among them, focusing is a continuous accumulation process. The electronic device compares the contrast of the pictures taken by the lens at different positions to obtain the position of the lens when the contrast of the picture is the largest, and then determines the focal length for focusing.

在电子设备拍摄过程中,对焦主要涉及摄像头,摄像头也可称为相机(camera)模组,相机模组包括镜头、马达、马达驱动芯片和图像传感器(sensor)等器件。镜头(lens)用于接收光线,在电子设备可以包括一个或多个镜头。镜头一般可以由一片或几片透镜组成。图像传感器可以将穿过镜头的光线转化为电信号,之后将电信号转化为数字信号。马达用于推动镜片调整位置。马达驱动用于在自动对焦时确定马达推动镜头的位置。In the process of shooting with electronic devices, focusing mainly involves the camera, which can also be called a camera module. The camera module includes components such as a lens, a motor, a motor driver chip, and an image sensor. The lens is used to receive light, and an electronic device may include one or more lenses. The lens can generally be composed of one or more lenses. The image sensor can convert the light passing through the lens into an electrical signal, and then convert the electrical signal into a digital signal. The motor is used to push the lens to adjust its position. The motor drive is used to determine the position of the motor to push the lens during autofocus.

其中,镜头和感光芯片是成像的主要器件,马达和马达驱动芯片是对焦的主要器件。当物体在分别在远景和近景的时候,对应的成像位置是不同的,需要调整镜头和感光芯片的距离,使得感光芯片上始终可以获得清晰的成像效果。对于电子设备摄像头模组来说,电子设备需要通过马达推动镜头,使得镜头与感光芯片之间的距离(焦距),以及镜头与被拍摄物之间的距离(物距)发生变化。Among them, the lens and photosensitive chip are the main components for imaging, and the motor and motor driver chip are the main components for focusing. When the object is in the long view and the close view, the corresponding imaging position is different. It is necessary to adjust the distance between the lens and the photosensitive chip so that a clear imaging effect can always be obtained on the photosensitive chip. For the camera module of an electronic device, the electronic device needs to push the lens through a motor to change the distance between the lens and the photosensitive chip (focal length), and the distance between the lens and the object being photographed (object distance).

2、马达2. Motor

马达可用于推动镜片调整位置,实现对焦。马达可包括开环马达(open loop VCM)和闭环马达(closed loop VCM)。开环马达可理解为马达的输入是电流参数,输出是位移参数,且输入输出之间无反馈的过程。开环马达存在一定缺陷,在重力的影响下,开环马达存在姿势差。闭环马达中集成霍尔元件,闭环马达可准确的测量出镜头在x轴、y轴、及z轴方向上的位置并将镜头锁定,使得马达不受自身重力和拍照姿态的影响。但闭环马达零件结构复杂,制造工艺繁琐,成本较高;使得闭环马达成本上没有开环马达的优势。本申请实施例中,马达可以为开环马达。The motor can be used to push the lens to adjust its position and achieve focusing. The motor may include an open loop motor (open loop VCM) and a closed loop motor (closed loop VCM). The open loop motor can be understood as a process in which the input of the motor is a current parameter, the output is a displacement parameter, and there is no feedback between the input and output. There are certain defects in the open loop motor. Under the influence of gravity, the open loop motor has a posture difference. The closed loop motor integrates Hall elements. The closed loop motor can accurately measure the position of the lens in the x-axis, y-axis, and z-axis directions and lock the lens, so that the motor is not affected by its own gravity and the shooting posture. However, the closed loop motor has a complex structure of parts, a cumbersome manufacturing process, and a high cost, which makes the closed loop motor have no advantage over the open loop motor in terms of cost. In the embodiment of the present application, the motor may be an open loop motor.

为了便于清楚描述本申请实施例的技术方案,本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其他实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

本申请实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And/or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character "/" generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, c can be single or multiple.

需要说明的是,本申请实施例中的“在……时”,可以为在某种情况发生的瞬时,也可以为在某种情况发生后的一段时间内,本申请实施例对此不作具体限定。此外,本申请实施例提供的显示界面仅作为示例,显示界面还可以包括更多或更少的内容。It should be noted that the "at..." in the embodiment of the present application can be the instant when a certain situation occurs, or can be a period of time after a certain situation occurs, and the embodiment of the present application does not specifically limit this. In addition, the display interface provided in the embodiment of the present application is only an example, and the display interface can also include more or less content.

电子设备中可配置有摄像头,用户可基于电子设备进行拍摄照片和录制视频等活动。可能的实现中,当用户在使用电子设备进行拍摄时,电子设备可对画面中的物体进行对焦,使得被拍摄物体成像清晰。The electronic device may be equipped with a camera, and the user may take photos and record videos based on the electronic device. In a possible implementation, when the user uses the electronic device to take photos, the electronic device may focus on the object in the picture so that the image of the photographed object is clear.

但在一些场景中,电子设备可能无法显示清晰成像。例如,当用户使用电子设备仰拍或俯拍被拍摄物体时,电子设备显示的画面中被拍摄物体成像模糊,影响用户的拍摄体验。However, in some scenarios, the electronic device may not be able to display clear images. For example, when a user uses an electronic device to shoot an object from above or below, the image of the object in the picture displayed by the electronic device is blurred, affecting the user's shooting experience.

可以理解的是,电子设备基于相机模组实现拍摄功能,相机模组中包括镜头、马达和传感器等,马达可用于推动镜片调整位置,实现对焦。其中,马达可以为开环马达;对于开环马达,当电子设备倾斜放置时,受到自身重力的影响,马达产生姿势差,降低马达位置的准确性。而可能的实现中,为降低姿势差的影响,电子设备中设置有预设倾斜角度和该预设倾斜角度对应的标定值,电子设备可基于测量倾斜角度与预设倾斜角度的差值计算测量角度对应的补偿值。It is understandable that the electronic device realizes the shooting function based on the camera module, which includes a lens, a motor and a sensor, etc. The motor can be used to push the lens to adjust the position to achieve focus. Among them, the motor can be an open-loop motor; for an open-loop motor, when the electronic device is tilted, it is affected by its own gravity, and the motor produces a posture difference, which reduces the accuracy of the motor position. In a possible implementation, in order to reduce the influence of the posture difference, a preset tilt angle and a calibration value corresponding to the preset tilt angle are set in the electronic device, and the electronic device can calculate the compensation value corresponding to the measured angle based on the difference between the measured tilt angle and the preset tilt angle.

具体的,图1示出了可能的实现中的一种对焦方法的流程示意图。如图1所示:Specifically, FIG1 shows a schematic flow chart of a focusing method in a possible implementation. As shown in FIG1:

S101、电子设备得到测量倾斜角度。S101: The electronic device obtains a measured tilt angle.

电子设备倾斜放置时,电子设备的陀螺仪传感器可得到测量倾斜角度。When the electronic device is tilted, the gyroscope sensor of the electronic device can measure the tilt angle.

S102、电子设备根据测量倾斜角度、预设倾斜角度和该预设倾斜角度的标定值得到测量倾斜角度对应的补偿值。S102: The electronic device obtains a compensation value corresponding to the measured tilt angle according to the measured tilt angle, the preset tilt angle and a calibration value of the preset tilt angle.

可能的实现中,电子设备可基于下述公式计算测量倾斜角度对应的补偿值:In a possible implementation, the electronic device may calculate the compensation value corresponding to the measured tilt angle based on the following formula:

其中,x为测量倾斜角度,y为测量倾斜角度对应的补偿值,(x0,y0)可以为一组预设倾斜角度和该预设倾斜角度对应的标定值;(x1,y1)可以为另一组预设倾斜角度和该预设倾斜角度对应的标定值。Among them, x is the measured tilt angle, y is the compensation value corresponding to the measured tilt angle, (x0 , y0 ) can be a set of preset tilt angles and calibration values corresponding to the preset tilt angles; (x1 , y1 ) can be another set of preset tilt angles and calibration values corresponding to the preset tilt angles.

电子设备中设置了两个预设倾斜角度与该预设倾斜对应的标定值。例如,预设倾斜角度为30°时,该预设倾斜角度对应的标定值为a;预设倾斜角度为60°时,该预设倾斜角度对应的标定值为b。电子设备可基于给出的预设倾斜角度和标定值推导出其他倾斜角度下的补偿值。例如,测量倾斜角度为45°时,电子设备基于预设倾斜角度30°和60°的数据计算45°对应的补偿值。具体的:Two preset tilt angles and calibration values corresponding to the preset tilt are set in the electronic device. For example, when the preset tilt angle is 30°, the calibration value corresponding to the preset tilt angle is a; when the preset tilt angle is 60°, the calibration value corresponding to the preset tilt angle is b. The electronic device can derive compensation values at other tilt angles based on the given preset tilt angles and calibration values. For example, when the measured tilt angle is 45°, the electronic device calculates the compensation value corresponding to 45° based on the data of the preset tilt angles 30° and 60°. Specifically:

得到测量倾斜角度为45°时的补偿值y=(a+b)/2。The compensation value y=(a+b)/2 is obtained when the measured tilt angle is 45°.

S103、电子设备输出马达位置。S103, the electronic device outputs the motor position.

电子设备基于测量倾斜角度的补偿值调整马达位置。The electronics adjust the motor position based on a compensation value for the measured tilt angle.

经发现,当倾斜角度较小时,计算得到补偿值与真实的补偿值的误差较小;当倾斜角度较大时,计算得到补偿值与真实的补偿值的误差较大,倾斜角度与补偿值之间不是线性关系。但从对公式1进行求导可以看出,计算的补偿值与真实的补偿值之间的差值为定值;可能的实现中,将计算的补偿值与真实的补偿值之间的差值作为线性关系进行计算。当测量倾斜角度越大时,公式1所计算得到的补偿值与真实的补偿值之间的差值越大。所以,可能的实现中,电子设备的姿势越垂直,补偿值的误差越大,会出现补偿不准的问题。It is found that when the tilt angle is small, the error between the calculated compensation value and the actual compensation value is small; when the tilt angle is large, the error between the calculated compensation value and the actual compensation value is large, and there is no linear relationship between the tilt angle and the compensation value. However, it can be seen from the derivation of formula 1 that The difference between the calculated compensation value and the actual compensation value is a constant; in a possible implementation, the difference between the calculated compensation value and the actual compensation value is calculated as a linear relationship. When the measured tilt angle is larger, the difference between the compensation value calculated by formula 1 and the actual compensation value is larger. Therefore, in a possible implementation, the more vertical the posture of the electronic device is, the larger the error of the compensation value is, and the problem of inaccurate compensation may occur.

此外,可能的实现中,电子设备会标定一个补偿值阈值,补偿值阈值一般为物距处于无穷远时,超焦距位置和能够清楚显示被拍摄物体的马达最小位置之间的差值。电子设备可通过判定计算的补偿值是否大于补偿值阈值来检验计算结果的准确性,但由于各个角度下均需要使用同一补偿值阈值,所以,补偿值阈值往往大于计算的补偿值。补偿值阈值设置范围过大,能够起到的检验效果较小。In addition, in a possible implementation, the electronic device will calibrate a compensation value threshold, which is generally the difference between the hyperfocal position and the minimum position of the motor that can clearly display the photographed object when the object distance is infinite. The electronic device can verify the accuracy of the calculation result by determining whether the calculated compensation value is greater than the compensation value threshold, but because the same compensation value threshold needs to be used at all angles, the compensation value threshold is often greater than the calculated compensation value. The compensation value threshold setting range is too large, and the inspection effect can be small.

所以,在可能的实现中,在电子设备仰拍或俯拍时,电子设备计算的补偿值准确度较低,马达未将镜头推到较为准确的位置处,使得电子设备出现无法显示清晰成像,拍摄照片模糊的问题。Therefore, in a possible implementation, when the electronic device is shooting upward or downward, the compensation value calculated by the electronic device is less accurate, and the motor fails to push the lens to a more accurate position, causing the electronic device to be unable to display clear images and the photos taken are blurry.

有鉴于此,本申请实施例提供了一种对焦方法,通过对角度的区间进行细化,得到多个预设区间,以及得到任一预设区间对应的补偿值阈值;在对焦过程中,电子设备可查找当前倾斜角度对应的补偿值阈值,并使用补偿值阈值衡量补偿值的准确性;若补偿值小于补偿值阈值,则电子设备可使用该补偿值完成对焦。这样,对倾斜角度进行区域划分后,预设区域的补偿值阈值的精确度要高于可能的实现中标定的全角度对应的补偿值阈值,满足小于补偿值阈值条件的补偿值准确度较高,从而提升了马达补偿值的准确性,进而减少摄像头成像模糊的场景。In view of this, the embodiment of the present application provides a focusing method, which obtains multiple preset intervals by refining the angle interval, and obtains the compensation value threshold corresponding to any preset interval; during the focusing process, the electronic device can find the compensation value threshold corresponding to the current tilt angle, and use the compensation value threshold to measure the accuracy of the compensation value; if the compensation value is less than the compensation value threshold, the electronic device can use the compensation value to complete the focusing. In this way, after the tilt angle is divided into regions, the accuracy of the compensation value threshold of the preset region is higher than the compensation value threshold corresponding to the full angle calibrated in the possible implementation, and the compensation value that meets the condition of being less than the compensation value threshold is more accurate, thereby improving the accuracy of the motor compensation value, thereby reducing the scene of blurred camera imaging.

本申请实施例中,电子设备也可以称为:终端设备、终端(terminal)、用户设备(user equipment,UE)、移动台(mobile station,MS)、移动终端(mobile terminal,MT)等。终端设备可以是手机(mobile phone)、智能电视、可穿戴设备、平板电脑(Pad)、带无线收发功能的电脑、虚拟现实(virtual reality,VR)终端设备、增强现实(augmented reality,AR)终端设备、工业控制(industrial control)中的无线终端、无人驾驶(self-driving)中的无线终端、远程手术(remote medical surgery)中的无线终端、智能电网(smart grid)中的无线终端、运输安全(transportation safety)中的无线终端、智慧城市(smart city)中的无线终端、智慧家庭(smart home)中的无线终端等等。In the embodiments of the present application, the electronic device may also be referred to as: terminal device, terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The terminal device may be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc.

其中,可穿戴设备也可以称为穿戴式智能设备,是应用穿戴式技术对日常穿戴进行智能化设计、开发出可以穿戴的设备的总称,如眼镜、手套、手表、服饰及鞋等。可穿戴设备即直接穿在身上,或是整合到用户的衣服或配件的一种便携式设备。可穿戴设备不仅仅是一种硬件设备,更是通过软件支持以及数据交互、云端交互来实现强大的功能。广义穿戴式智能设备包括功能全、尺寸大、可不依赖智能手机实现完整或者部分的功能,例如:智能手表或智能眼镜等,以及只专注于某一类应用功能,需要和其它设备如智能手机配合使用,如各类进行体征监测的智能手环、智能首饰等。Among them, wearable devices can also be called wearable smart devices, which are a general term for the intelligent design and development of wearable devices for daily wear using wearable technology, such as glasses, gloves, watches, clothing and shoes. Wearable devices are portable devices that are worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also realize powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and independent of smartphones to achieve complete or partial functions, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.

此外,在本申请实施例中,电子设备还可以是物联网(internet of things,IoT)系统中的电子设备,IoT是未来信息技术发展的重要组成部分,其主要技术特点是将物品通过通信技术与网络连接,从而实现人机互连,物物互连的智能化网络。本申请的实施例对电子设备所采用的具体技术和具体设备形态不做限定。In addition, in the embodiments of the present application, the electronic device may also be an electronic device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection. The embodiments of the present application do not limit the specific technology and specific device form used by the electronic device.

在本申请实施例中,电子设备可以包括硬件层、运行在硬件层之上的操作系统层,以及运行在操作系统层上的应用层。该硬件层包括中央处理器(central processingunit,CPU)、内存管理单元(memory management unit,MMU)和内存(也称为主存)等硬件。该操作系统可以是任意一种或多种通过进程(process)实现业务处理的计算机操作系统,例如,Linux操作系统、Unix操作系统、Android操作系统、iOS操作系统或windows操作系统等。该应用层包含浏览器、通讯录、文字处理软件、即时通信软件等应用。In an embodiment of the present application, the electronic device may include a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system may be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.

为了能够更好地理解本申请实施例,下面对本申请实施例的电子设备的结构进行介绍:In order to better understand the embodiments of the present application, the structure of the electronic device in the embodiments of the present application is introduced below:

图2示出了电子设备100的结构示意图。电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,用户标识模块(subscriberidentification module,SIM)卡接口195,嵌入式安全元件(embedded secureelement,eSE)芯片196等。2 shows a schematic diagram of the structure of the electronic device 100. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, a subscriber identification module (SIM) card interface 195, an embedded secure element (eSE) chip 196, and the like.

其中,传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processingunit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

本申请实施例中,电子设备可使用处理器110执行对焦流程。In the embodiment of the present application, the electronic device may use the processor 110 to execute the focusing process.

控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从存储器中调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor.

本申请实施例中,电子设备可基于显示屏194显示拍摄的图像。In the embodiment of the present application, the electronic device can display the captured image based on the display screen 194.

电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

本申请实施例中,电子设备可基于NPU中的图像识别算法等检测拍摄场景。例如,电子设备拍摄月亮、云朵等目标物体时,电子设备可设置与该特定场景对应的补偿值阈值。In the embodiment of the present application, the electronic device may detect the shooting scene based on the image recognition algorithm in the NPU, etc. For example, when the electronic device shoots a target object such as the moon or clouds, the electronic device may set a compensation value threshold corresponding to the specific scene.

内部存储器121可以用于存储计算机可执行程序代码,可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and/or instructions stored in a memory provided in the processor.

陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,x,y和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

本申请实施例中,电子设备100可根据陀螺仪传感器上报的角速度数据计算得到电子设备的倾斜角度,以便于后续根据倾斜角度设置补偿值阈值。In the embodiment of the present application, the electronic device 100 can calculate the tilt angle of the electronic device according to the angular velocity data reported by the gyroscope sensor, so as to set the compensation value threshold according to the tilt angle later.

马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用程序(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

本申请实施例中,马达用于将镜头推动至对焦位置,以提升拍摄图像的清晰度。In the embodiment of the present application, the motor is used to push the lens to a focusing position to improve the clarity of the captured image.

电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构,等。本申请实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture, etc. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

图3是本申请实施例的电子设备100的软件结构框图。FIG. 3 is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统可以包括:应用程序层(applications)、应用程序框架层(application framework)、硬件抽象层(hardware abstract layer,HAL)以及内核层(kernel),其中,内核层可能成为驱动层。The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system may include: application layer (applications), application framework layer (application framework), hardware abstract layer (HAL) and kernel layer (kernel), where the kernel layer may become a driver layer.

应用程序层可以包括一系列应用程序包。The application layer can include a series of application packages.

如图3所示,应用程序包可以包括设置,日历,地图,电话,音乐,相机,邮箱,视频和社交等应用程序。As shown in FIG3 , the application package may include applications such as settings, calendar, map, phone, music, camera, mailbox, video, and social.

应用程序框架层为应用程序层的应用程序提供应用编程接口(applicationprogramming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

如图3所示,应用程序框架层可以包括窗口管理器,内容提供器,资源管理器,视图系统,通知管理器,相机访问接口等。As shown in FIG. 3 , the application framework layer may include a window manager, a content provider, a resource manager, a view system, a notification manager, a camera access interface, and the like.

其中,相机访问接口使得应用程序可以进行相机管理,访问相机设备。比如管理相机进行图像拍摄等。The camera access interface enables applications to manage cameras and access camera devices, such as managing cameras to capture images.

硬件抽象层,可以包含多个库模块。Android系统可以为设备硬件加载相应的库模块,进而实现应用程序框架层访问设备硬件的目的。The hardware abstraction layer can contain multiple library modules. The Android system can load the corresponding library modules for the device hardware, thereby enabling the application framework layer to access the device hardware.

本申请实施例中,硬件抽象层可包括对焦算法模块和检测模块。其中,对焦算法模块用于计算镜头的对焦位置;检测模块可用于检测图像中的物体,当被拍摄物体为目标物体时,根据目标物体设置对焦位置。In the embodiment of the present application, the hardware abstraction layer may include a focus algorithm module and a detection module. The focus algorithm module is used to calculate the focus position of the lens; the detection module can be used to detect objects in the image, and when the photographed object is a target object, the focus position is set according to the target object.

内核层是硬件和软件之间的层。内核层用于驱动硬件,使得硬件工作。内核层可以包含传感器驱动,摄像头驱动,马达驱动等,本申请实施例对此不做限制。The kernel layer is a layer between hardware and software. The kernel layer is used to drive the hardware to make the hardware work. The kernel layer may include sensor driver, camera driver, motor driver, etc., which is not limited in the embodiments of the present application.

硬件层可以包括各种类型的硬件设备,例如,硬件层包括传感器、摄像头和马达,传感器可以为陀螺仪传感器。The hardware layer may include various types of hardware devices. For example, the hardware layer includes sensors, cameras, and motors. The sensor may be a gyroscope sensor.

下面结合图3说明本申请实施例的对焦方法可能的实现方式。The following describes a possible implementation of the focusing method of an embodiment of the present application in conjunction with FIG. 3 .

一种可能的实现方式中,电子设备启动相机应用后,电子设备可通过相机应用调用应用程序框架层的相机访问接口,相机访问接口管理硬件抽象层的对焦算法模块,以使内核层实现帧图像和IMU数据的获取,获取的帧图像和IMU数据进一步在对焦算法模块中经过本申请实施例的对焦算法的计算后,向马达驱动输出更加精准的对焦值,马达驱动则根据对焦值调整马达位置,以实现摄像头对焦。在完成对焦后,摄像头可将拍摄的对焦后的帧图像依次经过内核层、硬件抽象层和应用程序框架层上报到相机应用,电子设备的显示屏显示对焦后的帧图像。In one possible implementation, after the electronic device starts the camera application, the electronic device can call the camera access interface of the application framework layer through the camera application. The camera access interface manages the focus algorithm module of the hardware abstraction layer so that the kernel layer can obtain frame images and IMU data. The acquired frame images and IMU data are further calculated by the focus algorithm of the embodiment of the present application in the focus algorithm module, and a more accurate focus value is output to the motor driver. The motor driver adjusts the motor position according to the focus value to achieve camera focus. After completing the focus, the camera can report the captured focused frame image to the camera application through the kernel layer, the hardware abstraction layer and the application framework layer in sequence, and the display screen of the electronic device displays the focused frame image.

可选的,本申请实施例中对焦方法可涉及目标物体的拍摄场景,对焦算法模块可调用检测模块,对帧图像中的被拍摄物体进行图像识别,当被拍摄物体为目标物体时,对焦算法模块可向马达驱动下发与目标物体对应的对焦值,并控制镜头实现对焦。后续电子设备的显示屏可显示更加清晰的被拍摄物体。Optionally, the focusing method in the embodiment of the present application may involve a shooting scene of a target object, and the focusing algorithm module may call the detection module to perform image recognition on the object being shot in the frame image. When the object being shot is the target object, the focusing algorithm module may send a focus value corresponding to the target object to the motor driver and control the lens to achieve focusing. The display screen of the subsequent electronic device can display the object being shot more clearly.

下面先结合图4对本申请实施例提供的对焦方法所适用的场景进行说明。图4示出了本申请实施例提供的一种对焦方法的场景示意图。如图4所示:The following first describes the applicable scenario of the focusing method provided by the embodiment of the present application in conjunction with FIG4. FIG4 shows a scenario schematic diagram of a focusing method provided by the embodiment of the present application. As shown in FIG4:

电子设备启动相机应用,当电子设备如图4所示放置时,电子设备可拍摄高处的物体,实现仰拍。这时,电子设备处于倾斜状态,电子设备可使用本申请实施例提供的对焦方法,得到马达位置的补偿值,以使电子设备得到更加准确的马达位置,提升成片的清晰度。The electronic device starts the camera application, and when the electronic device is placed as shown in FIG4 , the electronic device can shoot high objects and achieve upward shooting. At this time, the electronic device is in a tilted state, and the electronic device can use the focusing method provided in the embodiment of the present application to obtain the compensation value of the motor position, so that the electronic device can obtain a more accurate motor position and improve the clarity of the film.

以电子设备横屏放置为例,图5示出了一种处于非倾斜状态下的电子设备100。例如,在图5中的a图中,电子设备100所处平面与重力方向平行,且电子设备的一边缘与重力方向平行,一边缘与重力方向垂直。电子设备100处于非倾斜状态;其中,Z轴与重力方向平行;X轴与重力方向垂直,且X轴与电子设备100的显示屏共面;Y轴与重力方向垂直,且Y轴垂直于电子设备100的显示屏。Taking the horizontal screen placement of an electronic device as an example, FIG5 shows an electronic device 100 in a non-tilted state. For example, in FIG5 a, the plane where the electronic device 100 is located is parallel to the direction of gravity, and one edge of the electronic device is parallel to the direction of gravity, and one edge is perpendicular to the direction of gravity. The electronic device 100 is in a non-tilted state; wherein the Z axis is parallel to the direction of gravity; the X axis is perpendicular to the direction of gravity, and the X axis is coplanar with the display screen of the electronic device 100; the Y axis is perpendicular to the direction of gravity, and the Y axis is perpendicular to the display screen of the electronic device 100.

具体的,图5中的b图示出了电子设备100在X轴方向上的投影,在Y-Z坐标系下,矩形可理解为电子设备100在X轴方向的投影,矩形的Y值可以为电子设备的厚度;电子设备100中设置有摄像头193,摄像头193可以为后置摄像头或前置摄像头。Specifically, Figure b in Figure 5 shows the projection of the electronic device 100 in the X-axis direction. In the Y-Z coordinate system, the rectangle can be understood as the projection of the electronic device 100 in the X-axis direction, and the Y value of the rectangle can be the thickness of the electronic device; the electronic device 100 is provided with a camera 193, and the camera 193 can be a rear camera or a front camera.

从图5中的b图中可以看出,在非倾斜状态下,Y轴所处方向可以为摄像头193的镜头延伸的方向,也就是说,摄像头193的延伸直线L与Y轴的夹角为0,这时可视为倾斜角度为0。It can be seen from Figure b in Figure 5 that in the non-tilted state, the direction of the Y axis can be the direction in which the lens of the camera 193 extends, that is, the angle between the extended straight line L of the camera 193 and the Y axis is 0, and the tilt angle can be regarded as 0 at this time.

可以理解的是,当电子设备100处于非倾斜状态时,马达在推动镜头移动时,受重力影响很小或不受重力影响,所以将镜头延伸方向与水平方向的y轴夹角为0时,设置为非倾斜状态。It is understandable that when the electronic device 100 is in a non-tilted state, the motor is little affected by gravity or not affected by gravity when pushing the lens to move, so when the angle between the lens extension direction and the horizontal y-axis is 0, it is set to a non-tilted state.

以电子设备横屏放置,且电子设备100处于图4所示的仰拍场景为例,图6中的a图示出了一种处于倾斜状态下的电子设备100。例如,在Y-Z坐标系下,用户通过倾斜电子设备100,以使电子设备100能够拍摄到高处的景象。电子设备处于倾斜状态,倾斜角度可以为摄像头193的镜头延伸方向L与Y轴的夹角θ,其中,当电子设备进行仰拍时,θ的取值范围可以为0-90°。Taking the electronic device placed horizontally and the electronic device 100 in the upward shooting scene shown in FIG. 4 as an example, FIG. 6 a shows an electronic device 100 in a tilted state. For example, in the Y-Z coordinate system, the user tilts the electronic device 100 so that the electronic device 100 can capture a scene at a high place. The electronic device is in a tilted state, and the tilt angle can be the angle θ between the extension direction L of the lens of the camera 193 and the Y axis, wherein when the electronic device is shooting upward, the value range of θ can be 0-90°.

以电子设备横屏放置,且电子设备100处于俯拍场景为例,图6中的b图示出了另一种处于倾斜状态下的电子设备100。例如,在Y-Z坐标系下,用户通过倾斜电子设备100,以使电子设备100能够拍摄到低处的景象。电子设备处于倾斜状态,倾斜角度可以为摄像头193的镜头延伸方向L与y轴的夹角θ,其中,当电子设备进行俯拍时,θ的取值范围可以为-90°-0°。Taking the electronic device placed horizontally and the electronic device 100 in a top-down shooting scene as an example, FIG. 6 b shows another electronic device 100 in a tilted state. For example, in the Y-Z coordinate system, the user tilts the electronic device 100 so that the electronic device 100 can shoot a low scene. The electronic device is in a tilted state, and the tilt angle can be the angle θ between the lens extension direction L of the camera 193 and the y-axis, wherein when the electronic device is shooting from a top, the value range of θ can be -90°-0°.

本申请实施例提供的对焦方法可适用于俯拍、仰拍等非水平拍摄的场景中,本申请实施例对此不作限制。The focusing method provided in the embodiment of the present application can be applied to non-horizontal shooting scenes such as overhead shooting and upward shooting, and the embodiment of the present application is not limited to this.

需要说明的是,本申请实施例以相机应用为例对对焦方法的使用场景进行了说明,本申请实施例中,该方法也可适用于其他场景,例如,电子设备基于社交应用启动摄像头。本申请实施例对此不做限制。It should be noted that the embodiment of the present application takes the camera application as an example to illustrate the use scenario of the focusing method. In the embodiment of the present application, the method can also be applied to other scenarios, for example, the electronic device starts the camera based on a social application. The embodiment of the present application does not limit this.

以上实施例对电子设备的倾斜状态和倾斜角度进行了说明,下面结合图7对本申请实施例提供的对焦方法的流程进行说明。图7示出了本申请实施例提供的一种对焦方法的流程示意图,如图7所示:The above embodiments describe the tilt state and tilt angle of the electronic device. The following describes the process of the focusing method provided by the embodiment of the present application in conjunction with FIG7. FIG7 shows a schematic flow chart of a focusing method provided by the embodiment of the present application, as shown in FIG7:

S701、电子设备启动相机应用。S701. The electronic device starts a camera application.

电子设备启动相机应用后,电子设备可使用摄像头拍摄图像。After the electronic device launches the camera application, the electronic device can use the camera to capture images.

本申请实施例中,电子设备也可使用其他应用启动摄像头,例如,社交应用。本申请实施例对此不作限制。In the embodiment of the present application, the electronic device may also use other applications to start the camera, for example, a social application, which is not limited in the embodiment of the present application.

S702、电子设备的对焦算法模块得到计算对焦值。S702: A focus algorithm module of the electronic device obtains a calculated focus value.

对焦算法模块可以为自动对焦(automatic focus,AF)算法模块,其中,AF算法可以为激光对焦(time of flight,TOF)、反差式自动对焦(contrast automatic focus,CAF)和相位探测自动对焦(phase detection automatic focus,PDAF)等。对焦算法模块可基于AF算法计算对焦值。例如,以PDAF算法为例,当电子设备拍摄被拍摄物体时,对焦算法模块的传感器可采集一个或多个成像;若成像的数量为一,则说明当前镜头的位置为对焦位置;若成像的数量为两个,对焦算法模块可根据两个成像之间的相位差调整对焦位置。The focus algorithm module may be an automatic focus (AF) algorithm module, wherein the AF algorithm may be laser focus (time of flight, TOF), contrast automatic focus (CAF) and phase detection automatic focus (PDAF), etc. The focus algorithm module may calculate the focus value based on the AF algorithm. For example, taking the PDAF algorithm as an example, when the electronic device photographs the photographed object, the sensor of the focus algorithm module may collect one or more images; if the number of images is one, it means that the position of the current lens is the focus position; if the number of images is two, the focus algorithm module may adjust the focus position according to the phase difference between the two images.

计算对焦值可以为电子设备处于非倾斜状态时的对焦位置;计算对焦值可以是对焦算法模块基于AF算法计算得到的;电子设备可根据计算对焦值控制马达,以使马达将镜头推动到能够清晰拍摄图像的位置。可以理解的是,计算对焦值是电子设备在非倾斜状态下的对焦位置,而本申请实施例中,马达控制镜头移动计算对焦值之后,由于电子设备处于倾斜状态,马达会受到重力影响,使得计算对焦值与最佳的对焦位置(真实对焦位置)之间存在误差,所以,本申请实施例中,电子设备后续可通过步骤S703-S711对计算对焦值进行修正,从而提升马达位置的准确度。The calculated focus value may be the focus position when the electronic device is in a non-tilted state; the calculated focus value may be calculated by the focus algorithm module based on the AF algorithm; the electronic device may control the motor according to the calculated focus value so that the motor pushes the lens to a position where it can clearly capture an image. It is understandable that the calculated focus value is the focus position of the electronic device in a non-tilted state, and in the embodiment of the present application, after the motor controls the lens to move the calculated focus value, since the electronic device is in a tilted state, the motor will be affected by gravity, resulting in an error between the calculated focus value and the optimal focus position (real focus position). Therefore, in the embodiment of the present application, the electronic device may subsequently correct the calculated focus value through steps S703-S711 to improve the accuracy of the motor position.

可以理解的是,步骤S702中,电子设备可采用TOF、CAF或DAF等算法计算可到计算对焦值,本申请实施例对计算对焦值不做限制。本申请实施例中,计算对焦值可以为电子设备基于AF算法得到的对焦位置,在步骤S702时,马达可处于计算对焦值处。It is understandable that in step S702, the electronic device may use an algorithm such as TOF, CAF or DAF to calculate the calculated focus value, and the embodiment of the present application does not limit the calculated focus value. In the embodiment of the present application, the calculated focus value may be a focus position obtained by the electronic device based on an AF algorithm, and in step S702, the motor may be at the calculated focus value.

S703、电子设备的陀螺仪传感器采集惯性测量单元(inertial measurementunit,IMU)数据,并上报至对焦算法模块。S703: The gyroscope sensor of the electronic device collects inertial measurement unit (IMU) data and reports it to the focus algorithm module.

陀螺仪传感器可通过IMU数据反映电子设备的倾斜状态;其中,IMU数据可以包括x轴方向的角速度、y轴方向的角速度和z轴方向的角速度等。例如,IMU数据可以为gSensor.x、gSensor.y和gSensor.z。硬件层的陀螺仪传感器可采集IMU数据,随后,将IMU数据上报至硬件抽象层的对焦算法模块。由对焦算法模块对IMU数据进行处理。The gyroscope sensor can reflect the tilt state of the electronic device through IMU data; wherein the IMU data may include the angular velocity in the x-axis direction, the angular velocity in the y-axis direction, and the angular velocity in the z-axis direction. For example, the IMU data may be gSensor.x, gSensor.y, and gSensor.z. The gyroscope sensor in the hardware layer can collect IMU data, and then report the IMU data to the focus algorithm module in the hardware abstraction layer. The focus algorithm module processes the IMU data.

需要说明的时,在电子设备启动目标应用后,电子设备可同时执行步骤S702和步骤S703,也可先后执行步骤S702和步骤S703,且本申请实施例对步骤S702和步骤S703的先后顺序不做限制。It should be noted that after the electronic device starts the target application, the electronic device may execute step S702 and step S703 simultaneously, or may execute step S702 and step S703 sequentially, and the embodiment of the present application does not limit the order of step S702 and step S703.

S704、电子设备的对焦算法模块得到IMU数据,并基于IMU数据得到电子设备的倾斜角度。S704: The focus algorithm module of the electronic device obtains IMU data, and obtains a tilt angle of the electronic device based on the IMU data.

对焦算法模块可基于IMU数据计算的到倾斜角度。The focus algorithm module can calculate the tilt angle based on IMU data.

以仰拍场景为例,电子设备处于倾斜状态,如图8所示。例如,一种可能的实现方式中,倾斜角度θ,可满足下述公式:Taking the upward shooting scene as an example, the electronic device is in a tilted state, as shown in FIG8. For example, in a possible implementation, the tilt angle θ may satisfy the following formula:

其中,b为竖直方向的角速度;c为水平方向的角速度,例如,b为z轴方向的角速度,c为x轴方向的角速度与y轴方向的角速度叠加后的角速度。Among them, b is the angular velocity in the vertical direction; c is the angular velocity in the horizontal direction, for example, b is the angular velocity in the z-axis direction, and c is the angular velocity obtained by superimposing the angular velocity in the x-axis direction and the angular velocity in the y-axis direction.

具体的:Specific:

另一种可能的实现方式中,对焦算法模块也可基于θ=arcsin(b/a)或θ=arccos(c/a)等公式计算得到θ值,本申请实施例对此不做限制。其中,a为x轴方向的角速度、y轴方向的角速度和z轴方向的角速度叠加后的角速度。In another possible implementation, the focus algorithm module can also calculate the θ value based on the formula θ=arcsin(b/a) or θ=arccos(c/a), etc., and the embodiment of the present application does not limit this. Wherein, a is the angular velocity of the angular velocity in the x-axis direction, the angular velocity in the y-axis direction, and the angular velocity in the z-axis direction.

其中,in,

具体的:Specific:

或者or

对焦算法模块基于上述方法得到倾斜角度θ。The focusing algorithm module obtains the tilt angle θ based on the above method.

S705、电子设备的对焦算法模块根据倾斜角度查找预设区间对应的补偿值阈值。S705: The focus algorithm module of the electronic device searches for a compensation value threshold corresponding to a preset interval according to the tilt angle.

预设区间中的值包括该倾斜角度,该预设区间对应有补偿值阈值。The value in the preset interval includes the tilt angle, and the preset interval corresponds to a compensation value threshold.

示例性的,电子设备中设置有预设列表,该预设列表中包括不同预设区间以及不同预设区间对应的补偿值阈值。本申请实施例中,可将倾斜角度进行划分,得到多个预设区间,例如:预设区间1、预设区间2、预设区间3……预设区间N等。预设列表中包括预设区间与补偿值阈值的对应关系。例如,预设区间1对应补偿值阈值1,预设区间2对应补偿值阈值2,预设区间3对应补偿值阈值3……预设区间N对应补偿值阈值N等。Exemplarily, a preset list is provided in the electronic device, and the preset list includes different preset intervals and compensation value thresholds corresponding to different preset intervals. In the embodiment of the present application, the tilt angle can be divided to obtain multiple preset intervals, for example: preset interval 1, preset interval 2, preset interval 3... preset interval N, etc. The preset list includes a correspondence between the preset intervals and the compensation value thresholds. For example, preset interval 1 corresponds to compensation value threshold 1, preset interval 2 corresponds to compensation value threshold 2, preset interval 3 corresponds to compensation value threshold 3... preset interval N corresponds to compensation value threshold N, etc.

其中,任一预设区间中的倾斜角度的值不重合。The values of the inclination angles in any preset interval do not overlap.

本申请实施例后续会对预设列表中的预设区间的划分规则和补偿值阈值的设置方法进行说明,此处不做详细说明。The embodiments of the present application will later describe the division rules of the preset intervals in the preset list and the method for setting the compensation value threshold, which will not be described in detail here.

S706、电子设备的对焦算法模块使用倾斜角度计算补偿值。S706: The focus algorithm module of the electronic device calculates a compensation value using the tilt angle.

一种可能的实现方式中,倾斜角度θ的补偿值(offset)可以满足下述公式:In a possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

offset=sinθ×offset0 (7)offset=sinθ×offset0 (7)

其中,offset0为默认补偿值,offset0可以为倾斜角度为±90°时的补偿值。Among them, offset0 is a default compensation value, and offset0 can be a compensation value when the tilt angle is ±90°.

另一种可能的实现方式中,倾斜角度θ的补偿值(offset)可以满足下述公式:In another possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

电子设备计算得到倾斜角度后,可基于公式(7)或公式(8)得到该倾斜角度下的补偿值。After the electronic device calculates the tilt angle, it can obtain the compensation value at the tilt angle based on formula (7) or formula (8).

S707、当补偿值小于补偿值阈值时,电子设备的对焦算法模块基于补偿值和计算对焦值得到马达待调整位置。S707: When the compensation value is less than the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value and the calculated focus value.

马达待调整位置可以为用于指示马达推动位置的对焦值。马达待调整位置可以为电子设备根据倾斜角度对计算对焦值进行修正后得到的较为准确的对焦值。当镜头位于马达待调整位置时,电子设备的摄像头可得到清晰的图像。The motor position to be adjusted may be a focus value for indicating the motor push position. The motor position to be adjusted may be a relatively accurate focus value obtained by the electronic device after correcting the calculated focus value according to the tilt angle. When the lens is located at the motor position to be adjusted, the camera of the electronic device can obtain a clear image.

可以理解的是,补偿值小于补偿值阈值,说明电子设备在该倾斜角度时,电子设备修正后的对焦位置(马达待调整位置)与真实对焦位置之间的误差较小,镜头位于马达待调整位置时,电子设备可以较为清晰的拍摄被拍摄物体。It can be understood that the compensation value is less than the compensation value threshold, which means that when the electronic device is at this tilt angle, the error between the corrected focus position of the electronic device (the motor position to be adjusted) and the actual focus position is small. When the lens is in the motor position to be adjusted, the electronic device can capture the object more clearly.

S708、电子设备的对焦算法模块将马达待调整位置下发至马达驱动。S708: The focus algorithm module of the electronic device sends the motor position to be adjusted to the motor driver.

S709、电子设备的马达驱动根据马达待调整位置调整马达位置。S709: The motor driver of the electronic device adjusts the motor position according to the motor position to be adjusted.

S710、电子设备在目标应用的界面中显示对焦后的图像。S710: The electronic device displays the focused image in the interface of the target application.

马达驱动芯片可根据马达待调整位置调整马达位置,从而使得镜头到达修正后的对焦位置处。这样,在电子设备调整镜头位置后,镜头位于对焦位置,使得摄像头可以获得清晰的成像效果。The motor driver chip can adjust the motor position according to the motor position to be adjusted, so that the lens reaches the corrected focus position. In this way, after the electronic device adjusts the lens position, the lens is located at the focus position, so that the camera can obtain a clear imaging effect.

或者,在步骤S706之后,还包括:Alternatively, after step S706, the method further includes:

S711、当补偿值大于或等于补偿值阈值时,电子设备的对焦算法模块基于补偿值阈值和计算对焦值得到马达待调整位置。S711: When the compensation value is greater than or equal to the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value threshold and the calculated focus value.

可以理解的是,补偿值大于补偿值阈值,可能当前倾斜角度较大,电子设备在该倾斜角度下,补偿值与最佳的补偿值(真实补偿值)之间的误差很大,电子设备仍然使用补偿值修正对焦位置的话,得到的对焦位置与真实对焦位置之间的误差也会很大。为降低误差,电子设备可通过缩小补偿值。一种可能的实现方式中,补偿值阈值小于或等于补偿值,所以补偿值阈值与真实补偿值之间的误差要小于补偿值与真实补偿值之间的误差。It is understandable that if the compensation value is greater than the compensation value threshold, it is possible that the current tilt angle is large. At this tilt angle, the error between the compensation value and the optimal compensation value (real compensation value) of the electronic device is large. If the electronic device still uses the compensation value to correct the focus position, the error between the obtained focus position and the real focus position will also be large. To reduce the error, the electronic device can reduce the compensation value. In one possible implementation, the compensation value threshold is less than or equal to the compensation value, so the error between the compensation value threshold and the real compensation value is smaller than the error between the compensation value and the real compensation value.

当电子设备通过将补偿值阈值计算马达待调整位置时,能够减少计算对焦位置与真实对焦位置之间的误差。When the electronic device calculates the position to be adjusted of the motor by using the compensation value threshold, the error between the calculated focus position and the actual focus position can be reduced.

之后,电子设备可执行步骤S708-S710。Afterwards, the electronic device may execute steps S708-S710.

可选的,在本申请实施例中,可根据下述方法设置预设列表中的预设区间。Optionally, in an embodiment of the present application, the preset interval in the preset list may be set according to the following method.

a)计算任一倾斜角度的计算补偿值。a) Calculate the compensation value for any tilt angle.

倾斜角度的取值范围可以为-90°-90°。The tilt angle can range from -90° to 90°.

一种可能的实现方式中,倾斜角度θ的补偿值(offset)可以满足下述公式:In a possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

offset=sinθ×offset0 (9)offset=sinθ×offset0 (9)

其中,offset0为默认补偿值。Among them, offset0 is the default compensation value.

另一种可能的实现方式中,倾斜角度θ的补偿值(offset)可以满足下述公式:In another possible implementation, the compensation value (offset) of the tilt angle θ may satisfy the following formula:

本申请实施例中,第一电子设备可根据公式(9)或公式(10)计算倾斜角度θ对应的计算补偿值,其中,公式(9)可以理解为公式(10)简化后的公式,上述两个公式的公式原理相同。In an embodiment of the present application, the first electronic device can calculate the compensation value corresponding to the tilt angle θ according to formula (9) or formula (10), wherein formula (9) can be understood as a simplified formula of formula (10), and the formula principles of the above two formulas are the same.

b)得到任一倾斜角度的真实补偿值。b) Get the true compensation value for any tilt angle.

第一电子设备可通过测量实验得到真实对焦值,并通过真实对焦值与计算对焦值的差值得到真实补偿值。真实对焦值可理解为:镜头能够清晰成像时,镜头(或马达)所在的理论对焦值。计算对焦值可理解为:第一电子设备基于对焦算法得到的非倾斜状态下的对焦值。二者之间的差值可以为真实补偿值。The first electronic device can obtain the real focus value through measurement experiments, and obtain the real compensation value through the difference between the real focus value and the calculated focus value. The real focus value can be understood as: the theoretical focus value of the lens (or motor) when the lens can form a clear image. The calculated focus value can be understood as: the focus value in a non-tilted state obtained by the first electronic device based on the focusing algorithm. The difference between the two can be the real compensation value.

其中,对焦算法可包括:反差式(contrast)对焦算法和相位探测(phasedetection,PD)等对焦算法等。The focusing algorithm may include: a contrast focusing algorithm and a phase detection (PD) focusing algorithm.

c)统计任一倾斜角度下真实补偿值与计算补偿值的差值。c) Count the difference between the actual compensation value and the calculated compensation value at any tilt angle.

第一电子设备可计算得到任一倾斜角度下的真实补偿值与计算补偿值的差值,基于各个倾斜角度下的差值绘制补偿值误差的曲线。The first electronic device can calculate the difference between the actual compensation value and the calculated compensation value at any tilt angle, and draw a curve of the compensation value error based on the difference at each tilt angle.

其中,图9示出了任一倾斜角度下的真实补偿值与计算补偿值的误差曲线,如图9所示:FIG9 shows an error curve between the actual compensation value and the calculated compensation value at any tilt angle, as shown in FIG9 :

以倾斜角度θ为0-90°为例:Take the tilt angle θ of 0-90° as an example:

图9中,横坐标为倾斜角度θ,纵坐标为真实补偿值与计算补偿值的误差。可以看出,当倾斜角度较小时,真实补偿值与计算补偿值的误差随倾斜角度的变化趋势可视为呈线性增长;例如,在0-40°时,倾斜角度与误差呈线性关系。而随着倾斜角度逐渐增大,误差的增长趋势变缓,呈现非线性增长趋势;例如,在40°-90°时,倾斜角度与误差呈非线性关系。In Figure 9, the horizontal axis is the tilt angle θ, and the vertical axis is the error between the real compensation value and the calculated compensation value. It can be seen that when the tilt angle is small, the error between the real compensation value and the calculated compensation value can be regarded as a linear growth with the change trend of the tilt angle; for example, at 0-40°, the tilt angle and the error are linearly related. As the tilt angle gradually increases, the growth trend of the error slows down and presents a nonlinear growth trend; for example, at 40°-90°, the tilt angle and the error are nonlinearly related.

本申请实施例示例性的示出了真实补偿值与计算补偿值的差值和倾斜角度的关系,但该曲线中的数据不对本申请实施例造成限制。The embodiment of the present application exemplarily shows the relationship between the difference between the actual compensation value and the calculated compensation value and the tilt angle, but the data in the curve does not limit the embodiment of the present application.

d)计算最大误差,并根据景深(depth of field,DOF)得到各个预设区间。d) Calculate the maximum error and obtain each preset interval according to the depth of field (DOF).

景深是指在摄像头的镜头能够取得清晰图像的成像所测定的被拍摄物体前后距离范围。本申请实施例中,可根据景深划分角度区间。The depth of field refers to the range of distances in front and behind the object being photographed measured when the camera lens can obtain a clear image. In the embodiment of the present application, the angle intervals can be divided according to the depth of field.

可以理解的是,在拍摄场景中,当镜头位于真实对焦位置的一定范围内,摄像头可以采集到清晰的图像,该范围可以为一个景深。步骤c)中的计算补偿值与真实补偿值的误差也可以近似为计算对焦值与真实对焦值的误差,当误差较小时,例如,误差在一个景深内,摄像头是可以采集到清晰的图像的;而当误差增大到两个景深的长度时,摄像头采集到的图像的清晰度要小于误差=1个景深时图像的清晰度,以此类推,误差为N个景深时图像的清晰度小于误差为N-1个景深时图像的清晰度。所以,本申请实施例可通过景深的长度衡量该长度的误差下,拍摄图像的清晰度。It is understandable that in a shooting scene, when the lens is within a certain range of the actual focus position, the camera can capture a clear image, and the range can be a depth of field. The error between the calculated compensation value and the actual compensation value in step c) can also be approximated as the error between the calculated focus value and the actual focus value. When the error is small, for example, the error is within one depth of field, the camera can capture a clear image; and when the error increases to the length of two depths of field, the clarity of the image captured by the camera is less than the clarity of the image when the error = 1 depth of field, and so on. The clarity of the image when the error is N depths of field is less than the clarity of the image when the error is N-1 depths of field. Therefore, the embodiment of the present application can measure the clarity of the captured image under the error of the length by the length of the depth of field.

本申请实施例中,预设区间的数量N可满足下述公式:In the embodiment of the present application, the number N of preset intervals may satisfy the following formula:

其中,Δoffsetmax可以为倾斜角度中真实补偿值与计算补偿值的最大误差,d可以为景深的长度,景深例如为7。Wherein, Δoffsetmax may be the maximum error between the real compensation value and the calculated compensation value in the tilt angle, and d may be the length of the depth of field, which may be 7, for example.

例如,在图9中,N值为7,其中,倾斜角度在0-9°时,误差在1个景深内;倾斜角度在9°-18°时,误差在2个景深内;倾斜角度在18-28°时,误差在3个景深内;倾斜角度在28°-38°时,误差在4个景深内;倾斜角度在38°-51°时,误差在5个景深内;倾斜角度在51°-70°时,误差在6个景深内;倾斜角度在70°-90°时,误差在7个景深内。For example, in Figure 9, the N value is 7, wherein, when the tilt angle is 0-9°, the error is within 1 depth of field; when the tilt angle is 9°-18°, the error is within 2 depths of field; when the tilt angle is 18°-28°, the error is within 3 depths of field; when the tilt angle is 28°-38°, the error is within 4 depths of field; when the tilt angle is 38°-51°, the error is within 5 depths of field; when the tilt angle is 51°-70°, the error is within 6 depths of field; when the tilt angle is 70°-90°, the error is within 7 depths of field.

以上对预设区间的范围参数的举例并不对本申请实施例中的预设区间造成限制。The above examples of range parameters of the preset interval do not limit the preset interval in the embodiments of the present application.

e)得到各个角度区间对应的补偿值阈值。e) Obtain the compensation value threshold corresponding to each angle interval.

一种可能的实现方式中,可通过实验测量结果得到任一区间对应的补偿值阈值。In a possible implementation, the compensation value threshold corresponding to any interval may be obtained through experimental measurement results.

示例性的,以一个预设区间为例,可设置多个数值;分别将数值作为补偿值阈值待入步骤S701-S711,得到摄像头在该补偿值阈值下采集的多张图像;比较多张图像的清晰度,将清晰度最高的图像所对应的数值作为该角度区间下的补偿值阈值。Exemplarily, taking a preset interval as an example, multiple numerical values can be set; the numerical values are respectively used as compensation value thresholds to enter steps S701-S711 to obtain multiple images captured by the camera under the compensation value threshold; the clarity of the multiple images is compared, and the numerical value corresponding to the image with the highest clarity is used as the compensation value threshold under the angle interval.

以此类推,可得到任一预设区间所对应的补偿值阈值。By analogy, the compensation value threshold corresponding to any preset interval can be obtained.

第一电子设备可将预设区间与补偿值阈值的对应关系预置在电子设备的预设列表中,以供电子设备使用。The first electronic device may preset the correspondence between the preset interval and the compensation value threshold in a preset list of the electronic device for use by the electronic device.

需要说明的是,步骤a)-步骤e)为后端的测试过程,该过程中的第一电子设备与步骤S701-S711中的电子设备不是同一电子设备,本申请实施例对此进行说明。It should be noted that step a) to step e) are a back-end testing process, and the first electronic device in this process is not the same electronic device as the electronic device in steps S701-S711, which is explained in the embodiments of the present application.

在本申请实施例中,电子设备基于步骤S701-S711的对焦方法得到第二对焦值可能不适用于一些长焦拍摄的场景中,电子设备可针对特定场景中的目标物体设置马达待调整位置,以使电子设备在该场景中能够准确对焦。示例性的,图10示出了本申请实施例提供的一种对焦方法的流程示意图,如图10所示:In the embodiment of the present application, the second focus value obtained by the electronic device based on the focusing method of steps S701-S711 may not be applicable to some telephoto shooting scenes. The electronic device can set the motor position to be adjusted for the target object in the specific scene so that the electronic device can accurately focus in the scene. For example, FIG10 shows a flow chart of a focusing method provided in the embodiment of the present application, as shown in FIG10:

S1001、电子设备启动目标应用。S1001. The electronic device starts a target application.

S1002、电子设备的对焦算法模块得到计算对焦值。S1002: A focus algorithm module of the electronic device obtains a calculated focus value.

S1003、电子设备的陀螺仪传感器采集IMU数据,并上报至对焦算法模块。S1003: The gyroscope sensor of the electronic device collects IMU data and reports it to the focus algorithm module.

S1004、电子设备的对焦算法模块得到IMU数据,并基于IMU数据得到电子设备的倾斜角度。S1004: The focus algorithm module of the electronic device obtains IMU data, and obtains a tilt angle of the electronic device based on the IMU data.

步骤S1001-S1004可参考步骤S701-S704中的相关描述,此处不再赘述。For steps S1001-S1004, reference may be made to the relevant descriptions in steps S701-S704, which will not be repeated here.

S1005、电子设备的摄像头采集被拍摄物体的图像,并将被拍摄物体的图像上传到检测模块。S1005: The camera of the electronic device collects an image of the photographed object and uploads the image of the photographed object to the detection module.

一些实施例中,检测模块可得到摄像头上报的图像;另一些实施例中,AF模块可得到摄像头上报的图像,并将该图像传递到检测模块。In some embodiments, the detection module may obtain an image reported by the camera; in other embodiments, the AF module may obtain an image reported by the camera and transmit the image to the detection module.

需要说明的是,在步骤S1001之后,电子设备可同时执行步骤S1002、步骤S1003和步骤S1005,也可先后执行步骤S1002、步骤S1003和步骤S1005,且本申请实施例对步骤S1002、步骤S1003和步骤S1005的先后顺序不做限制。It should be noted that after step S1001, the electronic device may execute step S1002, step S1003 and step S1005 simultaneously, or may execute step S1002, step S1003 and step S1005 in sequence, and the embodiment of the present application does not limit the order of step S1002, step S1003 and step S1005.

S1006、检测模块得到被拍摄物体的图像,并判定图像中的被拍摄物体是否为目标物体。S1006: The detection module obtains an image of the photographed object and determines whether the photographed object in the image is a target object.

检测模块可用于检测被拍摄物体是否为目标物体。目标物体可以为与电子设备的距离超过距离阈值的物体。例如,目标物体可以为月亮、云朵和远方建筑等。其中,目标物体可以是预先设置的目标物体。The detection module can be used to detect whether the photographed object is a target object. The target object can be an object whose distance from the electronic device exceeds a distance threshold. For example, the target object can be the moon, clouds, and distant buildings. The target object can be a pre-set target object.

例如,当电子设备拍摄月亮时,电子设备可触发本申请实施例的对焦方法。For example, when an electronic device takes a photo of the moon, the electronic device may trigger the focusing method of an embodiment of the present application.

S1007、当被拍摄物体为目标物体时,电子设备根据目标物体和倾斜角度查找补偿值阈值。S1007: When the photographed object is a target object, the electronic device searches for a compensation value threshold according to the target object and the tilt angle.

预设列表中可包括目标物体和目标物体在不同倾斜角度下对应的补偿值阈值。当被拍摄物体为目标物体时,电子设备可根据预设列表中目标物体与补偿值阈值的对应关系,得到补偿值阈值。The preset list may include target objects and compensation value thresholds corresponding to the target objects at different tilt angles. When the photographed object is the target object, the electronic device may obtain the compensation value threshold according to the correspondence between the target object and the compensation value threshold in the preset list.

可以理解的是,本申请实施例中,提供一种特定场景下的对焦方法。当被拍摄物体不是目标物体时,电子设备可采用步骤S701-S711实现被拍摄物体的对焦。而被拍摄物体是目标物体时,预设列表中的角度区间与补偿值阈值不适用于目标物体,因此,在特定的拍摄场景下,电子设备可根据目标物体设定相应的补偿值阈值。It is understandable that in the embodiment of the present application, a focusing method in a specific scene is provided. When the photographed object is not the target object, the electronic device can use steps S701-S711 to achieve focusing of the photographed object. When the photographed object is the target object, the angle interval and compensation value threshold in the preset list are not applicable to the target object. Therefore, in a specific shooting scene, the electronic device can set the corresponding compensation value threshold according to the target object.

其中,针对特定拍摄场景,电子设备可预设有更加精细的补偿值阈值,例如,电子设备可预设任一倾斜角度下拍摄目标物体时的补偿值阈值。示例性的,特定拍摄场景可以为长焦拍摄的场景,目标物体可以为月亮、天空、夕阳和远处建筑等。例如,当电子设备进行长焦拍摄时,镜头的位置可置于超焦距位置,电子设备可较为清晰的拍摄到远处的景象;而根据预设区间得到的补偿值阈值,可能无法满足将任一倾斜角度下的马达待调整位置均控制在超焦距位置附近,所以,这里需要针对目标物体和倾斜角度设定对应的补偿值阈值。Among them, for specific shooting scenes, the electronic device may preset a more precise compensation value threshold. For example, the electronic device may preset a compensation value threshold when shooting a target object at any tilt angle. Exemplarily, the specific shooting scene may be a telephoto shooting scene, and the target object may be the moon, the sky, the sunset, and distant buildings. For example, when the electronic device performs telephoto shooting, the position of the lens may be placed at the hyperfocal position, and the electronic device may capture distant scenes more clearly; and the compensation value threshold obtained according to the preset interval may not be able to satisfy the requirement that the motor position to be adjusted at any tilt angle is controlled near the hyperfocal position. Therefore, it is necessary to set corresponding compensation value thresholds for the target object and tilt angle.

一种可能的实现方式中,目标物体的补偿值阈值与预设区间的补偿值阈值可以不同;例如,电子设备可预设各个倾斜角度下目标物体的补偿值阈值,当电子设备检测到目标物体时,电子设备可使用该目标物体对应的补偿值阈值。In one possible implementation, the compensation value threshold of the target object may be different from the compensation value threshold of the preset interval; for example, the electronic device may preset the compensation value threshold of the target object at each tilt angle, and when the electronic device detects the target object, the electronic device may use the compensation value threshold corresponding to the target object.

另一种可能的实现方式中,电子设备可设定目标物体在某一倾斜角度下或某段角度区间的补偿值阈值;当倾斜角度在上述预设的倾斜角度中时,电子设备可使用目标物体对应的补偿值阈值;当倾斜角度不在上述预设的倾斜角度中时,电子设备可使用预设区间的补偿值阈值。本申请实施例对此不作限制。In another possible implementation, the electronic device may set a compensation value threshold for the target object at a certain tilt angle or in a certain angle interval; when the tilt angle is within the above-preset tilt angle, the electronic device may use the compensation value threshold corresponding to the target object; when the tilt angle is not within the above-preset tilt angle, the electronic device may use the compensation value threshold in the preset interval. This embodiment of the application is not limited to this.

S1008、电子设备的对焦算法模块使用倾斜角度计算补偿值。S1008: The focus algorithm module of the electronic device calculates a compensation value using the tilt angle.

S1009、当补偿值小于补偿值阈值时,电子设备的对焦算法模块基于补偿值和计算对焦值得到马达待调整位置。S1009: When the compensation value is less than the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value and the calculated focus value.

S1010、电子设备的对焦算法模块将马达待调整位置下发至马达驱动。S1010: The focus algorithm module of the electronic device sends the motor position to be adjusted to the motor driver.

S1011、电子设备的马达驱动根据马达待调整位置调整马达位置。S1011 , the motor driver of the electronic device adjusts the motor position according to the motor position to be adjusted.

S1012、电子设备在目标应用的界面中显示对焦后的图像。S1012: The electronic device displays the focused image in the interface of the target application.

步骤S1008-S1012可参考步骤S706-S710处的相关描述,此处不再赘述。For steps S1008-S1012, reference may be made to the relevant descriptions of steps S706-S710, which will not be repeated here.

或者,在步骤S1008之后,还包括:Alternatively, after step S1008, the method further includes:

S1013、当补偿值大于或等于补偿值阈值时,电子设备的对焦算法模块基于补偿值阈值和计算对焦值得到马达待调整位置。S1013: When the compensation value is greater than or equal to the compensation value threshold, the focus algorithm module of the electronic device obtains a motor position to be adjusted based on the compensation value threshold and the calculated focus value.

步骤S1013可参考步骤S711处的相关描述,此处不再赘述。For step S1013, reference may be made to the relevant description of step S711, which will not be repeated here.

之后,电子设备可执行步骤S1010-S1012。Afterwards, the electronic device may execute steps S1010 - S1012 .

可选的,在步骤S1006之后,还可包括:S1014、当被拍摄物体不是目标物体,电子设备的对焦算法模块根据倾斜角度查找预设区间对应的补偿值阈值。Optionally, after step S1006, the following may be included: S1014: when the photographed object is not the target object, the focus algorithm module of the electronic device searches for a compensation value threshold corresponding to a preset interval according to the tilt angle.

可以理解的是,当被拍摄物体不是目标物体时,电子设备可执行步骤S1014,实现图7中的对焦方法。本申请实施例对此不在赘述。It is understandable that when the photographed object is not the target object, the electronic device may execute step S1014 to implement the focusing method in Figure 7. This embodiment of the present application will not be described in detail.

需要说明的是,本申请所涉及的用户信息(包括但不限于用户设备信息、用户个人信息等)和数据(包括但不限于用于分析的数据、存储的数据、展示的数据等),均为经用户授权或者经过各方充分授权的信息和数据,并且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准,并提供有相应的操作入口,供用户选择授权或者拒绝。It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

在上述实施例的基础上,本申请实施例提供一种对焦方法。示例性的,图11为本申请实施例提供的一种对焦方法的流程示意图。Based on the above embodiments, the present application provides a focusing method. For example, FIG11 is a flow chart of a focusing method provided by the present application.

如图11所示,该对焦方法可应用于设置有摄像头和马达的电子设备,马达用于带动摄像头的位置移动,该对焦方法可以包括如下步骤:As shown in FIG. 11 , the focusing method may be applied to an electronic device provided with a camera and a motor, wherein the motor is used to drive the position of the camera to move. The focusing method may include the following steps:

S1101、在第一时刻,电子设备启动相机应用,电子设备的倾斜角度为第一倾斜角度,马达位于第一位置处,电子设备显示第一图像,第一位置对应第一对焦值。S1101. At a first moment, the electronic device starts a camera application, the tilt angle of the electronic device is a first tilt angle, the motor is located at a first position, the electronic device displays a first image, and the first position corresponds to a first focus value.

其中,步骤S1101可对应于步骤S702。第一对焦值可以为电子设备基于AF算法得到的计算对焦值,计算对焦值可以为电子设备处于非倾斜状态时的对焦位置。电子设备在得到第一对焦值后,将马达调整到第一对焦值对应的第一位置处。Wherein, step S1101 may correspond to step S702. The first focus value may be a calculated focus value obtained by the electronic device based on an AF algorithm, and the calculated focus value may be a focus position when the electronic device is in a non-tilted state. After obtaining the first focus value, the electronic device adjusts the motor to a first position corresponding to the first focus value.

可以理解的是,在第一时刻,第一位置与第一倾斜角度无明显对应关系,马达受自身重力影响,导致第一对焦值与真实对焦位置之间存在差值,所以,摄像头在第一位置处,电子设备未准确对焦,摄像头采集的第一图像的清晰度不高。It is understandable that at the first moment, there is no obvious correspondence between the first position and the first tilt angle, and the motor is affected by its own gravity, resulting in a difference between the first focus value and the actual focus position. Therefore, when the camera is at the first position, the electronic device is not accurately focused, and the clarity of the first image captured by the camera is not high.

S1102、在第二时刻,电子设备将马达调整到第二位置处,电子设备显示第二图像;第二图像的清晰度高于第一图像的清晰度;其中,第一倾斜角度属于第一预设区间,电子设备设置有第一预设区间对应的第一阈值,第二位置与第一位置的距离与第一补偿值呈正相关,第一补偿值与第一倾斜角度呈正相关,第一补偿值小于第一阈值;第一时刻早于第二时刻。S1102. At the second moment, the electronic device adjusts the motor to the second position, and the electronic device displays the second image; the clarity of the second image is higher than that of the first image; wherein the first tilt angle belongs to the first preset interval, the electronic device is provided with a first threshold corresponding to the first preset interval, the distance between the second position and the first position is positively correlated with the first compensation value, the first compensation value is positively correlated with the first tilt angle, and the first compensation value is less than the first threshold; the first moment is earlier than the second moment.

其中,步骤S1102可对应步骤S705-S710。第二位置可以是电子设备对使用补偿值(第一补偿值)对计算对焦值(第一对焦值)进行修正后的对焦位置;第二位置对应的对焦值与真实对焦位置之间的差值较小,所以第二图像的清晰度高于第一图像的清晰度。Among them, step S1102 may correspond to steps S705-S710. The second position may be a focus position after the electronic device corrects the calculated focus value (first focus value) using the compensation value (first compensation value); the difference between the focus value corresponding to the second position and the actual focus position is small, so the clarity of the second image is higher than the clarity of the first image.

具体的,S1101与S1102可视为电子设备在第一倾斜角度下调整马达位置的第一场景;第一时刻,电子设备先基于AF算法得到计算对焦值;第二时刻,电子设备基于补偿值对计算对焦值进行修正。其中,第一倾斜角度属于第一预设区域,在预设列表中,第一预设区域对应第一阈值,第一补偿值为基于第一倾斜角度计算得到的补偿值,第一补偿值小于第一阈值,可对应步骤S707对应的流程。Specifically, S1101 and S1102 can be regarded as the first scenario in which the electronic device adjusts the motor position at the first tilt angle; at the first moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the second moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the first tilt angle belongs to the first preset area, in the preset list, the first preset area corresponds to the first threshold, the first compensation value is the compensation value calculated based on the first tilt angle, and the first compensation value is less than the first threshold, which can correspond to the process corresponding to step S707.

S1103、在第三时刻,电子设备调整为第二倾斜角度,马达位于第三位置处,电子设备显示第三图像,第三位置对应第二对焦值,第二倾斜角度与第一倾斜角度不同;第二时刻早于第三时刻。S1103. At a third moment, the electronic device is adjusted to a second tilt angle, the motor is located at a third position, the electronic device displays a third image, the third position corresponds to a second focus value, and the second tilt angle is different from the first tilt angle; the second moment is earlier than the third moment.

其中,步骤S1103可对应于步骤S702,该步骤可参考步骤S1101处的相关描述,此处不再赘述。Among them, step S1103 may correspond to step S702, and this step may refer to the relevant description of step S1101, which will not be repeated here.

S1104、在第四时刻,电子设备将马达调整到第四位置处,电子设备显示第四图像,第四图像的清晰度高于第三图像的清晰度;其中,第二倾斜角度属于第一预设区间,第四位置与第三位置的距离与第二补偿值呈正相关,第二补偿值与第二倾斜角度呈正相关,第二补偿值小于第一阈值;第三时刻早于第四时刻。S1104. At the fourth moment, the electronic device adjusts the motor to the fourth position, and the electronic device displays a fourth image, and the clarity of the fourth image is higher than that of the third image; wherein the second tilt angle belongs to the first preset interval, the distance between the fourth position and the third position is positively correlated with the second compensation value, the second compensation value is positively correlated with the second tilt angle, and the second compensation value is less than the first threshold value; the third moment is earlier than the fourth moment.

其中,步骤S1104可对应步骤S705-S710,该步骤可参考步骤S1102处的相关描述,此处不再赘述。Among them, step S1104 may correspond to steps S705-S710, and this step may refer to the relevant description of step S1102, which will not be repeated here.

具体的,S1103与S1104可视为电子设备在第二倾斜角度下调整马达位置的第二场景;第三时刻,电子设备先基于AF算法得到计算对焦值;第四时刻,电子设备基于补偿值对计算对焦值进行修正。其中,第二倾斜角度属于第一预设区域,在预设列表中,第一预设区域对应第一阈值,第二补偿值为基于第二倾斜角度计算得到的补偿值,第二补偿值小于第一阈值,可对应步骤S707对应的流程。Specifically, S1103 and S1104 can be regarded as the second scenario in which the electronic device adjusts the motor position at the second tilt angle; at the third moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the fourth moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the second tilt angle belongs to the first preset area, in the preset list, the first preset area corresponds to the first threshold, the second compensation value is the compensation value calculated based on the second tilt angle, and the second compensation value is less than the first threshold, which can correspond to the process corresponding to step S707.

可以理解的是,第一场景与第二场景对比可发现:第一倾斜角度与第二倾斜角度均属于第一预设区间。在两个场景的对焦过程中,补偿值阈值均为第一倾斜角度对应的第一阈值。对于同一预设区间中的多个倾斜角度,电子设备所使用的补偿值阈值是一样的;例如,以图9为例,在预设区间18°-28°中,倾斜角度20°与倾斜角度25°所使用的补偿值阈值相同。一种可能的实现方式中,第一场景与第二场景下,补偿值均小于第一阈值,所以电子设备根据补偿值与计算对焦值得到马达待调整位置。It can be understood that by comparing the first scene with the second scene, it can be found that the first tilt angle and the second tilt angle both belong to the first preset interval. In the focusing process of the two scenes, the compensation value threshold is the first threshold corresponding to the first tilt angle. For multiple tilt angles in the same preset interval, the compensation value threshold used by the electronic device is the same; for example, taking Figure 9 as an example, in the preset interval of 18°-28°, the compensation value threshold used for the tilt angle of 20° is the same as the compensation value threshold used for the tilt angle of 25°. In one possible implementation, in the first scene and the second scene, the compensation value is less than the first threshold, so the electronic device obtains the position to be adjusted of the motor based on the compensation value and the calculated focus value.

S1105、在第五时刻,电子设备再次调整为第三倾斜角度,马达位于第五位置处,电子设备显示第五图像,第五位置对应第三对焦值,第四时刻早于第五时刻。S1105. At the fifth moment, the electronic device is adjusted to the third tilt angle again, the motor is located at the fifth position, the electronic device displays the fifth image, the fifth position corresponds to the third focus value, and the fourth moment is earlier than the fifth moment.

其中,步骤S1105可对应于步骤S702,该步骤可参考步骤S1101处的相关描述,此处不再赘述。Among them, step S1105 may correspond to step S702, and this step may refer to the relevant description of step S1101, which will not be repeated here.

S1106、在第六时刻,电子设备将马达调整到第六位置处,电子设备显示第六图像,第六图像的清晰度高于第五图像的清晰度;其中,第三倾斜角度属于第二预设区间,第二预设区间中的值与第一预设区间中的值不重合,电子设备中还设置有第二预设区间对应的第二阈值,第二阈值与第一阈值不同,第六位置与第五位置的距离与第三补偿值呈正相关,第三补偿值与第三倾斜角度呈正相关,第三补偿值小于第二阈值;第五时刻早于第六时刻。S1106. At the sixth moment, the electronic device adjusts the motor to the sixth position, and the electronic device displays the sixth image, and the clarity of the sixth image is higher than that of the fifth image; wherein the third tilt angle belongs to the second preset interval, and the value in the second preset interval does not overlap with the value in the first preset interval, and the electronic device is also provided with a second threshold corresponding to the second preset interval, and the second threshold is different from the first threshold, and the distance between the sixth position and the fifth position is positively correlated with the third compensation value, and the third compensation value is positively correlated with the third tilt angle, and the third compensation value is less than the second threshold; the fifth moment is earlier than the sixth moment.

其中,步骤S1106可对应步骤S705-S710,该步骤可参考步骤S1102处的相关描述,此处不再赘述。Among them, step S1106 may correspond to steps S705-S710. This step may refer to the relevant description of step S1102 and will not be repeated here.

具体的,S1105与S1106可视为电子设备在第三倾斜角度下调整马达位置的第三场景;第五时刻,电子设备先基于AF算法得到计算对焦值;第六时刻,电子设备基于补偿值对计算对焦值进行修正。其中,第三倾斜角度属于第二预设区域,在预设列表中,第二预设区域对应第二阈值,第三补偿值为基于第三倾斜角度计算得到的补偿值,第三补偿值小于第二阈值,可对应步骤S707对应的流程。Specifically, S1105 and S1106 can be regarded as the third scenario in which the electronic device adjusts the motor position at the third tilt angle; at the fifth moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the sixth moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the third tilt angle belongs to the second preset area, in the preset list, the second preset area corresponds to the second threshold, the third compensation value is the compensation value calculated based on the third tilt angle, and the third compensation value is less than the second threshold, which can correspond to the process corresponding to step S707.

可以理解的是,第一场景与第三场景对比可发现:第一倾斜角度与第三倾斜角度分别属于第一预设区间和第二预设区间。在两个场景的对焦过程中,补偿值阈值分别为第一阈值和第二阈值。对于不同预设区间中的多个倾斜角度,电子设备所使用的补偿值阈值是不同的;例如,以图9为例,预设区间18°-28°中的倾斜角度20°与预设区间28°-38°倾斜角度30°所使用的补偿值阈值是不相同的。一种可能的实现方式中,第一场景下,第一补偿值小于第一阈值,电子设备根据第一补偿值与第一对焦值得到马达待调整位置;第三场景下,第三补偿值小于第二阈值,电子设备根据第三补偿值与第三对焦值得到马达待调整位置。It can be understood that by comparing the first scene with the third scene, it can be found that the first tilt angle and the third tilt angle belong to the first preset interval and the second preset interval, respectively. In the focusing process of the two scenes, the compensation value thresholds are the first threshold and the second threshold, respectively. For multiple tilt angles in different preset intervals, the compensation value thresholds used by the electronic device are different; for example, taking Figure 9 as an example, the compensation value thresholds used for the tilt angle 20° in the preset interval 18°-28° and the tilt angle 30° in the preset interval 28°-38° are different. In one possible implementation, in the first scene, the first compensation value is less than the first threshold, and the electronic device obtains the motor position to be adjusted according to the first compensation value and the first focus value; in the third scene, the third compensation value is less than the second threshold, and the electronic device obtains the motor position to be adjusted according to the third compensation value and the third focus value.

本申请实施例中,电子设备对倾斜角度进行区域划分,得到多个预设区间。任一预设区间均设置有该预设区间下的补偿值阈值,提升了补偿值阈值的准确度,补偿值小于补偿值阈值时,电子设备得到的补偿值更加准确,从而提升了补偿值的准确度,进而减少摄像头成像模糊的场景。In the embodiment of the present application, the electronic device divides the tilt angle into regions to obtain a plurality of preset intervals. Each preset interval is provided with a compensation value threshold value under the preset interval, which improves the accuracy of the compensation value threshold value. When the compensation value is less than the compensation value threshold value, the compensation value obtained by the electronic device is more accurate, thereby improving the accuracy of the compensation value, and further reducing the scene of blurred camera imaging.

可选的,电子设备还包括马达驱动,在电子设备将马达调整到第二位置处之前,还包括:电子设备根据第一倾斜角度查找第一预设区间对应的第一阈值;电子设备使用第一倾斜角度计算第一补偿值;第一补偿值与第一倾斜角度的正弦值呈正相关;当第一补偿值小于第一阈值时,电子设备基于第一补偿值和第一对焦值得到第二位置;第二位置与第一补偿值和第一对焦值的和呈正相关;电子设备将第二位置下发至马达驱动。Optionally, the electronic device also includes a motor drive, and before the electronic device adjusts the motor to the second position, it also includes: the electronic device searches for a first threshold corresponding to a first preset interval based on the first tilt angle; the electronic device calculates a first compensation value using the first tilt angle; the first compensation value is positively correlated with the sine value of the first tilt angle; when the first compensation value is less than the first threshold, the electronic device obtains a second position based on the first compensation value and the first focus value; the second position is positively correlated with the sum of the first compensation value and the first focus value; and the electronic device sends the second position to the motor drive.

其中,第一预设区间可以为任一预设区间,例如,第一预设区间可以为预设区间1、预设区间2……预设区间N中的任一预设区间,第一预设区间并非特指预设区间1;第一倾斜角度可以为第一预设区间下的任一倾斜角度。Among them, the first preset interval can be any preset interval, for example, the first preset interval can be any preset interval in preset interval 1, preset interval 2...preset interval N, and the first preset interval does not specifically refer to preset interval 1; the first inclination angle can be any inclination angle under the first preset interval.

该步骤可对应于步骤S705-S708,第二位置可以为马达待调整位置,该步骤可参考步骤S705-S708处的相关描述,此处不再赘述。This step may correspond to steps S705-S708, and the second position may be the position of the motor to be adjusted. This step may refer to the relevant descriptions of steps S705-S708, which will not be repeated here.

这样,当补偿值小于补偿值阈值时,电子设备可使用补偿值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

可选的,第一补偿值满足下述公式:Optionally, the first compensation value satisfies the following formula:

offset=sinθ×offset0offset = sinθ × offset0

其中,offset为第一补偿值,θ为第一倾斜角度,offset0为预设补偿值阈值。Wherein, offset is the first compensation value, θ is the first tilt angle, and offset0 is the preset compensation value threshold.

需要说明的是,本申请实施例以第一补偿值为例,对补偿值的计算方法进行说明。本申请实施例也可使用该公式计算第二补偿值、第三补偿值、第四补偿值等,本申请实施例对此不再赘述。此外,电子设备也可基于该公式的变形公式计算补偿值阈值,例如,电子设备也可使用公式(8)计算补偿值。It should be noted that the embodiment of the present application takes the first compensation value as an example to illustrate the method for calculating the compensation value. The embodiment of the present application may also use the formula to calculate the second compensation value, the third compensation value, the fourth compensation value, etc., which will not be described in detail in the embodiment of the present application. In addition, the electronic device may also calculate the compensation value threshold based on a modified formula of the formula. For example, the electronic device may also use formula (8) to calculate the compensation value.

这样,电子设备可使用补偿值计算公式得到补偿值,以便于在后续对焦流程中使用该值提升对焦的准确性。In this way, the electronic device can use the compensation value calculation formula to obtain the compensation value, so as to use the value in the subsequent focusing process to improve the focusing accuracy.

可选的,该对焦方法还包括:Optionally, the focusing method further includes:

(1)、在第七时刻,电子设备再次调整为第四倾斜角度,马达位于第七位置处,电子设备显示第七图像,第七位置对应第四对焦值,第六时刻早于第七时刻。(1) At the seventh moment, the electronic device is adjusted to the fourth tilt angle again, the motor is located at the seventh position, the electronic device displays the seventh image, the seventh position corresponds to the fourth focus value, and the sixth moment is earlier than the seventh moment.

其中,该步骤可对应于步骤S702,该步骤可参考步骤S1101处的相关描述,此处不再赘述。Among them, this step may correspond to step S702, and this step may refer to the relevant description at step S1101, which will not be repeated here.

(2)、在第八时刻,电子设备将马达调整到第八位置处,电子设备显示第八图像,第八图像的清晰度高于第七图像的清晰度;其中,第四倾斜角属于第三预设区间,第三预设区间中的值与第二预设区间中的值不重合,电子设备中还设置有第三预设区间对应的第三阈值,第三阈值与第二阈值不同,第八位置与第七位置的距离与第三阈值呈正相关,第四补偿值大于或等于第三阈值,第四补偿值与第四倾斜角度呈正相关,第七时刻早于第八时刻。(2) At the eighth moment, the electronic device adjusts the motor to the eighth position, and the electronic device displays the eighth image, and the clarity of the eighth image is higher than that of the seventh image; wherein the fourth tilt angle belongs to the third preset interval, and the value in the third preset interval does not overlap with the value in the second preset interval. The electronic device is also provided with a third threshold corresponding to the third preset interval, and the third threshold is different from the second threshold. The distance between the eighth position and the seventh position is positively correlated with the third threshold, the fourth compensation value is greater than or equal to the third threshold, and the fourth compensation value is positively correlated with the fourth tilt angle. The seventh moment is earlier than the eighth moment.

其中,该步骤可对应步骤S705、S706、S711、S708-S710,第四位置可以是电子设备使用补偿值阈值(第三阈值)对计算对焦值(第四对焦值)进行修正后的对焦位置;第四位置对应的对焦值与真实对焦值差值较小,所以第四图像的清晰度高于第三图像的清晰度。Among them, this step may correspond to steps S705, S706, S711, S708-S710, and the fourth position may be the focus position after the electronic device uses the compensation value threshold (third threshold) to correct the calculated focus value (fourth focus value); the focus value corresponding to the fourth position has a smaller difference with the actual focus value, so the clarity of the fourth image is higher than the clarity of the third image.

具体的,步骤(1)和步骤(2)可视为电子设备在第四倾斜角度下调整马达位置的第四场景;第七时刻,电子设备先基于AF算法得到计算对焦值;第八时刻,电子设备基于补偿值对计算对焦值进行修正。其中,第四斜角度属于第三预设区域,在预设列表中,第三预设区域对应第三阈值,第四补偿值为基于第四倾斜角度计算得到的补偿值,第四补偿值大于或等于第三阈值,可对应步骤S711对应的流程。Specifically, step (1) and step (2) can be regarded as the fourth scenario in which the electronic device adjusts the motor position at the fourth tilt angle; at the seventh moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the eighth moment, the electronic device corrects the calculated focus value based on the compensation value. Among them, the fourth tilt angle belongs to the third preset area, in the preset list, the third preset area corresponds to the third threshold value, the fourth compensation value is the compensation value calculated based on the fourth tilt angle, and the fourth compensation value is greater than or equal to the third threshold value, which can correspond to the process corresponding to step S711.

可以理解的是,第三场景与第四场景对比可发现:第三倾斜角度属于第二预设区间,第四倾斜角度属于第三预设区间,第三预设区间的值与第二预设区间的值不重合。在第三场景中,第三补偿值小于第二阈值,所以电子设备使用第三补偿值修正第三对焦值。在第四场景中,第四补偿值大于或等于第三阈值,所以电子设备使用第三阈值修正第四对焦值。It is understandable that, by comparing the third scene with the fourth scene, it can be found that: the third tilt angle belongs to the second preset interval, the fourth tilt angle belongs to the third preset interval, and the value of the third preset interval does not overlap with the value of the second preset interval. In the third scene, the third compensation value is less than the second threshold value, so the electronic device uses the third compensation value to correct the third focus value. In the fourth scene, the fourth compensation value is greater than or equal to the third threshold value, so the electronic device uses the third threshold value to correct the fourth focus value.

这样,电子设备通过补偿值阈值衡量补偿值的准确度,当补偿值大于或等于补偿值阈值时,当前补偿值误差较大,无法使用补偿值修正计算对焦值;这时,可使用补偿值阈值对计算对焦值进行修正,以提升马达待调整位置的准确性。In this way, the electronic device measures the accuracy of the compensation value through the compensation value threshold. When the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large and the compensation value cannot be used to correct the calculated focus value. At this time, the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the motor position to be adjusted.

可选的,在电子设备将马达调整到第八位置之前,还包括:Optionally, before the electronic device adjusts the motor to the eighth position, the method further includes:

电子设备根据第四倾斜角度查找第三预设区间对应的第三阈值;电子设备使用第四倾斜角度计算第四补偿值;第四补偿值与第四倾斜角度的正弦值呈正相关;当第四补偿值大于或等于第三阈值时,电子设备基于第三阈值和第四对焦值得到第八位置;第八位置与第三阈值和第四对焦值的和呈正相关;电子设备将第八位置下发至马达驱动。The electronic device searches for the third threshold value corresponding to the third preset interval according to the fourth tilt angle; the electronic device calculates the fourth compensation value using the fourth tilt angle; the fourth compensation value is positively correlated with the sine value of the fourth tilt angle; when the fourth compensation value is greater than or equal to the third threshold value, the electronic device obtains the eighth position based on the third threshold value and the fourth focus value; the eighth position is positively correlated with the sum of the third threshold value and the fourth focus value; the electronic device sends the eighth position to the motor drive.

其中,第三预设区间可以为任一预设区间,例如,第三预设区间可以为预设区间1、预设区间2……预设区间N中的任一预设区间,第三预设区间并非特指预设区间3;第四倾斜角度可以为第三预设区间下的任一倾斜角度。Among them, the third preset interval can be any preset interval, for example, the third preset interval can be any preset interval in preset interval 1, preset interval 2...preset interval N, and the third preset interval does not specifically refer to preset interval 3; the fourth inclination angle can be any inclination angle under the third preset interval.

该步骤可对应于步骤S705、S706、S711、S708,第八位置可以为马达待调整位置,该步骤可参考步骤S705、S706、S711、S708处的相关描述,此处不再赘述。This step may correspond to steps S705, S706, S711, and S708. The eighth position may be the position of the motor to be adjusted. This step may refer to the relevant descriptions of steps S705, S706, S711, and S708, and will not be repeated here.

这样,当补偿值大于或等于补偿值阈值时,电子设备可使用补偿值阈值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In this way, when the compensation value is greater than or equal to the compensation value threshold, the electronic device can use the compensation value threshold and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

可选的,还包括:Optionally, also include:

(1)、在第九时刻,电子设备再次调整为第五倾斜角度,马达位于第九位置处,电子设备显示第九图像,第九图像中包括预设的目标物体,目标物体为与电子设备的距离超过距离阈值的物体,第九位置对应第五对焦值,第八时刻早于第九时刻。(1) At the ninth moment, the electronic device is adjusted to the fifth tilt angle again, the motor is located at the ninth position, and the electronic device displays a ninth image. The ninth image includes a preset target object, which is an object whose distance from the electronic device exceeds a distance threshold. The ninth position corresponds to the fifth focus value, and the eighth moment is earlier than the ninth moment.

其中,该步骤可对应于步骤S1002。第五对焦值可以为电子设备基于AF算法得到的计算对焦值,计算对焦值可以为电子设备处于非倾斜状态时的对焦位置。电子设备在得到第五对焦值后,将马达调整到第五对焦值对应的第九位置处。目标物体为与电子设备的距离超过距离阈值的物体,例如,目标物体与长焦拍摄有关,目标物体例如云朵、月亮、远处的建筑等。Among them, this step may correspond to step S1002. The fifth focus value may be a calculated focus value obtained by the electronic device based on the AF algorithm, and the calculated focus value may be a focus position when the electronic device is in a non-tilted state. After obtaining the fifth focus value, the electronic device adjusts the motor to a ninth position corresponding to the fifth focus value. The target object is an object whose distance from the electronic device exceeds a distance threshold, for example, the target object is related to telephoto shooting, such as clouds, the moon, distant buildings, etc.

可以理解的是,在第九时刻,第九位置与第五倾斜角度无明显对应关系,马达受自身重力影响,导致第五对焦值与真实对焦位置之间存在差值,所以,摄像头在第九位置处,电子设备未准确对焦,摄像头采集的第九图像的清晰度不高。It is understandable that at the ninth moment, there is no obvious correspondence between the ninth position and the fifth tilt angle, and the motor is affected by its own gravity, resulting in a difference between the fifth focus value and the actual focus position. Therefore, when the camera is at the ninth position, the electronic device does not focus accurately, and the clarity of the ninth image captured by the camera is not high.

(2)、在第十时刻,电子设备将马达调整到第十位置处,电子设备显示第十图像,第十图像中包括目标物体,第十图像的清晰度高于第九图像的清晰度;电子设备还设置有目标物体在第五倾斜角度下的第四阈值,第十位置与第九位置的距离与第五补偿值呈正相关,第五补偿值与第五倾斜角度呈正相关,第五补偿值小于第四阈值;其中,第五倾斜角度属于第四预设区间,电子设备中还设置有第四预设区间对应的阈值,且第四阈值与第四预设区间对应的阈值不同;第九时刻早于第十时刻。(2) At the tenth moment, the electronic device adjusts the motor to the tenth position, and the electronic device displays the tenth image, which includes the target object, and the clarity of the tenth image is higher than that of the ninth image; the electronic device is also provided with a fourth threshold value of the target object at the fifth tilt angle, the distance between the tenth position and the ninth position is positively correlated with the fifth compensation value, the fifth compensation value is positively correlated with the fifth tilt angle, and the fifth compensation value is less than the fourth threshold value; wherein, the fifth tilt angle belongs to the fourth preset interval, and the electronic device is also provided with a threshold value corresponding to the fourth preset interval, and the fourth threshold value is different from the threshold value corresponding to the fourth preset interval; the ninth moment is earlier than the tenth moment.

其中,该步骤可对应步骤S1005-S1012。第十位置可以是电子设备对使用补偿值(第五补偿值)对计算对焦值(第五对焦值)进行修正后的对焦位置;第十位置对应的对焦值与真实对焦位置之间的差值较小,所以第十图像的清晰度高于第九图像的清晰度。This step may correspond to steps S1005-S1012. The tenth position may be a focus position after the electronic device corrects the calculated focus value (fifth focus value) using the compensation value (fifth compensation value); the difference between the focus value corresponding to the tenth position and the actual focus position is small, so the clarity of the tenth image is higher than that of the ninth image.

具体的,步骤(1)和步骤(2)可视为电子设备在第五倾斜角度下调整马达位置的第五场景;第九时刻,电子设备先基于AF算法得到计算对焦值;第十时刻,电子设备基于补偿值对计算对焦值进行修正。在步骤(2)中,由于被拍摄物体为目标物体,电子设备可采用目标物体在第五倾斜角度下对应的补偿值阈值(第四阈值),而不是采用预设区间对应的阈值,所以第四阈值与第四预设区间对应的阈值不同。Specifically, step (1) and step (2) can be regarded as the fifth scenario in which the electronic device adjusts the motor position at the fifth tilt angle; at the ninth moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the tenth moment, the electronic device corrects the calculated focus value based on the compensation value. In step (2), since the photographed object is the target object, the electronic device can use the compensation value threshold (fourth threshold) corresponding to the target object at the fifth tilt angle instead of the threshold corresponding to the preset interval, so the fourth threshold is different from the threshold corresponding to the fourth preset interval.

这样,在拍摄目标物体时,电子设备可根据需要的精度调整任一倾斜角度下的补偿值阈值,提升补偿值阈值的精度,从而提升对焦位置的准确度。In this way, when photographing a target object, the electronic device can adjust the compensation value threshold at any tilt angle according to the required accuracy, thereby improving the accuracy of the compensation value threshold and thus improving the accuracy of the focus position.

可选的,在电子设备将马达位置调整到第十位置处之前,还包括:Optionally, before the electronic device adjusts the motor position to the tenth position, the method further includes:

电子设备得到第九图像,并判定第九图像中的被拍摄物体是否为目标物体;当第九图像中的被拍摄物体是目标物体时,电子设备根据目标物体和第五倾斜角度查找第四阈值;电子设备使用第五倾斜角度计算第五补偿值;当第五补偿值小于第四阈值时,电子设备基于第五补偿值和第五对焦值得到第十位置;第十位置与第五补偿值和第五对焦值的和呈正相关;电子设备将第十位置下发至马达驱动。The electronic device obtains a ninth image, and determines whether the photographed object in the ninth image is a target object; when the photographed object in the ninth image is a target object, the electronic device searches for a fourth threshold value according to the target object and a fifth tilt angle; the electronic device calculates a fifth compensation value using the fifth tilt angle; when the fifth compensation value is less than the fourth threshold value, the electronic device obtains a tenth position based on the fifth compensation value and the fifth focus value; the tenth position is positively correlated with the sum of the fifth compensation value and the fifth focus value; the electronic device sends the tenth position to the motor drive.

该步骤可参考步骤S1005-S1010中的相关描述,此处不做赘述。For this step, please refer to the relevant description in steps S1005-S1010, which will not be repeated here.

这样,当补偿值小于补偿值阈值时,电子设备可使用补偿值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In this way, when the compensation value is less than the compensation value threshold, the electronic device can use the compensation value and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

可选的,还包括:Optionally, also include:

(1)、在第十一时刻,电子设备再次调整为第六倾斜角度,马达位于第十一位置处,电子设备显示第十一图像,第十一图像中包括目标物体,第十一位置对应第六对焦值,第十时刻早于第十一时刻。(1) At the eleventh moment, the electronic device is adjusted to the sixth tilt angle again, the motor is located at the eleventh position, the electronic device displays the eleventh image, the eleventh image includes the target object, the eleventh position corresponds to the sixth focus value, and the tenth moment is earlier than the eleventh moment.

该步骤可参考第九时刻所示步骤中的相关描述,此处不再赘述。For this step, please refer to the relevant description in the step shown at the ninth moment, which will not be repeated here.

(2)、在第十二时刻,电子设备将马达调整到第十二位置处,电子设备显示第十二图像,第十二图像中包括目标物体,第十二图像的清晰度高于第十一图像的清晰度;电子设备还设置有目标物体在第六倾斜角度下对应的第五阈值,第十二位置与第十一位置的距离与第五阈值呈正相关,第六补偿值大于或等于第五阈值,第六补偿值与第六倾斜角度呈正相关;其中,第六倾斜角度属于第四预设区间,第五阈值与第四预设区间对应的阈值不同,且第五阈值与第四阈值不同;第十一时刻早于第十二时刻。(2) At the twelfth moment, the electronic device adjusts the motor to the twelfth position, and the electronic device displays the twelfth image, which includes the target object, and the clarity of the twelfth image is higher than that of the eleventh image; the electronic device is also provided with a fifth threshold value corresponding to the target object at a sixth tilt angle, the distance between the twelfth position and the eleventh position is positively correlated with the fifth threshold value, the sixth compensation value is greater than or equal to the fifth threshold value, and the sixth compensation value is positively correlated with the sixth tilt angle; wherein the sixth tilt angle belongs to the fourth preset interval, the fifth threshold value is different from the threshold value corresponding to the fourth preset interval, and the fifth threshold value is different from the fourth threshold value; the eleventh moment is earlier than the twelfth moment.

其中,该步骤可对应步骤S1005-S1008、S1013、S1010-S1012。Among them, this step may correspond to steps S1005-S1008, S1013, and S1010-S1012.

具体的,步骤(1)和步骤(2)可视为电子设备在第六倾斜角度下调整马达位置的第六场景;第十一时刻,电子设备先基于AF算法得到计算对焦值;第十二时刻,电子设备基于补偿值阈值对计算对焦值进行修正。在步骤(2)中,由于被拍摄物体为目标物体,电子设备可采用目标物体在第六倾斜角度下对应的补偿值阈值(第五阈值),而不是采用预设区间对应的阈值,所以第五阈值与第四预设区间对应的阈值不同。Specifically, step (1) and step (2) can be regarded as the sixth scene in which the electronic device adjusts the motor position at the sixth tilt angle; at the eleventh moment, the electronic device first obtains the calculated focus value based on the AF algorithm; at the twelfth moment, the electronic device corrects the calculated focus value based on the compensation value threshold. In step (2), since the photographed object is the target object, the electronic device can use the compensation value threshold (fifth threshold) corresponding to the target object at the sixth tilt angle instead of the threshold corresponding to the preset interval, so the fifth threshold is different from the threshold corresponding to the fourth preset interval.

可以理解的是,第五场景和第六场景对比可发现:第五倾斜角度和第六倾斜角度均属于第四预设区间,但在电子设备拍摄目标物体时,电子设备采用目标物体在特定倾斜角度下的补偿值阈值,而不使用预设区间对应的阈值,所以第四阈值和第五阈值均与第四预设区间对应的阈值无关。同时,同一目标物体在不同倾斜角度下对应的补偿值阈值也不相同,例如,第四阈值与第五阈值不同。It is understandable that by comparing the fifth scene with the sixth scene, it can be found that the fifth tilt angle and the sixth tilt angle both belong to the fourth preset interval, but when the electronic device photographs the target object, the electronic device uses the compensation value threshold of the target object at a specific tilt angle, instead of the threshold corresponding to the preset interval, so the fourth threshold and the fifth threshold are irrelevant to the threshold corresponding to the fourth preset interval. At the same time, the compensation value thresholds corresponding to the same target object at different tilt angles are also different, for example, the fourth threshold is different from the fifth threshold.

这样,在拍摄目标物体时,电子设备可根据需要的精度调整任一倾斜角度下的补偿值阈值,提升补偿值阈值的精度;电子设备通过该补偿值阈值衡量补偿值的准确度,当补偿值大于或等于补偿值阈值时,当前补偿值误差较大,无法使用补偿值修正计算对焦值;可使用补偿值阈值对计算对焦值进行修正,以提升马达待调整位置的准确性。In this way, when shooting the target object, the electronic device can adjust the compensation value threshold at any tilt angle according to the required accuracy to improve the accuracy of the compensation value threshold; the electronic device measures the accuracy of the compensation value through the compensation value threshold. When the compensation value is greater than or equal to the compensation value threshold, the current compensation value error is large and the compensation value cannot be used to correct the calculated focus value; the compensation value threshold can be used to correct the calculated focus value to improve the accuracy of the motor position to be adjusted.

可选的,在电子设备将马达位置调整到第十二位置处之前,还包括:电子设备得到第十一图像,并判定第十一图像中的被拍摄物体是否为目标物体;当第十一图像中的被拍摄物体是目标物体时,电子设备根据目标物体和第六倾斜角度查找第五阈值;电子设备使用第六倾斜角度计算第六补偿值;当第六补偿值大于或等于第五阈值时,电子设备基于第五阈值和第六对焦值得到第十二位置;第十二位置与第五阈值和第六对焦值的和呈正相关;电子设备将第十二位置下发至马达驱动。Optionally, before the electronic device adjusts the motor position to the twelfth position, it also includes: the electronic device obtains the eleventh image, and determines whether the photographed object in the eleventh image is the target object; when the photographed object in the eleventh image is the target object, the electronic device searches for the fifth threshold according to the target object and the sixth tilt angle; the electronic device calculates the sixth compensation value using the sixth tilt angle; when the sixth compensation value is greater than or equal to the fifth threshold, the electronic device obtains the twelfth position based on the fifth threshold and the sixth focus value; the twelfth position is positively correlated with the sum of the fifth threshold and the sixth focus value; the electronic device sends the twelfth position to the motor drive.

该步骤可参考步骤S1005-S1008、S1013、S1010中的相关描述,此处不再赘述。For this step, please refer to the relevant descriptions in steps S1005-S1008, S1013, and S1010, which will not be repeated here.

这样,当补偿值大于或等于补偿值阈值时,电子设备可使用补偿值阈值和计算对焦值得到较为准确的马达待调整位置,从而提升对焦位置的准确性。In this way, when the compensation value is greater than or equal to the compensation value threshold, the electronic device can use the compensation value threshold and the calculated focus value to obtain a more accurate motor position to be adjusted, thereby improving the accuracy of the focus position.

可选的,第一倾斜角度与惯性测量单元IMU数据相关,IMU数据是电子设备基于陀螺仪传感器得到的;第一倾斜角度满足下述任一公式:Optionally, the first tilt angle is related to inertial measurement unit IMU data, where the IMU data is obtained by the electronic device based on a gyroscope sensor; the first tilt angle satisfies any of the following formulas:

或者;or;

或者;or;

其中,gSensor.x为电子设备处于第一倾斜角度时x轴方向的角速度,gSensor.y为电子设备处于第一倾斜角度时y轴方向的角速度,gSensor.z为电子设备处于第一倾斜角度时z轴方向的角速度。Among them, gSensor.x is the angular velocity of the electronic device in the x-axis direction when the electronic device is at the first tilt angle, gSensor.y is the angular velocity of the electronic device in the y-axis direction when the electronic device is at the first tilt angle, and gSensor.z is the angular velocity of the electronic device in the z-axis direction when the electronic device is at the first tilt angle.

需要说明的是,本申请实施例以第一倾斜角度为例,对倾斜角度的计算方法进行说明。本申请实施例也可使用该公式计算第二倾斜角度、第三倾斜角度、第四倾斜角度等,本申请实施例对此不再赘述。此外,电子设备也可基于该公式的变形公式计算补偿值阈值,本申请实施例对此不再一一列举。It should be noted that the embodiment of the present application takes the first tilt angle as an example to illustrate the calculation method of the tilt angle. The embodiment of the present application can also use the formula to calculate the second tilt angle, the third tilt angle, the fourth tilt angle, etc., which will not be described in detail in the embodiment of the present application. In addition, the electronic device can also calculate the compensation value threshold based on a modified formula of the formula, which will not be listed one by one in the embodiment of the present application.

这样,电子设备可使用倾斜角度计算公式得到当前倾斜角度,以便于在后续对焦流程中使用该值提升对焦的准确性。In this way, the electronic device can use the tilt angle calculation formula to obtain the current tilt angle, so as to use this value in the subsequent focusing process to improve the focusing accuracy.

上面已对本申请实施例的对焦方法进行了说明,下面对本申请实施例提供的执行上述对焦方法的装置进行描述。本领域技术人员可以理解,方法和装置可以相互结合和引用,本申请实施例提供的相关装置可以执行上述对焦方法中的步骤。The focusing method of the embodiment of the present application has been described above, and the device for executing the above focusing method provided by the embodiment of the present application is described below. Those skilled in the art can understand that the method and the device can be combined and referenced with each other, and the relevant device provided by the embodiment of the present application can execute the steps in the above focusing method.

如图12所示,对焦装置1200可以用于通信设备、电路、硬件组件或者芯片中,该对焦装置包括:显示单元1201、以及处理单元1202。其中,显示单元1201用于支持对焦装置1200执行的显示的步骤;处理单元1202用于支持对焦装置1200执行信息处理的步骤。As shown in FIG12 , a focusing device 1200 can be used in a communication device, a circuit, a hardware component or a chip, and the focusing device includes: a display unit 1201 and a processing unit 1202. The display unit 1201 is used to support the display step performed by the focusing device 1200; the processing unit 1202 is used to support the information processing step performed by the focusing device 1200.

可能的实现方式中,该对焦装置1200中也可以包括通信单元1203。具体的,通信单元用于支持对焦装置1200执行数据的发送以及数据的接收的步骤。其中,该通信单元1203可以是输入或者输出接口、管脚或者电路等。In a possible implementation, the focusing device 1200 may also include a communication unit 1203. Specifically, the communication unit is used to support the focusing device 1200 to perform the steps of sending and receiving data. The communication unit 1203 may be an input or output interface, a pin or a circuit.

可能的实施例中,对焦装置还可以包括:存储单元1204。处理单元1202、存储单元1204通过线路相连。存储单元1204可以包括一个或者多个存储器,存储器可以是一个或者多个设备、电路中用于存储程序或者数据的器件。存储单元1204可以独立存在,通过通信线路与对焦装置具有的处理单元1202相连。存储单元1204也可以和处理单元1202集成在一起。In a possible embodiment, the focusing device may further include: a storage unit 1204. The processing unit 1202 and the storage unit 1204 are connected via a line. The storage unit 1204 may include one or more memories, and the memory may be a device used to store programs or data in one or more devices or circuits. The storage unit 1204 may exist independently and be connected to the processing unit 1202 of the focusing device via a communication line. The storage unit 1204 may also be integrated with the processing unit 1202.

存储单元1204可以存储终端设备中的方法的计算机执行指令,以使处理单元1202执行上述实施例中的方法。存储单元1204可以是寄存器、缓存或者RAM等,存储单元1204可以和处理单元1202集成在一起。存储单元1204可以是只读存储器(read-only memory,ROM)或者可存储静态信息和指令的其他类型的静态存储设备,存储单元1204可以与处理单元1202相独立。The storage unit 1204 may store computer-executable instructions of the method in the terminal device so that the processing unit 1202 executes the method in the above embodiment. The storage unit 1204 may be a register, a cache, or a RAM, etc. The storage unit 1204 may be integrated with the processing unit 1202. The storage unit 1204 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, and the storage unit 1204 may be independent of the processing unit 1202.

本申请实施例提供的对焦方法,可以应用在具备通信功能的电子设备中。电子设备包括终端设备,终端设备的具体设备形态等可以参照上述相关说明,此处不再赘述。The focusing method provided in the embodiment of the present application can be applied to electronic devices with communication functions. The electronic devices include terminal devices, and the specific device form of the terminal devices can refer to the above related descriptions, which will not be repeated here.

本申请实施例提供一种终端设备,该终端设备包括:包括:处理器和存储器;存储器存储计算机执行指令;处理器执行存储器存储的计算机执行指令,使得终端设备执行上述方法。An embodiment of the present application provides a terminal device, which includes: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the above method.

本申请实施例提供一种芯片。芯片包括处理器,处理器用于调用存储器中的计算机程序,以执行上述实施例中的技术方案。其实现原理和技术效果与上述相关实施例类似,此处不再赘述。The embodiment of the present application provides a chip. The chip includes a processor, and the processor is used to call a computer program in a memory to execute the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above related embodiments, and will not be repeated here.

本申请实施例还提供了一种计算机可读存储介质。计算机可读存储介质存储有计算机程序。计算机程序被处理器执行时实现上述方法。上述实施例中描述的方法可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。如果在软件中实现,则功能可以作为一个或多个指令或代码存储在计算机可读介质上或者在计算机可读介质上传输。计算机可读介质可以包括计算机存储介质和通信介质,还可以包括任何可以将计算机程序从一个地方传送到另一个地方的介质。存储介质可以是可由计算机访问的任何目标介质。The embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program. The above method is implemented when the computer program is executed by the processor. The method described in the above embodiment can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.

一种可能的实现方式中,计算机可读介质可以包括RAM,ROM,只读光盘(compactdisc read-only memory,CD-ROM)或其它光盘存储器,磁盘存储器或其它磁存储设备,或目标于承载的任何其它介质或以指令或数据结构的形式存储所需的程序代码,并且可由计算机访问。而且,任何连接被适当地称为计算机可读介质。例如,如果使用同轴电缆,光纤电缆,双绞线,数字用户线(Digital Subscriber Line,DSL)或无线技术(如红外,无线电和微波)从网站,服务器或其它远程源传输软件,则同轴电缆,光纤电缆,双绞线,DSL或诸如红外,无线电和微波之类的无线技术包括在介质的定义中。如本文所使用的磁盘和光盘包括光盘,激光盘,光盘,数字通用光盘(Digital Versatile Disc,DVD),软盘和蓝光盘,其中磁盘通常以磁性方式再现数据,而光盘利用激光光学地再现数据。上述的组合也应包括在计算机可读介质的范围内。In one possible implementation, a computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the required program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer-readable medium. For example, if a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave) is used to transmit software from a website, server or other remote source, the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disks and optical disks as used herein include optical disks, laser disks, optical disks, digital versatile disks (DVD), floppy disks and Blu-ray disks, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer-readable media.

本申请实施例提供一种计算机程序产品,计算机程序产品包括计算机程序,当计算机程序被运行时,使得计算机执行上述方法。An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes the above method.

本申请实施例是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程设备的处理单元以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理单元执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application embodiment is described with reference to the flowchart and/or block diagram of the method, device (system) and computer program product according to the present application embodiment. It should be understood that each process and/or box in the flowchart and/or block diagram and the combination of the process and/or box in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions can be provided to the processing unit of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable device to produce a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.

以上的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本发明的保护范围之内。The above specific implementation methods further illustrate the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the protection scope of the present invention.

Claims (13)

At a sixth moment, the electronic device adjusts the motor to a sixth position, the electronic device displaying a sixth image, the sharpness of the sixth image being higher than the sharpness of the fifth image; the third inclination angle belongs to a second preset interval, the value in the second preset interval is not coincident with the value in the first preset interval, a second threshold corresponding to the second preset interval is further arranged in the electronic equipment, the second threshold is different from the first threshold, the distance between the sixth position and the fifth position is positively correlated with a third compensation value, the third compensation value is positively correlated with the third inclination angle, and the third compensation value is smaller than the second threshold; the fifth time is earlier than the sixth time.
At an eighth time, the electronic device adjusts the motor to an eighth position, the electronic device displaying an eighth image, the eighth image having a higher sharpness than the seventh image; the fourth inclination angle belongs to a third preset interval, the value in the third preset interval is not coincident with the value in the second preset interval, a third threshold corresponding to the third preset interval is further arranged in the electronic equipment, the third threshold is different from the second threshold, the distance between the eighth position and the seventh position is positively correlated with the third threshold, a fourth compensation value is greater than or equal to the third threshold, the fourth compensation value is positively correlated with the fourth inclination angle, and the seventh moment is earlier than the eighth moment.
At a tenth moment, the electronic device adjusts the motor to a tenth position, and the electronic device displays a tenth image, wherein the tenth image comprises the target object, and the definition of the tenth image is higher than that of the ninth image; the electronic equipment is further provided with a fourth threshold value of the target object under the fifth inclination angle, the distance between the tenth position and the ninth position is positively correlated with a fifth compensation value, the fifth compensation value is positively correlated with the fifth inclination angle, and the fifth compensation value is smaller than the fourth threshold value; the fifth inclination angle belongs to a fourth preset interval, a threshold value corresponding to the fourth preset interval is further arranged in the electronic equipment, and the fourth threshold value is different from the threshold value corresponding to the fourth preset interval; the ninth time is earlier than the tenth time.
At a twelfth time, the electronic device adjusts the motor to a twelfth position, and the electronic device displays a twelfth image, wherein the twelfth image comprises the target object, and the definition of the twelfth image is higher than that of the eleventh image; the electronic equipment is further provided with a fifth threshold value corresponding to the target object under the sixth inclination angle, the distance between the twelfth position and the eleventh position is positively correlated with the fifth threshold value, a sixth compensation value is larger than or equal to the fifth threshold value, and the sixth compensation value is positively correlated with the sixth inclination angle; the sixth inclination angle belongs to a fourth preset interval, the fifth threshold value is different from a threshold value corresponding to the fourth preset interval, and the fifth threshold value is different from the fourth threshold value; the eleventh time is earlier than the twelfth time.
CN202311155726.8A2023-09-072023-09-07 Focusing method and related equipmentActiveCN118474538B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202311155726.8ACN118474538B (en)2023-09-072023-09-07 Focusing method and related equipment

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202311155726.8ACN118474538B (en)2023-09-072023-09-07 Focusing method and related equipment

Publications (2)

Publication NumberPublication Date
CN118474538Atrue CN118474538A (en)2024-08-09
CN118474538B CN118474538B (en)2025-03-21

Family

ID=92154704

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202311155726.8AActiveCN118474538B (en)2023-09-072023-09-07 Focusing method and related equipment

Country Status (1)

CountryLink
CN (1)CN118474538B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20110211107A1 (en)*2010-03-012011-09-01Digital Imaging Systems GmbhMethod to perform sobel calculations and normalization for auto-focus in a digital camera
CN102902132A (en)*2012-10-302013-01-30广东欧珀移动通信有限公司Automatic focusing method and device
CN103246131A (en)*2013-05-202013-08-14爱佩仪光电技术(深圳)有限公司Method of realizing three-dimensional multi-region automatic focusing by utilizing lens-incline-controllable focusing motor
US20130322863A1 (en)*2012-06-012013-12-05Hon Hai Precision Industry Co., Ltd.Camera and auto-focusing method of the camera
CN103984199A (en)*2014-05-302014-08-13爱佩仪光电技术(深圳)有限公司Adjustment and application method for tilting compensation control of lens of automatic focusing camera module
JP2014211589A (en)*2013-04-222014-11-13株式会社ニコンFocus adjustment device and imaging device
CN106161951A (en)*2016-08-082016-11-23广东欧珀移动通信有限公司A kind of focusing method, device and mobile terminal
WO2021203421A1 (en)*2020-04-102021-10-14南昌欧菲光电技术有限公司Motor system and tilt correction method and apparatus therefor, camera module, and electronic device
CN113556466A (en)*2021-06-292021-10-26荣耀终端有限公司Focusing method and electronic equipment
CN113938596A (en)*2020-06-292022-01-14北京字节跳动网络技术有限公司Method and device for shooting image
CN115623318A (en)*2022-12-202023-01-17荣耀终端有限公司 Focusing method and related device
WO2023071948A1 (en)*2021-11-012023-05-04华为技术有限公司Image capturing method and related device

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20110211107A1 (en)*2010-03-012011-09-01Digital Imaging Systems GmbhMethod to perform sobel calculations and normalization for auto-focus in a digital camera
US20130322863A1 (en)*2012-06-012013-12-05Hon Hai Precision Industry Co., Ltd.Camera and auto-focusing method of the camera
CN102902132A (en)*2012-10-302013-01-30广东欧珀移动通信有限公司Automatic focusing method and device
JP2014211589A (en)*2013-04-222014-11-13株式会社ニコンFocus adjustment device and imaging device
CN103246131A (en)*2013-05-202013-08-14爱佩仪光电技术(深圳)有限公司Method of realizing three-dimensional multi-region automatic focusing by utilizing lens-incline-controllable focusing motor
CN103984199A (en)*2014-05-302014-08-13爱佩仪光电技术(深圳)有限公司Adjustment and application method for tilting compensation control of lens of automatic focusing camera module
CN106161951A (en)*2016-08-082016-11-23广东欧珀移动通信有限公司A kind of focusing method, device and mobile terminal
WO2021203421A1 (en)*2020-04-102021-10-14南昌欧菲光电技术有限公司Motor system and tilt correction method and apparatus therefor, camera module, and electronic device
CN113938596A (en)*2020-06-292022-01-14北京字节跳动网络技术有限公司Method and device for shooting image
CN113556466A (en)*2021-06-292021-10-26荣耀终端有限公司Focusing method and electronic equipment
WO2023071948A1 (en)*2021-11-012023-05-04华为技术有限公司Image capturing method and related device
CN115623318A (en)*2022-12-202023-01-17荣耀终端有限公司 Focusing method and related device

Also Published As

Publication numberPublication date
CN118474538B (en)2025-03-21

Similar Documents

PublicationPublication DateTitle
TWI808987B (en)Apparatus and method of five dimensional (5d) video stabilization with camera and gyroscope fusion
CN106605403B (en)Shooting method and electronic equipment
KR102378472B1 (en)Method for capturing image using camera including driving device capable of rotating mirror and electronic device
US9692959B2 (en)Image processing apparatus and method
JP5670476B2 (en) Image capture device with tilt or perspective correction capability
US9313419B2 (en)Image processing apparatus and image pickup apparatus where image processing is applied using an acquired depth map
KR20180081918A (en)Electronic device and method for photographing image thereof
KR20170019827A (en)Method for processing image and electronic device supporting the same
US11792351B2 (en)Image processing method, electronic device, and computer-readable storage medium
WO2018121385A1 (en)Information processing method and apparatus, and computer storage medium
CN108616691A (en)Photographic method, device, server based on automatic white balance and storage medium
CN112351209B (en)External lens for mobile terminal, method for controlling lens, mobile terminal and storage medium
CN118429231A (en) Image correction method, device, computer equipment and storage medium
WO2018219274A1 (en)Method and apparatus for denoising processing, storage medium and terminal
CN111127541A (en)Vehicle size determination method and device and storage medium
CN118474538B (en) Focusing method and related equipment
CN116029951B (en) Image processing method and electronic device
KR20180018213A (en)Electronic device and controlling method thereof
CN117729411A (en)Voltage adjusting method and related device
CN114093020A (en)Motion capture method, motion capture device, electronic device and storage medium
CN118474217B (en)Data transmission method and related device
US12309524B2 (en)Capturing self-photo images using a multi-camera electronic device
CN118574005B (en)Shooting method, shooting device, storage medium and program product
WO2022178782A1 (en)Electric device, method of controlling electric device, and computer readable storage medium
CN113848644B (en)Focal length adjusting method, device and equipment of AR glasses and readable storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
CB02Change of applicant information

Country or region after:China

Address after:Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Applicant after:Honor Terminal Co.,Ltd.

Address before:3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong

Applicant before:Honor Device Co.,Ltd.

Country or region before:China

CB02Change of applicant information
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp