WO2021057652A1 - Focusing method and apparatus, electronic device, and computer readable storage medium - Google Patents

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

Info

Publication number
WO2021057652A1
WO2021057652A1 PCT/CN2020/116481 CN2020116481W WO2021057652A1 WO 2021057652 A1 WO2021057652 A1 WO 2021057652A1 CN 2020116481 W CN2020116481 W CN 2020116481W WO 2021057652 A1 WO2021057652 A1 WO 2021057652A1
Authority
WO
WIPO (PCT)
Prior art keywords
subject
preview image
area
target
image
Prior art date
Application number
PCT/CN2020/116481
Other languages
French (fr)
Chinese (zh)
Inventor
贾玉虎
Original Assignee
Oppo广东移动通信有限公司
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 Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2021057652A1 publication Critical patent/WO2021057652A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/61Control of cameras or camera modules based on recognised objects
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/61Control of cameras or camera modules based on recognised objects
    • H04N23/611Control of cameras or camera modules based on recognised objects where the recognised objects include parts of the human body
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • H04N23/675Focus control based on electronic image sensor signals comprising setting of focusing regions

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Studio Devices (AREA)
  • Automatic Focus Adjustment (AREA)

Abstract

A focusing method, comprising: obtaining a first preview image; determining a target main body in the first preview image; when the first preview image satisfies a preset condition, determining a centroid region of the target main body, wherein the preset condition comprises at least one of a face area corresponding to the target main body being less than or equal to a face area threshold and the brightness of the first preview image being less than or equal to a brightness threshold; and focusing according to the centroid region.

Description

对焦方法和装置、电子设备、计算机可读存储介质Focusing method and device, electronic equipment, and computer readable storage medium
相关申请的交叉引用Cross-references to related applications
本申请要求于2019年9月29日提交中国专利局、申请号为201910931431.2、发明名称为“对焦方法和装置、电子设备、计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on September 29, 2019, the application number is 201910931431.2, and the invention title is "focusing method and device, electronic equipment, computer-readable storage medium", and the entire content of it is approved The reference is incorporated in this application.
技术领域Technical field
本申请涉及图像处理领域,特别是涉及一种对焦方法和装置、电子设备、计算机可读存储介质。This application relates to the field of image processing, in particular to a focusing method and device, electronic equipment, and computer-readable storage medium.
背景技术Background technique
随着图像处理技术的发展,人们对于图像的要求越来越高。在图像拍摄过程中,传统的对焦方法是对焦在整张图像的中心位置。然而,目前的对焦方法,在一些场景下,存在不能准确对焦导致拍摄对象较模糊的问题。With the development of image processing technology, people have higher and higher requirements for images. In the image shooting process, the traditional focusing method is to focus on the center of the entire image. However, in some scenes, the current focusing method has the problem that the subject cannot be accurately focused and the subject is blurred.
发明内容Summary of the invention
根据本申请的各种实施例提供一种对焦方法、装置、电子设备、计算机可读存储介质。According to various embodiments of the present application, a focusing method, device, electronic device, and computer-readable storage medium are provided.
一种对焦方法,包括:A focusing method includes:
获取第一预览图像;Obtain the first preview image;
确定第一预览图像中的目标主体;Determine the target subject in the first preview image;
当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种;When the first preview image meets the preset conditions, determine the centroid area of the target subject, where the preset conditions include that the face area corresponding to the target subject is less than or equal to the face area threshold, and the brightness of the first preview image is less than or equal to the brightness threshold At least one of
根据质心区域进行对焦。Focus based on the center of mass area.
一种对焦装置,包括:A focusing device includes:
获取模块,用于获取第一预览图像;An obtaining module for obtaining the first preview image;
主体确定模块,用于确定第一预览图像中的目标主体;The subject determination module is used to determine the target subject in the first preview image;
质心区域确定模块,用于当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种;The centroid area determination module is used to determine the centroid area of the target subject when the first preview image meets preset conditions, where the preset conditions include that the face area corresponding to the target subject is less than or equal to the face area threshold, and the first preview image The brightness of is less than or equal to at least one of the brightness thresholds;
对焦模块,用于根据质心区域进行对焦。The focusing module is used for focusing according to the center of mass area.
一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行如下步骤:An electronic device includes a memory and a processor, and a computer program is stored in the memory. When the computer program is executed by the processor, the processor executes the following steps:
获取第一预览图像;Obtain the first preview image;
确定第一预览图像中的目标主体;Determine the target subject in the first preview image;
当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种;When the first preview image meets the preset conditions, determine the centroid area of the target subject, where the preset conditions include that the face area corresponding to the target subject is less than or equal to the face area threshold, and the brightness of the first preview image is less than or equal to the brightness threshold At least one of
根据质心区域进行对焦。Focus based on the center of mass area.
一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如下步骤:A computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the following steps:
获取第一预览图像;Obtain the first preview image;
确定第一预览图像中的目标主体;Determine the target subject in the first preview image;
当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目 标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种;When the first preview image meets the preset conditions, determine the centroid area of the target subject, where the preset conditions include that the face area corresponding to the target subject is less than or equal to the face area threshold, and the brightness of the first preview image is less than or equal to the brightness threshold At least one of
根据质心区域进行对焦。Focus based on the center of mass area.
上述对焦方法和装置、电子设备、计算机可读存储介质,获取第一预览图像,确定第一预览图像中的目标主体,当第一预览图像满足目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种时,确定目标主体的质心区域,并根据质心区域进行对焦,能够在人脸过小或者光照过暗时可以迅速找到适当的位置进行自动对焦,提高对焦效率,同时避免对焦到背景区域,提高对焦准确性以及拍摄对象的清晰度。The above-mentioned focusing method and device, electronic equipment, and computer-readable storage medium acquire a first preview image, and determine the target subject in the first preview image. When the first preview image satisfies the target subject’s corresponding face area is less than or equal to the face area When the threshold value and the brightness of the first preview image are less than or equal to the brightness threshold value, determine the center of mass area of the target subject and focus based on the center of mass area, which can quickly find an appropriate position when the face is too small or the light is too dark Carry out autofocus to improve the focus efficiency, while avoiding focusing on the background area, improving the focus accuracy and the sharpness of the subject.
附图说明Description of the drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly describe the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.
图1为一个实施例中图像处理电路的示意图。Fig. 1 is a schematic diagram of an image processing circuit in an embodiment.
图2为一个实施例中对焦方法的流程图。Fig. 2 is a flowchart of a focusing method in an embodiment.
图3为一个实施例中确定目标主体的质心区域的流程示意图。Fig. 3 is a schematic diagram of the process of determining the centroid region of the target subject in an embodiment.
图4为一个实施例中确定第一预览图像中的目标主体的流程示意图。Fig. 4 is a schematic diagram of a process of determining a target subject in a first preview image in an embodiment.
图5为一个实施例中质心坐标求取的流程示意图。Fig. 5 is a schematic diagram of the process of obtaining the centroid coordinates in an embodiment.
图6为一个实施例中主体检测的过程示意图。Fig. 6 is a schematic diagram of a subject detection process in an embodiment.
图7为另一个实施例中对焦方法的流程示意图。FIG. 7 is a schematic flowchart of a focusing method in another embodiment.
图8为一个实施例中对焦装置的结构框图。Fig. 8 is a structural block diagram of a focusing device in an embodiment.
图9为一个实施例中电子设备的内部结构示意图。Fig. 9 is a schematic diagram of the internal structure of an electronic device in an embodiment.
具体实施方式detailed description
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions, and advantages of this application clearer, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the application, and not used to limit the application.
可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本申请的范围的情况下,可以将第一预览图像称为第二预览图像,且类似地,可将第二预览图像称为第一预览图像。第一预览图像和第二预览图像两者都是预览图像,但其不是同一预览图像。It can be understood that the terms "first", "second", etc. used in this application can be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element. For example, without departing from the scope of the present application, the first preview image may be referred to as the second preview image, and similarly, the second preview image may be referred to as the first preview image. Both the first preview image and the second preview image are preview images, but they are not the same preview image.
本申请实施例中的对焦方法可应用于电子设备。该电子设备可为带有摄像头的计算机设备、个人数字助理、平板电脑、智能手机、穿戴式设备等。电子设备中的摄像头在拍摄图像时,会进行自动对焦,以保证拍摄的图像清晰。该电子设备中的摄像头数量不限,例如可以是一个、两个、三个等。The focusing method in the embodiment of the present application can be applied to electronic equipment. The electronic device may be a computer device with a camera, a personal digital assistant, a tablet computer, a smart phone, a wearable device, etc. When the camera in the electronic device takes an image, it will automatically focus to ensure that the captured image is clear. The number of cameras in the electronic device is not limited, for example, it can be one, two, three, and so on.
在一个实施例中,上述电子设备中可包括图像处理电路,图像处理电路可以利用硬件和/或软件组件实现,可包括定义ISP(Image Signal Processing,图像信号处理)管线的各种处理单元。图1为一个实施例中图像处理电路的示意图。如图1所示,为便于说明,仅示出与本申请实施例相关的图像处理技术的各个方面。In one embodiment, the above electronic device may include an image processing circuit, which may be implemented by hardware and/or software components, and may include various processing units that define an ISP (Image Signal Processing, image signal processing) pipeline. Fig. 1 is a schematic diagram of an image processing circuit in an embodiment. As shown in FIG. 1, for ease of description, only various aspects of the image processing technology related to the embodiments of the present application are shown.
如图1所示,图像处理电路包括ISP处理器140和控制逻辑器150。成像设备110捕捉的图像数据首先由ISP处理器140处理,ISP处理器140对图像数据进行分析以捕捉可 用于确定和/或成像设备110的一个或多个控制参数的图像统计信息。成像设备110可包括具有一个或多个透镜112、图像传感器114、执行器116的照相机。执行器116可驱动透镜112移动。图像传感器114可包括色彩滤镜阵列(如Bayer滤镜),图像传感器114可获取用图像传感器114的每个成像像素捕捉的光强度和波长信息,并提供可由ISP处理器140处理的一组原始图像数据。传感器120(如陀螺仪)可基于传感器120接口类型把采集的图像处理的参数(如防抖参数)提供给ISP处理器140。传感器120接口可以利用SMIA(Standard Mobile Imaging Architecture,标准移动成像架构)接口、其它串行或并行照相机接口或上述接口的组合。As shown in FIG. 1, the image processing circuit includes an ISP processor 140 and a control logic 150. The image data captured by the imaging device 110 is first processed by the ISP processor 140, and the ISP processor 140 analyzes the image data to capture image statistics that can be used to determine and/or one or more control parameters of the imaging device 110. The imaging device 110 may include a camera having one or more lenses 112, an image sensor 114, and an actuator 116. The actuator 116 can drive the lens 112 to move. The image sensor 114 may include a color filter array (such as a Bayer filter). The image sensor 114 may obtain the light intensity and wavelength information captured by each imaging pixel of the image sensor 114, and provide a set of raw materials that can be processed by the ISP processor 140. Image data. The sensor 120 (such as a gyroscope) can provide the collected image processing parameters (such as anti-shake parameters) to the ISP processor 140 based on the interface type of the sensor 120. The sensor 120 interface may use SMIA (Standard Mobile Imaging Architecture) interface, other serial or parallel camera interfaces, or a combination of the above interfaces.
此外,图像传感器114也可将原始图像数据发送给传感器120,传感器120可基于传感器120接口类型把原始图像数据提供给ISP处理器140,或者传感器120将原始图像数据存储到图像存储器130中。In addition, the image sensor 114 may also send raw image data to the sensor 120, and the sensor 120 may provide the raw image data to the ISP processor 140 based on the interface type of the sensor 120, or the sensor 120 may store the raw image data in the image memory 130.
ISP处理器140按多种格式逐个像素地处理原始图像数据。例如,每个图像像素可具有8、10、12或14比特的位深度,ISP处理器140可对原始图像数据进行一个或多个图像处理操作、收集关于图像数据的统计信息。其中,图像处理操作可按相同或不同的位深度精度进行。The ISP processor 140 processes the original image data pixel by pixel in a variety of formats. For example, each image pixel may have a bit depth of 8, 10, 12, or 14 bits, and the ISP processor 140 may perform one or more image processing operations on the original image data, and collect statistical information about the image data. Among them, the image processing operations can be performed with the same or different bit depth accuracy.
ISP处理器140还可从图像存储器130接收图像数据。例如,传感器120接口将原始图像数据发送给图像存储器130,图像存储器130中的原始图像数据再提供给ISP处理器140以供处理。图像存储器130可为存储器装置的一部分、存储设备、或电子设备内的独立的专用存储器,并可包括DMA(Direct Memory Access,直接直接存储器存取)特征。The ISP processor 140 may also receive image data from the image memory 130. For example, the sensor 120 interface sends the original image data to the image memory 130, and the original image data in the image memory 130 is then provided to the ISP processor 140 for processing. The image memory 130 may be a part of a memory device, a storage device, or an independent dedicated memory in an electronic device, and may include DMA (Direct Memory Access) features.
当接收到来自图像传感器114接口或来自传感器120接口或来自图像存储器130的原始图像数据时,ISP处理器140可进行一个或多个图像处理操作,如时域滤波。处理后的图像数据可发送给图像存储器130,以便在被显示之前进行另外的处理。ISP处理器140从图像存储器130接收处理数据,并对所述处理数据进行原始域中以及RGB和YCbCr颜色空间中的图像数据处理。ISP处理器140处理后的图像数据可输出给显示器170,以供用户观看和/或由图形引擎或GPU(Graphics Processing Unit,图形处理器)进一步处理。此外,ISP处理器140的输出还可发送给图像存储器130,且显示器170可从图像存储器130读取图像数据。在一个实施例中,图像存储器130可被配置为实现一个或多个帧缓冲器。此外,ISP处理器140的输出可发送给编码器/解码器160,以便编码/解码图像数据。编码的图像数据可被保存,并在显示于显示器170设备上之前解压缩。编码器/解码器160可由CPU或GPU或协处理器实现。When receiving raw image data from the image sensor 114 interface or from the sensor 120 interface or from the image memory 130, the ISP processor 140 may perform one or more image processing operations, such as temporal filtering. The processed image data can be sent to the image memory 130 for additional processing before being displayed. The ISP processor 140 receives the processed data from the image memory 130, and performs image data processing in the original domain and in the RGB and YCbCr color spaces on the processed data. The image data processed by the ISP processor 140 may be output to the display 170 for viewing by the user and/or further processed by a graphics engine or a GPU (Graphics Processing Unit, graphics processor). In addition, the output of the ISP processor 140 can also be sent to the image memory 130, and the display 170 can read image data from the image memory 130. In one embodiment, the image memory 130 may be configured to implement one or more frame buffers. In addition, the output of the ISP processor 140 may be sent to the encoder/decoder 160 in order to encode/decode image data. The encoded image data can be saved and decompressed before being displayed on the display 170 device. The encoder/decoder 160 may be implemented by a CPU or GPU or a co-processor.
ISP处理器140确定的统计数据可发送给控制逻辑器150。例如,统计数据可包括自动曝光、自动白平衡、自动聚焦、闪烁检测、黑电平补偿、透镜112阴影校正等图像传感器114统计信息。控制逻辑器150可包括执行一个或多个例程(如固件)的处理器和/或微控制器,一个或多个例程可根据接收的统计数据,确定成像设备110的控制参数及ISP处理器140的控制参数。例如,成像设备110的控制参数可包括传感器120控制参数(例如增益、曝光控制的积分时间、防抖参数等)、照相机闪光控制参数、透镜112控制参数(例如聚焦或变焦用焦距)、或这些参数的组合。控制逻辑器150可将透镜112的控制参数输出给执行器116,由执行器116根据控制参数驱动透镜112移动。ISP控制参数可包括用于自动白平衡和颜色调整(例如,在RGB处理期间)的增益水平和色彩校正矩阵,以及透镜112阴影校正参数。The statistical data determined by the ISP processor 140 may be sent to the control logic 150. For example, the statistical data may include image sensor 114 statistical information such as automatic exposure, automatic white balance, automatic focus, flicker detection, black level compensation, and lens 112 shading correction. The control logic 150 may include a processor and/or a microcontroller that executes one or more routines (such as firmware). The one or more routines can determine the control parameters and ISP processing of the imaging device 110 based on the received statistical data. The control parameters of the device 140. For example, the control parameters of the imaging device 110 may include sensor 120 control parameters (such as gain, integration time for exposure control, anti-shake parameters, etc.), camera flash control parameters, lens 112 control parameters (such as focal length for focusing or zooming), or these The combination of parameters. The control logic 150 can output the control parameters of the lens 112 to the actuator 116, and the actuator 116 drives the lens 112 to move according to the control parameters. The ISP control parameters may include gain levels and color correction matrices for automatic white balance and color adjustment (for example, during RGB processing), and lens 112 shading correction parameters.
在本申请实施例中,该电子设备所包括的处理器140执行存储在存储器上的计算机程序时实现获取第一预览图像;确定第一预览图像中的目标主体;当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种;根据质心区域进行对焦。In the embodiment of the present application, the processor 140 included in the electronic device executes the computer program stored on the memory to obtain the first preview image; determine the target subject in the first preview image; when the first preview image satisfies the preset In the condition, determine the centroid area of the target subject, where the preset condition includes at least one of the face area corresponding to the target subject is less than or equal to the face area threshold, and the brightness of the first preview image is less than or equal to the brightness threshold; according to the centroid area Focus.
图2为一个实施例中对焦方法的流程图。本实施例中的对焦方法,以运行于图1中的终端为例进行描述。如图5所示,对焦方法包括操作202至操作208。Fig. 2 is a flowchart of a focusing method in an embodiment. The focusing method in this embodiment is described by taking the terminal operating in FIG. 1 as an example. As shown in FIG. 5, the focusing method includes operation 202 to operation 208.
操作202,获取第一预览图像。In operation 202, a first preview image is obtained.
其中,预览图像可为可见光图像。预览图像是指摄像头未进行拍摄时呈现在电子设备屏幕上的图像。第一预览图像可为当前帧的预览图像。Among them, the preview image may be a visible light image. The preview image refers to the image presented on the screen of the electronic device when the camera is not shooting. The first preview image may be a preview image of the current frame.
具体地,当获取到采集指令时,电子设备的摄像头采集第一预览图像并显示在电子设备的显示装置上。Specifically, when the collection instruction is acquired, the camera of the electronic device collects the first preview image and displays it on the display device of the electronic device.
操作204,确定第一预览图像中的目标主体。In operation 204, the target subject in the first preview image is determined.
其中,目标主体可为预先配置的能够识别的对象。该对象可为人、物、动物等。物可包括花、山、树等。动物可包括猫、狗、牛、羊、老虎等。目标主体可以是不规则图形轮廓,也可以是规则的图形轮廓。Among them, the target subject can be a pre-configured recognizable object. The object can be a person, thing, animal, etc. Objects can include flowers, mountains, trees, etc. Animals may include cats, dogs, cows, sheep, tigers, etc. The target body can be an irregular graphic contour or a regular graphic contour.
具体地,电子设备可对第一预览图像进行主体检测,确定第一预览图像中的目标主体。或者电子设备可通过检测第一预览图像中的特征点得到目标主体。Specifically, the electronic device may perform subject detection on the first preview image to determine the target subject in the first preview image. Or the electronic device can obtain the target subject by detecting the feature points in the first preview image.
操作206,当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种。Operation 206: When the first preview image satisfies a preset condition, determine the centroid area of the target subject, where the preset condition includes that the face area corresponding to the target subject is less than or equal to the face area threshold, and the brightness of the first preview image is less than or Equal to at least one of the brightness thresholds.
其中,质心是指物质上被认为质量集中于此的一个假想点。质心区域是指该质心所在的区域。质心区域可以是一个方形区域、圆形区域、三角形区域等不限于此。人脸面积阈值是指在电子设备中存储的人脸面积的临界值。人脸面积阈值可根据需求设置。例如,在同一距离下,用户A的人脸面积大于预设人脸面积阈值。为了符合个性化设置,用户A可自行配置人脸面积阈值。亮度阈值是指在电子设备中存储的图像亮度的临界值。亮度阈值也可根据时间配置。例如,白天,即早上七点到晚上六点,为第一亮度阈值;晚上,即晚上六点到早上七点,为第二亮度阈值。第一亮度阈值大于第二亮度阈值。或者,亮度阈值根据地点配置。电子设备获取所在地点,当该地点为室外时,自动选择第一亮度阈值;当该地点为室内时,自动选择第二亮度阈值,其中,第一亮度阈值大于第二亮度阈值。Among them, the center of mass refers to an imaginary point where mass is considered to be concentrated in matter. The center of mass area refers to the area where the center of mass is located. The centroid area may be a square area, a circular area, a triangular area, etc., and is not limited thereto. The face area threshold refers to the critical value of the face area stored in the electronic device. The face area threshold can be set according to requirements. For example, at the same distance, the face area of user A is greater than the preset face area threshold. In order to meet the personalized settings, user A can configure the face area threshold by himself. The brightness threshold refers to the critical value of the brightness of the image stored in the electronic device. The brightness threshold can also be configured according to time. For example, during the day, that is, from seven in the morning to six in the evening, is the first brightness threshold; at night, that is, from six in the evening to seven in the morning, is the second brightness threshold. The first brightness threshold is greater than the second brightness threshold. Or, the brightness threshold is configured according to the location. The electronic device obtains the location, and when the location is outdoor, the first brightness threshold is automatically selected; when the location is indoor, the second brightness threshold is automatically selected, where the first brightness threshold is greater than the second brightness threshold.
具体地,当电子设备检测到第一预览图像满足预设条件时,即预设条件包括目标主体对应的人脸面积小于人脸面积阈值、人脸面积等于人脸面积阈值、第一预览图像的亮度小于亮度阈值、第一预览图像的亮度等于亮度阈值、目标主体对应的人脸面积小于人脸面积阈值且亮度小于亮度阈值、人脸面积小于人脸面积阈值且亮度等于亮度阈值、人脸面积等于面积阈值且亮度小于亮度阈值,或者人脸面积等于面积阈值且亮度等于亮度阈值,确定目标主体的质心区域。Specifically, when the electronic device detects that the first preview image satisfies the preset condition, that is, the preset condition includes that the face area corresponding to the target subject is less than the face area threshold, the face area is equal to the face area threshold, and the first preview image The brightness is less than the brightness threshold, the brightness of the first preview image is equal to the brightness threshold, the face area corresponding to the target subject is less than the face area threshold and the brightness is less than the brightness threshold, the face area is less than the face area threshold and the brightness is equal to the brightness threshold, face area It is equal to the area threshold and the brightness is less than the brightness threshold, or the face area is equal to the area threshold and the brightness is equal to the brightness threshold, and the center of mass region of the target subject is determined.
本实施例中,电子设备确定第一预览图像中的目标主体所在区域。电子设备在目标主体所在区域中检测是否存在人脸。当目标主体所在区域中存在人脸时,判断目标主体的人脸面积是否满足人脸面积阈值。In this embodiment, the electronic device determines the area where the target subject in the first preview image is located. The electronic device detects whether there is a human face in the area where the target subject is located. When there is a face in the area where the target subject is located, it is determined whether the face area of the target subject meets the face area threshold.
本实施例中,电子设备通过检测人脸的特征点得到人脸区域,再获取该人脸特征点所围成的区域对应的像素点的数量计算得到目标主体对应的人脸面积。In this embodiment, the electronic device obtains the face area by detecting the feature points of the face, and then obtains the number of pixels corresponding to the area enclosed by the face feature points to calculate the face area corresponding to the target subject.
本实施例中,电子设备可通过HSV(Hue Saturation Value,色调饱和度亮度)颜色模型算法得到第一预览图像的亮度。In this embodiment, the electronic device can obtain the brightness of the first preview image through the HSV (Hue Saturation Value) color model algorithm.
本实施例中,电子设备可获取环境亮度,将环境亮度转化为图像亮度,从而得到图像亮度。In this embodiment, the electronic device can obtain the environmental brightness, convert the environmental brightness into the image brightness, and obtain the image brightness.
本实施例中,电子设备可通过深度摄像头获取人脸到手机屏幕的距离,根据该距离计算得到人脸面积。或者,电子设备可根据距离与人脸面积的对应关系得到目标主体对应的人脸面积。In this embodiment, the electronic device can obtain the distance from the human face to the screen of the mobile phone through the depth camera, and calculate the area of the human face according to the distance. Alternatively, the electronic device may obtain the face area corresponding to the target subject according to the correspondence between the distance and the face area.
操作208,根据质心区域进行对焦。In operation 208, focus is performed according to the center of mass region.
其中,自动对焦的方式可以是反差式对焦(Contrast Detection Auto Focus,CDAF)、 相位对焦(Phase Detection Auto Focus,PDAF)或者激光对焦(Laser Detection Auto Focus,LADF)等不限于此。Wherein, the auto-focusing method may be Contrast Detection Auto Focus (CDAF), Phase Detection Auto Focus (PDAF) or Laser Focus (Laser Detection Auto Focus, LADF), etc., which are not limited to this.
具体地,电子设备可将质心区域作为第一预览图像中的对焦区域。电子设备可根据对焦区域控制摄像头进行自动对焦。即电子设备根据对焦区域调节透镜,进行自动对焦。相位检测自动对焦是通过传感器获取相位差,根据相位差计算离焦值,根据离焦值控制透镜移动,再寻找聚焦值(Focus Value,简称FV)峰值。激光对焦是通过记录红外激光从拍摄装置发射,经过目标表面反射,最后再被测距仪接收到的时间差,来计算目标到测试仪器的距离,从而实现对焦。Specifically, the electronic device may use the center of mass area as the focus area in the first preview image. The electronic device can control the camera to auto-focus according to the focus area. That is, the electronic device adjusts the lens according to the focus area to perform automatic focusing. The phase detection autofocus is to obtain the phase difference through the sensor, calculate the defocus value according to the phase difference, control the lens movement according to the defocus value, and then look for the focus value (FV) peak value. Laser focusing is to calculate the distance between the target and the test instrument by recording the time difference between the infrared laser emitted from the camera, reflected by the target surface, and finally received by the rangefinder to achieve focusing.
本实施例中,电子设备可将质心区域作为参考区域,并根据参考区域处理得到对焦区域,进行自动对焦。In this embodiment, the electronic device may use the centroid area as the reference area, and process the focus area according to the reference area to perform autofocus.
本实施例中的对焦方法,获取第一预览图像,确定第一预览图像中的目标主体,当第一预览图像满足目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种时,确定目标主体的质心区域,并以质心区域作为对焦区域进行对焦,能够在人脸过小或者光照过暗时可以迅速找到适当的位置进行自动对焦,提高对焦效率,同时避免对焦到背景区域,提高对焦准确性以及拍摄对象的清晰度。In the focusing method in this embodiment, a first preview image is acquired, and the target subject in the first preview image is determined. When the first preview image satisfies the target subject's face area less than or equal to the face area threshold, the first preview image When the brightness is less than or equal to at least one of the brightness thresholds, the centroid area of the target subject is determined, and the centroid area is used as the focus area for focusing. It can quickly find an appropriate position for autofocus when the face is too small or the light is too dark. Improve the focus efficiency, while avoiding focusing on the background area, improving the focus accuracy and the sharpness of the subject.
在一个实施例中,如图3所示,图3为一个实施例中确定目标主体的质心区域的流程示意图,包括:In an embodiment, as shown in FIG. 3, FIG. 3 is a schematic diagram of the process of determining the centroid region of the target subject in an embodiment, including:
操作302,获取目标主体对应的像素点的集合。In operation 302, a set of pixels corresponding to the target subject is obtained.
其中,像素点的集合是指目标主体所对应的多个像素点。Among them, the set of pixels refers to multiple pixels corresponding to the target subject.
具体地,电子设备确定目标主体对应的像素点的集合。例如,目标主体为人脸,那么目标主体对应的像素点的集合为人脸轮廓所围成的多个像素点。目标主体为人像,那么目标主体对应的像素点的集合为人像所围成的多个像素点。Specifically, the electronic device determines the set of pixel points corresponding to the target subject. For example, if the target subject is a human face, then the set of pixels corresponding to the target subject is a plurality of pixels surrounded by the contour of the human face. The target subject is a portrait, so the set of pixels corresponding to the target subject is a plurality of pixels surrounded by the portrait.
操作304,获取目标主体所对应的像素点的集合中各个像素点的坐标。In operation 304, the coordinates of each pixel in the set of pixel points corresponding to the target subject are obtained.
其中,每个像素点均有像素点坐标。Among them, each pixel has pixel coordinates.
具体地,电子设备获取目标主体所对应的像素点的集合中各个像素点的坐标。例如,像素点的集合中有100个像素点,那么电子设备获取100个像素点中每个像素点的坐标。Specifically, the electronic device obtains the coordinates of each pixel in the set of pixel points corresponding to the target body. For example, if there are 100 pixels in the set of pixels, the electronic device obtains the coordinates of each pixel in the 100 pixels.
操作306,根据各个像素点的坐标,得到目标主体的质心坐标。In operation 306, the centroid coordinates of the target body are obtained according to the coordinates of each pixel point.
具体地,电子设备从各个像素点的坐标中查找到横坐标最小值、横坐标最大值、纵坐标最小值和纵坐标最大值。电子设备根据横坐标最小值和横坐标最大值求均值得到质心坐标的横坐标。电子设备根据纵坐标最小值和最大值求均值得到质心坐标的纵坐标。Specifically, the electronic device finds the minimum value of the abscissa, the maximum value of the abscissa, the minimum value of the ordinate, and the maximum value of the ordinate from the coordinates of each pixel point. The electronic device obtains the abscissa of the centroid coordinate by averaging the abscissa minimum value and the abscissa maximum value. The electronic device obtains the ordinate of the center of mass coordinate by averaging the minimum and maximum values of the ordinate.
本实施例中,电子设备可获取目标主体的轮廓对应的像素点坐标。根据目标主体的轮廓上各个像素点对应的目标像素点坐标得到目标主体的质心坐标。电子设备可对轮廓上像素点坐标的横坐标求均值以及纵坐标求均值得到目标主体的质心坐标。In this embodiment, the electronic device can obtain the pixel coordinates corresponding to the contour of the target subject. The centroid coordinates of the target body are obtained according to the target pixel point coordinates corresponding to each pixel point on the contour of the target body. The electronic device can average the abscissa and the ordinate of the pixel coordinates on the contour to obtain the centroid coordinates of the target body.
本实施例中,当计算得到的质心坐标中含有小数时,对质心坐标取整。或者,对该小数进行四舍五入,得到质心坐标。In this embodiment, when the calculated centroid coordinates contain decimals, the centroid coordinates are rounded off. Or, round the decimal to get the centroid coordinate.
操作308,确定质心坐标所在区域。In operation 308, the area where the centroid coordinates are located is determined.
具体地,电子设备可以质心坐标为中心确定质心坐标所在区域。例如以质心坐标为中心,横向取150个像素点,纵向取150个像素点作为质心坐标所在区域。或者以质心坐标为中心,以150个像素点为半径取一个圆形作为质心坐标所在区域等不限于此。Specifically, the electronic device can determine the area where the centroid coordinates are located with the centroid coordinates as the center. For example, take the centroid coordinates as the center, take 150 pixels in the horizontal direction, and take 150 pixels in the vertical direction as the area where the centroid coordinates are located. Or taking the centroid coordinates as the center, taking a circle with 150 pixels as the radius as the area where the centroid coordinates are located, etc. are not limited to this.
操作310,将质心坐标所在区域作为目标主体的质心区域。In operation 310, the area where the center of mass coordinates is located is taken as the center of mass area of the target subject.
本申请实施例中的对焦方法,获取目标主体对应的像素点的集合,获取各个像素点的坐标,得到质心坐标,将质心坐标所在区域作为目标主体的质心区域,能够确定对焦区域,提高目标主体拍摄的清晰度。The focusing method in the embodiment of the present application obtains a collection of pixel points corresponding to the target subject, obtains the coordinates of each pixel point, and obtains the centroid coordinates, and uses the area where the centroid coordinates are located as the centroid area of the target subject, which can determine the focus area and improve the target subject The clarity of the shot.
在一个实施例中,根据各个像素点的坐标,得到目标主体的质心坐标,包括:将各个像素点的坐标求加权平均值,得到目标主体的质心坐标。In one embodiment, obtaining the coordinates of the center of mass of the target subject according to the coordinates of each pixel includes: calculating a weighted average of the coordinates of each pixel to obtain the coordinates of the center of mass of the target subject.
具体地,电子设备将各个像素点的坐标的横坐标求加权平均值,以及各个像素点坐标的纵坐标求加权平均值,得到目标主体的质心坐标。例如,目标像素点坐标有100个,分别为(X1,Y1)、(X2,Y2)…(X100,Y100),设质心坐标为(A,B),那么A=(X1+X2+…+X100)/100,Y=(Y1+Y2+…+Y100)/100。Specifically, the electronic device calculates the weighted average value of the abscissa of the coordinates of each pixel point, and calculates the weighted average value of the ordinate of the coordinates of each pixel point, to obtain the centroid coordinates of the target body. For example, there are 100 target pixel coordinates, namely (X1,Y1), (X2,Y2)...(X100,Y100), set the center of mass coordinates to (A, B), then A=(X1+X2+...+X100 )/100, Y=(Y1+Y2+...+Y100)/100.
本申请实施例中的对焦方法,将各个像素点的坐标求加权平均值,得到目标主体的质心坐标,能够获取所有的目标像素点坐标进行计算,提高质心坐标计算的准确性。The focusing method in the embodiment of the present application calculates the weighted average of the coordinates of each pixel point to obtain the centroid coordinates of the target body, which can obtain the coordinates of all the target pixels for calculation, and improve the accuracy of the centroid coordinate calculation.
在一个实施例中,当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种,包括:In one embodiment, when the first preview image satisfies a preset condition, the centroid area of the target subject is determined, where the preset condition includes that the face area corresponding to the target subject is less than or equal to the face area threshold and the first preview image The brightness is less than or equal to at least one of the brightness thresholds, including:
当第一预览图像满足目标主体对应的人脸面积大于人脸面积阈值时,判断第一预览图像的亮度是否大于亮度阈值;When the first preview image satisfies that the face area corresponding to the target subject is greater than the face area threshold, determine whether the brightness of the first preview image is greater than the brightness threshold;
当第一预览图像的亮度小于或等于亮度阈值时,确定目标主体的质心区域。When the brightness of the first preview image is less than or equal to the brightness threshold, the center of mass region of the target subject is determined.
其中,判断目标主体对应的人脸面积大于人脸面积阈值的条件优先级可高于判断亮度条件的优先级。Among them, the priority of determining that the face area corresponding to the target subject is greater than the threshold of the face area may be higher than the priority of determining the brightness condition.
具体地,当电子设备检测到第一预览图像满足第一预览图像中的目标主体对应的人脸面积大于人脸面积阈值时,判断第一预览图像的亮度是否大于亮度阈值。当电子设备检测到第一预览图像的亮度小于或等于亮度阈值时,确定目标主体的质心区域。Specifically, when the electronic device detects that the first preview image satisfies that the face area corresponding to the target subject in the first preview image is greater than the face area threshold, it determines whether the brightness of the first preview image is greater than the brightness threshold. When the electronic device detects that the brightness of the first preview image is less than or equal to the brightness threshold, the center of mass region of the target subject is determined.
本申请实施例中的对焦方法,通过人脸面积是否大于人脸面积阈值以及第一预览图像的亮度是否大于亮度阈值两个条件判断是否需要确定目标主体的质心区域,能够在人脸面积大于人脸面积阈值且光线过暗时迅速找到适当的位置进行自动对焦,提高对焦效率,同时避免对焦到背景区域,提高对焦准确性以及拍摄对象的清晰度。The focusing method in the embodiment of the present application determines whether it is necessary to determine the center of mass region of the target subject based on the two conditions of whether the face area is greater than the face area threshold and whether the brightness of the first preview image is greater than the brightness threshold. When the face area threshold is too dark and the light is too dark, it quickly finds the appropriate position for autofocus, which improves the focusing efficiency, while avoiding focusing on the background area, improving the focusing accuracy and the sharpness of the subject.
在一个实施例中,如图4所示,为一个实施例中确定第一预览图像中的目标主体的流程示意图,包括:In one embodiment, as shown in FIG. 4, it is a schematic diagram of the process of determining the target subject in the first preview image in one embodiment, including:
操作402,对第一预览图像进行主体检测,得到目标主体所在区域,其中,目标主体所在区域对应的图像为主体掩膜图。In operation 402, subject detection is performed on the first preview image to obtain the area where the target subject is located, where the image corresponding to the area where the target subject is located is the subject mask map.
其中,目标主体所在区域可以是一个规则的区域。例如目标主体所在区域为矩形区域。目标主体所在区域的面积大于目标主体的面积。主体掩膜(mask)图是用于识别图像中主体的图像滤镜模板,可以遮挡图像的其他部分,筛选出图像中的主体。Among them, the area where the target subject is located can be a regular area. For example, the area where the target subject is located is a rectangular area. The area where the target subject is located is larger than the area of the target subject. The subject mask (mask) is an image filter template used to identify the subject in the image, which can block other parts of the image and filter out the subject in the image.
具体地,电子设备对第一预览图像进行主体检测,得到目标主体所在区域。Specifically, the electronic device performs subject detection on the first preview image to obtain the area where the target subject is located.
操作404,获取目标主体所在区域中各像素点的灰度值。In operation 404, the gray value of each pixel in the area where the target subject is located is obtained.
其中,主体掩膜图中的一般包含两种颜色,即黑和白。且主体掩膜图一般包含两个灰度值,例如0和255不限于此。Among them, the main mask image generally contains two colors, namely black and white. And the main body mask image generally includes two gray values, for example, 0 and 255 are not limited thereto.
具体地,电子设备获取主体掩膜图中目标主体所在区域中各像素点的灰度值。Specifically, the electronic device obtains the gray value of each pixel in the area where the target subject is located in the subject mask.
操作406,确定目标主体所在区域中满足目标灰度值的目标像素点集合。In operation 406, a set of target pixels meeting the target gray value in the area where the target subject is located is determined.
具体地,目标灰度值是指目标主体对应的灰度值。由于主体掩膜图中一般包含两个灰度值,例如0和255,0可以代表背景,255代表主体。电子设备确定目标主体所在区域中满足目标灰度值的目标像素点集合。Specifically, the target gray value refers to the gray value corresponding to the target subject. Since the subject mask image generally contains two gray values, such as 0 and 255, 0 can represent the background and 255 represents the subject. The electronic device determines a set of target pixels meeting the target gray value in the area where the target subject is located.
操作408,将目标像素点集合对应的区域作为目标主体。In operation 408, the area corresponding to the target pixel set is used as the target subject.
具体地,电子设备将目标像素点集合对应的第一预览图像中的区域作为目标主体。例如主体掩膜图中的目标像素点集合为(X1,Y1)、(X2,Y2)…(X100,Y100),那么在第一预览图像中的目标主体对应的像素点坐标也为(X1,Y1)、(X2,Y2)…(X100,Y100)。Specifically, the electronic device uses the area in the first preview image corresponding to the target pixel point set as the target subject. For example, the target pixel point set in the subject mask image is (X1, Y1), (X2, Y2)...(X100, Y100), then the pixel point coordinates corresponding to the target subject in the first preview image are also (X1, Y1), (X2, Y2)... (X100, Y100).
本申请实施例中的对焦方法,对第一预览图像进行主体检测,得到目标主体所在区域,获取各像素点灰度值,确定满足目标灰度值的区域,得到目标主体,能够通过主体掩膜图确定目标主体,从而确定目标主体的质心区域,并以质心区域作为对焦区域进行对焦,能够在人脸过小或者光照过暗时可以迅速找到适当的位置进行自动对焦,提高对焦效率,同 时避免对焦到背景区域,提高拍摄对象的清晰度。In the focusing method in the embodiment of the present application, subject detection is performed on the first preview image to obtain the area where the target subject is located, obtain the gray value of each pixel, determine the area that meets the target gray value, and obtain the target subject, which can be passed through the subject mask The map determines the target subject, thereby determining the center of mass area of the target subject, and using the center of mass area as the focus area for focusing. It can quickly find the appropriate position for autofocus when the face is too small or the light is too dark, which improves the focus efficiency while avoiding Focus on the background area to improve the clarity of the subject.
图5为一个实施例中质心坐标求取的流程示意图。如图5所示,包括以下操作:Fig. 5 is a schematic diagram of the process of obtaining the centroid coordinates in an embodiment. As shown in Figure 5, it includes the following operations:
操作502,获取目标主体所在区域。In operation 502, the area where the target subject is located is obtained.
操作504,遍历该目标主体所在区域中的各个像素点。In operation 504, each pixel in the area where the target subject is traversed.
操作506,记录灰度值为255的像素点坐标。In operation 506, the pixel coordinates with a gray value of 255 are recorded.
操作508,求取灰度值为255的像素点坐标的平均值,得到质心坐标。In operation 508, the average value of the pixel point coordinates with the gray value of 255 is calculated to obtain the centroid coordinates.
本申请实施例中的对焦方法,获取目标主体所在区域,遍历该目标主体所在区域中各个像素点,记录灰度值为255的像素点坐标,并求平均值得到质心坐标,能够得到质心坐标,提高对焦准确性以及拍摄对象的清晰度。The focusing method in the embodiment of the present application obtains the area where the target body is located, traverses each pixel point in the area where the target body is located, records the pixel coordinates with a gray value of 255, and calculates the average value to obtain the centroid coordinates, which can obtain the centroid coordinates. Improve focus accuracy and sharpness of the subject.
在一个实施例中,确定第一预览图像中的目标主体,包括:获取第二预览图像,其中,第二预览图像是第一预览图像的前向帧图像;对第二预览图像进行主体检测,得到参考主体;将参考主体作为第一预览图像中的目标主体。In one embodiment, determining the target subject in the first preview image includes: acquiring a second preview image, where the second preview image is a forward frame image of the first preview image; subject detection is performed on the second preview image, Obtain the reference subject; use the reference subject as the target subject in the first preview image.
其中,第二预览图像是第一预览图像的前向帧图像。前向帧的帧数量小于预设数量。例如,预设数量可以是5帧,那么前向帧图像可以为第一预览图像的前五帧对应的一帧图像,不可以是第一预览图像的前六帧对应的图像。Wherein, the second preview image is a forward frame image of the first preview image. The frame number of the forward frame is less than the preset number. For example, the preset number may be 5 frames, then the forward frame image may be an image corresponding to the first five frames of the first preview image, and may not be an image corresponding to the first six frames of the first preview image.
具体地,电子设备获取第二预览图像,并对第二预览图像进行主体检测,得到参考主体。由于相邻预设帧之间的图像差距较小,因此电子设备可将参考主体作为第一预览图像中的目标主体。Specifically, the electronic device acquires the second preview image, and performs subject detection on the second preview image to obtain the reference subject. Since the image gap between adjacent preset frames is small, the electronic device can use the reference subject as the target subject in the first preview image.
本申请实施例中的对焦方法,取第二预览图像,其中,第二预览图像是第一预览图像的前向帧图像,对第二预览图像进行主体检测,得到参考主体,由于相邻预设帧之间的图像差距较小,将参考主体作为第一预览图像中的目标主体,能提高图像处理效率,也提高对焦的效率。In the focusing method in the embodiment of the present application, a second preview image is taken, where the second preview image is a forward frame image of the first preview image, and subject detection is performed on the second preview image to obtain a reference subject. The image gap between frames is small, and the reference subject is used as the target subject in the first preview image, which can improve the efficiency of image processing and the efficiency of focusing.
在一个实施例中,对第二预览图像进行主体检测,得到参考主体,包括:将第二预览图像输入至主体检测模型中,得到第二预览图像中的参考主体,其中,主体检测模型是预先根据同一场景的可见光图、中心权重图及对应的已标注的主体进行训练得到的模型,或者主体检测模型是预先根据同一场景的可见光图、中心权重图、深度图及对应的已标注的主体进行训练得到的模型。In one embodiment, performing subject detection on the second preview image to obtain the reference subject includes: inputting the second preview image into the subject detection model to obtain the reference subject in the second preview image, wherein the subject detection model is a pre- A model trained based on the visible light map, center weight map, and the corresponding labeled subject of the same scene, or the subject detection model is based on the visible light map, center weight map, depth map, and corresponding labeled subject of the same scene in advance The trained model.
其中,中心权重图是指用于记录可见光图中各个像素点的权重值的图。中心权重图中记录的权重值从中心向四边逐渐减小,即中心权重最大,向四边权重逐渐减小。通过中心权重图表征可见光图的图像中心像素点到图像边缘像素点的权重值逐渐减小。Among them, the central weight map refers to a map used to record the weight value of each pixel in the visible light image. The weight value recorded in the center weight map gradually decreases from the center to the four sides, that is, the center weight is the largest, and the weight gradually decreases toward the four sides. The weight value from the center pixel of the visible light image to the edge pixel of the image is gradually reduced through the center weight map.
主体检测模型是预先采集大量的训练数据,将训练数据输入到包含有初始网络权重的主体检测模型进行训练得到的。每组训练数据包括同一场景对应的可见光图、中心权重图及已标注的主体掩膜图。其中,可见光图和中心权重图作为训练的主体检测模型的输入,已标注的主体掩膜(mask)图作为训练的主体检测模型期望输出得到的真实值(ground truth)。The subject detection model is obtained by pre-collecting a large amount of training data, and inputting the training data into the subject detection model containing the initial network weights for training. Each set of training data includes the visible light map, the center weight map and the labeled subject mask map corresponding to the same scene. Among them, the visible light map and the center weight map are used as the input of the trained subject detection model, and the labeled subject mask map is used as the ground truth that the trained subject detection model expects to output.
具体地,电子设备可将第二预览图像输入至主体检测模型中进行检测,得到第二预览图像中的参考主体。Specifically, the electronic device may input the second preview image into the subject detection model for detection, and obtain the reference subject in the second preview image.
本申请实施例中的对焦方法,将第二预览图像输入至主体检测模型中,得到第二预览图像中的参考主体,能够准确检测到第二预览图像中的目标主体,从而准确检测到第一预览图像中的目标主体,提高对焦的准确性以及拍摄对象的清晰度。In the focusing method in the embodiment of the present application, the second preview image is input into the subject detection model to obtain the reference subject in the second preview image, which can accurately detect the target subject in the second preview image, thereby accurately detecting the first Preview the target subject in the image to improve the accuracy of focus and the clarity of the subject.
在一个实施例中,将第二预览图像输入至主体检测模型中,得到第二预览图像中的参考主体,包括:In one embodiment, inputting the second preview image into the subject detection model to obtain the reference subject in the second preview image includes:
生成与第二预览图像对应的中心权重图;Generating a center weight map corresponding to the second preview image;
将第二预览图像和中心权重图输入到主体检测模型中,得到主体区域置信度图;Input the second preview image and the center weight map into the subject detection model to obtain the subject area confidence map;
对主体区域置信度图进行处理,得到主体掩膜图;Process the confidence map of the subject area to obtain the subject mask map;
根据主体掩膜图确定第二预览图像中的参考主体。Determine the reference subject in the second preview image according to the subject mask map.
具体地,电子设备可根据第二预览图像的大小生成对应的中心权重图。电子设备将第二预览图像和中心权重图输入至主体检测模型中进行检测,得到主体区域置信度图。主体区域置信度图是用于记录主体属于哪种能识别的主体的概率。例如某个像素点属于人的概率是0.6,花的概率是0.2,背景的概率是0.2。Specifically, the electronic device may generate a corresponding center weight map according to the size of the second preview image. The electronic device inputs the second preview image and the center weight map into the subject detection model for detection, and obtains the subject area confidence map. The subject area confidence map is used to record the probability of the subject which can be recognized. For example, the probability that a certain pixel belongs to a person is 0.6, the probability of a flower is 0.2, and the probability of a background is 0.2.
主体区域置信度图中存在一些置信度较低、零散的点,可通过ISP处理器或中央处理器对主体区域置信度图进行过滤处理,得到主体掩膜图。过滤处理可采用配置置信度阈值,电子设备将主体区域置信度图中置信度值低于置信度阈值的像素点过滤。该置信度阈值可采用自适应置信度阈值,也可以采用固定阈值,也可以采用分区域配置对应的阈值。电子设备根据主体掩膜图确定第二预览图像中的参考主体。There are some low-confidence and scattered points in the confidence map of the subject area. The subject area confidence map can be filtered by the ISP processor or the central processing unit to obtain the subject mask map. The filtering process can be configured to configure a confidence threshold, and the electronic device filters pixels whose confidence values are lower than the confidence threshold in the confidence map of the subject area. The confidence threshold can be an adaptive confidence threshold, or a fixed threshold, or a threshold corresponding to a regional configuration. The electronic device determines the reference subject in the second preview image according to the subject mask map.
本实施例中,根据主体掩膜图确定第二预览图像中的参考主体,包括:获取主体掩膜图中各像素点的灰度值,确定主体掩膜图中满足目标灰度值的目标像素点集合,将目标像素点集合对应的区域作为目标主体。In this embodiment, determining the reference subject in the second preview image according to the subject mask image includes: obtaining the gray value of each pixel in the subject mask image, and determining the target pixel in the subject mask image that meets the target gray value Point set, the area corresponding to the target pixel point set is taken as the target subject.
本申请实施例中的对焦方法,生成与第二预览图像对应的中心权重图,将第二预览图像和中心权重图输入到主体检测模型中,得到主体区域置信度图,对主体区域置信度图进行处理,得到主体掩膜图,根据主体掩膜图确定第二预览图像中的参考主体,能够精确地检测到第二预览图像中的目标主体,从而进行质心计算,提高对焦准确性。The focusing method in the embodiment of the present application generates a center weight map corresponding to the second preview image, and inputs the second preview image and the center weight map into the subject detection model to obtain a confidence map of the subject area, and a confidence map of the subject area Processing is performed to obtain the subject mask map, and the reference subject in the second preview image is determined according to the subject mask map, and the target subject in the second preview image can be accurately detected, thereby performing centroid calculation and improving focus accuracy.
在一个实施例中,对主体区域置信度图进行处理,得到主体掩膜图,包括:In one embodiment, processing the confidence map of the subject area to obtain the subject mask map includes:
对该主体区域置信度图进行自适应置信度阈值过滤处理,得到二值化掩膜图;对该二值化掩膜图进行形态学处理和引导滤波处理,得到主体掩膜图。Perform adaptive confidence threshold filtering processing on the subject region confidence map to obtain a binarized mask map; perform morphological processing and guided filtering processing on the binarized mask map to obtain a subject mask map.
具体地,ISP处理器或中央处理器将主体区域置信度图按照自适应置信度阈值过滤处理后,将保留的像素点的置信度值采用1表示,去掉的像素点的置信度值采用0表示,得到二值化掩膜图。Specifically, after the ISP processor or central processing unit filters the confidence map of the subject area according to the adaptive confidence threshold, the confidence value of the retained pixel is represented by 1, and the confidence value of the removed pixel is represented by 0. , Get the binarization mask map.
形态学处理可包括腐蚀和膨胀。可先对二值化掩膜图进行腐蚀操作,再进行膨胀操作,去除噪声;再对形态学处理后的二值化掩膜图进行引导滤波处理,实现边缘滤波操作,得到边缘提取的主体掩膜图。Morphological treatments can include corrosion and expansion. You can perform the erosion operation on the binarized mask first, and then perform the expansion operation to remove the noise; and then conduct the guided filtering process on the binarized mask after morphological processing to realize the edge filtering operation and obtain the main mask for edge extraction. Membrane diagram.
本申请实施例中的对焦方法,对主体区域置信度图进行形态学处理和引导滤波处理可以保证得到的主体掩膜图的噪点少或没有噪点,边缘更加柔和,从而提高质心计算的准确性,进而提高对焦的准确性以及拍摄对象的清晰度。In the focusing method in the embodiment of the present application, morphological processing and guided filtering processing on the confidence map of the subject area can ensure that the resulting subject mask image has less or no noise, and the edges are softer, thereby improving the accuracy of centroid calculation. In turn, the accuracy of focusing and the sharpness of the subject are improved.
在一个实施例中,该对焦方法还包括:获取第一预览图像的后向帧图像;采用目标跟踪算法对第一预览图像中的目标主体进行追踪,得到后向帧图像中的主体;当追踪的后向帧图像的帧数达到预设帧数时,重新确定图像中的主体。In an embodiment, the focusing method further includes: acquiring a backward frame image of the first preview image; using a target tracking algorithm to track the target subject in the first preview image to obtain the subject in the backward frame image; When the number of frames in the backward frame image reaches the preset number of frames, the subject in the image is re-determined.
其中,第一预览图像的后向帧图像可以是第一预览图像的下一帧图像、下两帧图像等等不限于此。目标跟踪算法可以是TLD(Tracking Learning Detection,跟踪 学习 检测)算法、Minimum OutputSum of Squared Error MOSSE(最小均方误差)滤波算法、Struck算法等不限于此。预设帧数可以是在电子设备中存储的帧数阈值。例如预设帧数可为10帧、20帧…等不限于此。Wherein, the backward frame image of the first preview image may be the next frame image, the next two frames of the first preview image, and so on, which is not limited thereto. The target tracking algorithm may be a TLD (Tracking Learning Detection) algorithm, a Minimum OutputSum of Squared Error MOSSE (minimum mean square error) filtering algorithm, and a Struck algorithm, etc. are not limited to this. The preset number of frames may be a threshold value of the number of frames stored in the electronic device. For example, the preset number of frames can be 10 frames, 20 frames, etc., and is not limited thereto.
具体地,电子设备获取第一预览图像的后向帧图像。由于在预设帧数内,目标主体的移动范围不会太大,因此电子设备采用目标跟踪算法对第一预览图像中的目标主体进行追踪,得到后向帧中的主体。当追踪的后向帧图像的帧数达到预设帧数时,目标主体可能与第一预览图像中的目标主体的位置或者类型等不同,电子设备重新确定图像中的主体。Specifically, the electronic device acquires the backward frame image of the first preview image. Since the moving range of the target subject will not be too large within the preset number of frames, the electronic device uses a target tracking algorithm to track the target subject in the first preview image to obtain the subject in the backward frame. When the number of frames of the tracked backward frame image reaches the preset number of frames, the position or type of the target subject may be different from the target subject in the first preview image, and the electronic device re-determines the subject in the image.
本申请实施例中的对焦方法,获取第一预览图像的后向帧图像,采用目标跟踪算法对第一预览图像中的目标主体进行追踪,得到后向帧图像中的主体,当追踪的后向帧图像的帧数达到预设帧数时,重新确定图像中的主体,能够提高主体检测的效率,从而提高对焦效率。In the focusing method in the embodiment of the present application, the backward frame image of the first preview image is obtained, and the target subject in the first preview image is tracked by the target tracking algorithm, and the subject in the backward frame image is obtained. When the number of frames of the frame image reaches the preset number of frames, re-determining the subject in the image can improve the efficiency of subject detection, thereby improving the focusing efficiency.
图6为一个实施例中主体检测的过程示意图。如图6所示,RGB图602中存在一只蝴蝶,将RGB图输入到主体检测模型后得到主体区域置信度图604,然后对主体区域置信度图604进行滤波和二值化得到二值化掩膜图606,再对二值化掩膜图606进行形态学处理和引导滤波实现边缘增强,得到主体掩膜图608。该主体掩膜图608记录了图像识别得到的目标主体及对应的目标主体区域。Fig. 6 is a schematic diagram of a subject detection process in an embodiment. As shown in Figure 6, there is a butterfly in the RGB image 602. After inputting the RGB image into the subject detection model, the subject area confidence map 604 is obtained, and then the subject area confidence map 604 is filtered and binarized to obtain the binarization. For the mask image 606, morphological processing and guided filtering are performed on the binary mask image 606 to realize edge enhancement, and the main body mask image 608 is obtained. The subject mask map 608 records the target subject obtained by image recognition and the corresponding target subject area.
在一个实施例中,确定第一预览图像中的目标主体,包括:当存在至少两个主体时,根据每个主体所属类别的优先级、每个主体在第一预览图像中所占的面积、每个主体在第一预览图像中的区域中的至少一种,确定第一预览图像中的目标主体。In one embodiment, determining the target subject in the first preview image includes: when there are at least two subjects, according to the priority of each subject's category, the area occupied by each subject in the first preview image, At least one of the areas of each subject in the first preview image determines the target subject in the first preview image.
其中,类别是指对主体所分的类,如人像、花、动物、风景等类别。Among them, the category refers to the category of the subject, such as portraits, flowers, animals, landscapes and other categories.
具体地,当存在多个主体时,获取每个主体所属类别的优先级,选取优先级最高或次高等的主体作为目标主体。例如,优先级为人脸>动物>花,第一预览图像中同时包含人脸、动物和花,那么电子设备确定人脸为目标主体。Specifically, when there are multiple subjects, the priority of each subject's category is obtained, and the subject with the highest or the second highest priority is selected as the target subject. For example, if the priority is human face>animal>flower, and the first preview image contains a human face, an animal, and a flower at the same time, the electronic device determines that the human face is the target subject.
当存在多个主体时,获取每个主体在图像中所占的面积,选取在可见光图中所占面积最大的主体作为目标主体。When there are multiple subjects, the area occupied by each subject in the image is obtained, and the subject with the largest area in the visible light image is selected as the target subject.
当存在多个主体时,获取每个主体在图像中的位置,选取主体在图像的位置与该图像的中心点之间的距离最小的主体为目标主体。例如,花在图像中的中心点,人脸在中心点的另一侧,那么电子设备确定花为目标主体。When there are multiple subjects, the position of each subject in the image is obtained, and the subject with the smallest distance between the position of the subject in the image and the center point of the image is selected as the target subject. For example, if the flower is at the center of the image and the face is on the other side of the center, the electronic device determines that the flower is the target subject.
当存在多个主体所属类别的优先级相同且最高时,获取该多个主体在图像中所占的面积,选取在图像中所占面积最大的主体作为目标主体。例如,第一预览图像中存在两张人脸,那么电子设备选取所占面积最大的人脸作为目标主体并计算得到质心。When there are multiple subjects with the same priority and the highest category, the area occupied by the multiple subjects in the image is obtained, and the subject with the largest area in the image is selected as the target subject. For example, if there are two human faces in the first preview image, the electronic device selects the human face with the largest area as the target subject and calculates the centroid.
当存在多个主体所属类别的优先级相同且最高时,获取该优先级相同且最高的多个主体中每个主体在图像中的位置,选取主体在图像中的位置与该图像的中心点之间的距离最小的主体为目标主体。When there are multiple subjects with the same priority and the highest priority, the position of each subject in the image of the multiple subjects with the same priority and the highest is obtained, and the position of the subject in the image is selected from the center point of the image. The subject with the smallest distance between them is the target subject.
当存在多个主体所属类别的优先级相同且最高,获取该优先级相同且最高的多个主体中每个主体在图像中所占的面积,存在多个主体在图像中所占的面积相同时,获取面积相同的多个主体在图像中的位置,选取主体在图像中的位置与该图像的中心点之间的距离最小的主体为目标主体。When there are multiple subjects with the same priority and the highest priority, the area occupied by each subject in the image from the multiple subjects with the same priority and the highest is obtained, and there are multiple subjects occupying the same area in the image , Obtain the positions of multiple subjects with the same area in the image, and select the subject with the smallest distance between the subject's position in the image and the center point of the image as the target subject.
当存在多个主体时,可以获取每个主体所属类别的优先级、每个主体在图像中所占的面积、每个主体在图像中的位置,可以按照优先级、面积和位置三个维度筛选,优先级、面积和位置筛选的顺序可根据需要设定,不作限定。When there are multiple subjects, the priority of each subject's category, the area occupied by each subject in the image, and the position of each subject in the image can be obtained, which can be filtered according to the three dimensions of priority, area and location , The order of priority, area, and location filtering can be set as needed and is not limited.
本实施例中,当存在多个主体时,根据主体所属类别的优先级、主体在图像中面积和主体在图像中位置中的一种或至少两种进行筛选确定目标主体,可以准确确定目标主体。In this embodiment, when there are multiple subjects, one or at least two of the priority of the subject's category, the subject's area in the image, and the subject's position in the image are screened to determine the target subject, and the target subject can be accurately determined. .
本申请实施例中的对焦方法,当存在至少两个主体时,根据每个主体所属类别的优先级、每个主体在第一预览图像中所占的面积、每个主体在第一预览图像中的区域中的至少一种,确定第一预览图像中的目标主体,能够在存在多个主体的情况下确定目标主体,提高主体检测的准确性,从而提高对焦准确性。In the focusing method in the embodiment of the present application, when there are at least two subjects, according to the priority of each subject's category, the area occupied by each subject in the first preview image, and the location of each subject in the first preview image Determine the target subject in the first preview image, which can determine the target subject when there are multiple subjects, improve the accuracy of subject detection, and thereby improve the accuracy of focusing.
在一个实施例中,该对焦方法还包括:当满足人脸面积大于人脸面积阈值且第一预览图像的亮度大于亮度阈值时,按照预设对焦区域进行自动对焦。In an embodiment, the focusing method further includes: when it is satisfied that the face area is greater than the threshold value of the face area and the brightness of the first preview image is greater than the brightness threshold, performing automatic focusing according to the preset focus area.
其中,预设对焦区域可以是电子设备设置的任何一个对焦区域,例如可以是图像的中心区域。The preset focus area may be any focus area set by the electronic device, for example, it may be the center area of the image.
具体地,当满足人脸面积大于人脸面积阈值且第一预览图像的亮度大于亮度阈值时,说明拍摄场景的情况良好,按照预设对焦区域进行自动对焦。Specifically, when it is satisfied that the face area is greater than the face area threshold and the brightness of the first preview image is greater than the brightness threshold, it indicates that the shooting scene is in good condition, and the autofocus is performed according to the preset focus area.
本申请实施例中的对焦方法,当满足人脸面积大于人脸面积阈值且第一预览图像的亮度大于亮度阈值时,按照预设对焦区域进行自动对焦,不需要计算质心坐标,提高对焦效率。In the focusing method in the embodiment of the present application, when it is satisfied that the face area is greater than the face area threshold and the brightness of the first preview image is greater than the brightness threshold, autofocus is performed according to the preset focus area without calculating the centroid coordinates, which improves the focus efficiency.
在一个实施例中,图7为另一个实施例中对焦方法的流程示意图。如图7所示,一种对焦方法,包括以下操作:In one embodiment, FIG. 7 is a schematic flowchart of a focusing method in another embodiment. As shown in Figure 7, a focusing method includes the following operations:
操作702,获取第二预览图像,其中,第二预览图像是第一预览图像的前向帧图像。Operation 702: Acquire a second preview image, where the second preview image is a forward frame image of the first preview image.
操作704,对第二预览图像进行主体检测,得到参考主体所在区域。In operation 704, subject detection is performed on the second preview image to obtain an area where the reference subject is located.
操作706,获取第一预览图像,将参考主体所在区域作为第一预览图像的目标主体所在区域。Operation 706: Obtain a first preview image, and use the area where the reference subject is located as the area where the target subject of the first preview image is located.
操作708,将目标主体所在区域输入至人脸检测模块,当检测结果出现人脸时,判断人脸面积是否大于人脸面积阈值。In operation 708, the area where the target subject is located is input to the face detection module, and when a face appears in the detection result, it is determined whether the face area is greater than the face area threshold.
操作710,当人脸面积大于面积阈值时,判断第一预览图像的亮度是否大于亮度阈值。In operation 710, when the face area is greater than the area threshold, it is determined whether the brightness of the first preview image is greater than the brightness threshold.
操作712,当满足目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种时,确定目标主体的质心区域。In operation 712, when at least one of the face area corresponding to the target subject is less than or equal to the face area threshold and the brightness of the first preview image is less than or equal to the brightness threshold is satisfied, the centroid region of the target subject is determined.
操作714,根据质心区域进行自动对焦。In operation 714, auto focus is performed according to the center of mass area.
本申请实施例中的对焦方法,获取第一预览图像,确定第一预览图像中的目标主体,当第一预览图像满足目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种时,确定目标主体的质心区域,并以质心区域作为对焦区域进行对焦,能够在人脸过小或者光照过暗时可以迅速找到适当的位置进行自动对焦,提高对焦效率,同时避免对焦到背景区域,提高拍摄对象的清晰度。In the focusing method in the embodiment of the present application, a first preview image is acquired, and the target subject in the first preview image is determined. When the first preview image satisfies the target subject, the face area corresponding to the target subject is less than or equal to the face area threshold, and the first preview image When the brightness of is less than or equal to at least one of the brightness thresholds, determine the center of mass area of the target subject, and use the center of mass area as the focus area for focusing. It can quickly find an appropriate position for autofocus when the face is too small or the light is too dark , Improve the focusing efficiency, while avoiding focusing on the background area, improving the clarity of the subject.
在一个实施例中,一种对焦方法,包括:In one embodiment, a focusing method includes:
操作(a1),获取第二预览图像,其中,第二预览图像是第一预览图像的前向帧图像。Operation (a1) is to obtain a second preview image, where the second preview image is a forward frame image of the first preview image.
操作(a2),生成与第二预览图像对应的中心权重图。In operation (a2), a center weight map corresponding to the second preview image is generated.
操作(a3),将第二预览图像和中心权重图输入到主体检测模型中,得到主体区域置信度图。Operation (a3), input the second preview image and the center weight map into the subject detection model to obtain the subject region confidence map.
操作(a4),对主体区域置信度图进行自适应置信度阈值过滤处理,得到二值化掩膜图。Operation (a4) is to perform adaptive confidence threshold filtering processing on the confidence map of the main body area to obtain a binarized mask map.
操作(a5),对二值化掩膜图进行形态学处理和引导滤波处理,得到主体掩膜图。In operation (a5), morphological processing and guided filtering processing are performed on the binarized mask image to obtain the main body mask image.
操作(a6),获取参考主体所在区域中各像素点的灰度值。Operation (a6), obtain the gray value of each pixel in the area where the reference subject is located.
操作(a7),确定参考主体所在区域中满足目标灰度值的参考像素点集合。Operation (a7) is to determine the set of reference pixels meeting the target gray value in the area where the reference subject is located.
操作(a8),将参考像素点集合对应的区域作为参考主体。In operation (a8), the area corresponding to the set of reference pixels is used as the reference subject.
操作(a9),将参考主体作为第一预览图像中的目标主体。Operation (a9), use the reference subject as the target subject in the first preview image.
操作(a10),当第一预览图像满足预设条件时,获取目标主体对应的像素点的集合,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种。Operation (a10), when the first preview image meets a preset condition, obtain a set of pixels corresponding to the target subject, where the preset condition includes that the face area corresponding to the target subject is less than or equal to the face area threshold, and the first preview The brightness of the image is less than or equal to at least one of the brightness thresholds.
操作(a11),获取目标主体所对应的像素点的集合中各个像素点的坐标。Operation (a11) is to obtain the coordinates of each pixel in the set of pixel points corresponding to the target subject.
操作(a12),根据各个像素点的坐标,得到目标主体的质心坐标。Operation (a12), according to the coordinates of each pixel point, obtain the center of mass coordinates of the target body.
操作(a13),确定质心坐标所在区域。Operate (a13) to determine the area where the centroid coordinates are located.
操作(a14),将质心坐标所在区域作为目标主体的质心区域。Operation (a14), use the area where the center of mass coordinates are located as the center of mass area of the target subject.
操作(a15),当满足人脸面积大于人脸面积阈值且第一预览图像的亮度大于亮度阈值时,按照预设对焦区域进行自动对焦。Operation (a15), when it is satisfied that the face area is greater than the face area threshold and the brightness of the first preview image is greater than the brightness threshold, autofocus is performed according to the preset focus area.
操作(a16),根据质心区域进行对焦。Operate (a16) to focus based on the center of mass area.
操作(a17),当存在至少两个主体时,根据每个主体所属类别的优先级、每个主体在第一预览图像中所占的面积、每个主体在第一预览图像中的区域中的至少一种,确定第一预览图像中的目标主体。Operation (a17), when there are at least two subjects, according to the priority of each subject's category, the area occupied by each subject in the first preview image, and the area of each subject in the first preview image At least one of determining the target subject in the first preview image.
操作(a18),获取第一预览图像的后向帧图像。In operation (a18), the backward frame image of the first preview image is acquired.
操作(a19),采用目标跟踪算法对第一预览图像中的目标主体进行追踪,得到后向帧图像中的主体。Operation (a19) is to use the target tracking algorithm to track the target subject in the first preview image to obtain the subject in the backward frame image.
操作(a20),当追踪的后向帧图像的帧数达到预设帧数时,重新确定图像中的主体。Operation (a20), when the number of frames of the tracked backward frame image reaches the preset number of frames, the subject in the image is re-determined.
本实施例中的对焦方法,获取第一预览图像,确定第一预览图像中的目标主体,当第一预览图像满足目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种时,确定目标主体的质心区域,并以质心区域作为对焦区域进行对焦,能够在人脸过小或者光照过暗时可以迅速找到适当的位置进行自动对焦,提高对焦效率,同时避免对焦到背景区域,提高拍摄对象的清晰度。In the focusing method in this embodiment, a first preview image is acquired, and the target subject in the first preview image is determined. When the first preview image satisfies the target subject's face area less than or equal to the face area threshold, the first preview image When the brightness is less than or equal to at least one of the brightness thresholds, the centroid area of the target subject is determined, and the centroid area is used as the focus area for focusing. It can quickly find an appropriate position for autofocus when the face is too small or the light is too dark. Improve the focusing efficiency, while avoiding focusing on the background area, improving the clarity of the subject.
应该理解的是,虽然图2至7的流程图中的各个操作按照箭头的指示依次显示,但是这些操作并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些操作的执行并没有严格的顺序限制,这些操作可以以其它的顺序执行。而且,图2至7中的至少一部分操作可以包括多个子操作或者多个阶段,这些子操作或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子操作或者阶段的执行顺序也不必然是依次进行,而是可以与其它操作或者其它操作的子操作或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the various operations in the flowcharts of FIGS. 2 to 7 are displayed in sequence as indicated by the arrows, these operations are not necessarily performed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these operations, and these operations can be executed in other orders. Moreover, at least part of the operations in FIGS. 2 to 7 may include multiple sub-operations or multiple stages. These sub-operations or stages are not necessarily executed at the same time, but can be executed at different times. These sub-operations or stages The execution order of is not necessarily performed sequentially, but may be performed alternately or alternately with other operations or at least a part of the sub-operations or stages of other operations.
图8为一个实施例的对焦装置的结构框图。如图8所示,一种对焦装置,包括获取模块802、主体确定模块804、质心确定模块806和对焦模块808,其中:Fig. 8 is a structural block diagram of a focusing device according to an embodiment. As shown in FIG. 8, a focusing device includes an acquiring module 802, a subject determining module 804, a centroid determining module 806, and a focusing module 808, wherein:
获取模块802,用于获取第一预览图像。The obtaining module 802 is used to obtain the first preview image.
主体确定模块804,用于确定第一预览图像中的目标主体。The subject determination module 804 is used to determine the target subject in the first preview image.
质心确定模块806,用于当第一预览图像满足预设条件时,确定目标主体的质心区域,其中,预设条件包括目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种。The centroid determination module 806 is configured to determine the centroid area of the target subject when the first preview image meets preset conditions, where the preset conditions include that the face area corresponding to the target subject is less than or equal to the face area threshold, and the first preview image The brightness of is less than or equal to at least one of the brightness thresholds.
对焦模块808,用于根据质心区域进行对焦。The focusing module 808 is used for focusing according to the center of mass area.
本实施例中的对焦装置,获取第一预览图像,确定第一预览图像中的目标主体,当第一预览图像满足目标主体对应的人脸面积小于或等于人脸面积阈值、第一预览图像的亮度小于或等于亮度阈值中至少一种时,确定目标主体的质心区域,并根据质心区域进行对焦,能够在人脸过小或者光照过暗时可以迅速找到适当的位置进行自动对焦,提高对焦效率,同时避免对焦到背景区域,提高拍摄对象的清晰度。The focusing device in this embodiment acquires the first preview image, and determines the target subject in the first preview image. When the first preview image satisfies the target subject, the face area corresponding to the target subject is less than or equal to the face area threshold and the first preview image When the brightness is less than or equal to at least one of the brightness thresholds, determine the center of mass area of the target subject, and focus according to the center of mass area, which can quickly find the appropriate position for autofocus when the face is too small or the light is too dark, and improve the focus efficiency , While avoiding focusing on the background area to improve the clarity of the subject.
在一个实施例中,质心确定模块806用于获取目标主体对应的像素点的集合;获取目标主体所对应的像素点的集合中各个像素点的坐标;根据各个像素点对应的目标像素点的坐标,得到目标主体的质心坐标;确定质心坐标所在区域;将质心坐标所在区域作为目标主体的质心区域。In one embodiment, the centroid determination module 806 is used to obtain a set of pixel points corresponding to the target subject; obtain the coordinates of each pixel in the set of pixel points corresponding to the target subject; according to the coordinates of the target pixel corresponding to each pixel , Get the center of mass coordinates of the target subject; determine the area where the center of mass coordinates are located; take the area where the center of mass coordinates are located as the center of mass area of the target subject.
本申请实施例中的对焦装置,获取目标主体对应的像素点的集合,获取各个像素点的坐标,得到质心坐标,将质心坐标所在区域作为目标主体的质心区域,能够确定对焦区域,提高目标主体拍摄的清晰度。The focusing device in the embodiment of the present application obtains a set of pixel points corresponding to the target subject, obtains the coordinates of each pixel point, and obtains the centroid coordinates, and uses the area where the centroid coordinates are located as the centroid area of the target subject, which can determine the focus area and improve the target subject The clarity of the shot.
在一个实施例中,质心确定模块806用于将各个像素点对应的目标像素点的坐标求加权平均值,得到目标主体的质心坐标。In one embodiment, the centroid determination module 806 is used to calculate the weighted average of the coordinates of the target pixel corresponding to each pixel to obtain the coordinates of the centroid of the target subject.
本申请实施例中的对焦装置,将各个像素点的坐标求加权平均值,得到目标主体的质心坐标,能够获取所有的目标像素点坐标进行计算,提高质心坐标计算的准确性。The focusing device in the embodiment of the present application calculates the weighted average of the coordinates of each pixel point to obtain the centroid coordinates of the target body, and can obtain all the target pixel coordinates for calculation, thereby improving the accuracy of the centroid coordinate calculation.
在一个实施例中,质心确定模块806用于当第一预览图像满足目标主体对应的人脸面积大于人脸面积阈值时,判断第一预览图像的亮度是否大于亮度阈值;当第一预览图像的亮度小于或等于亮度阈值时,确定目标主体的质心区域。In one embodiment, the centroid determination module 806 is configured to determine whether the brightness of the first preview image is greater than the brightness threshold when the first preview image satisfies that the face area corresponding to the target subject is greater than the threshold value of the face area; When the brightness is less than or equal to the brightness threshold, the center of mass area of the target subject is determined.
本申请实施例中的对焦装置,通过人脸面积是否大于人脸面积阈值以及第一预览图像的亮度是否大于亮度阈值两个条件判断是否需要确定目标主体的质心区域,能够在人脸面积大于人脸面积阈值且光线过暗时迅速找到适当的位置进行自动对焦,提高对焦效率,同 时避免对焦到背景区域,提高对焦准确性以及拍摄对象的清晰度。The focusing device in the embodiment of the present application judges whether it is necessary to determine the centroid area of the target subject based on the two conditions of whether the face area is greater than the face area threshold and whether the brightness of the first preview image is greater than the brightness threshold. When the face area threshold is too dark and the light is too dark, it quickly finds the appropriate position for autofocus, which improves the focusing efficiency, while avoiding focusing on the background area, improving the focusing accuracy and the sharpness of the subject.
在一个实施例中,主体确定模块804用于对第一预览图像进行主体检测,得到目标主体所在区域,其中,目标主体所在区域对应的图像为主体掩膜图;获取目标主体所在区域中各像素点的灰度值;确定目标主体所在区域中满足目标灰度值的目标像素点集合;将目标像素点集合对应的区域作为目标主体。In one embodiment, the subject determination module 804 is used to perform subject detection on the first preview image to obtain the area where the target subject is located, where the image corresponding to the area where the target subject is located is the subject mask; to obtain each pixel in the area where the target subject is located The gray value of the point; determine the target pixel point set that meets the target gray value in the area where the target subject is located; take the area corresponding to the target pixel point set as the target subject.
本申请实施例中的对焦装置,对第一预览图像进行主体检测,得到目标主体所在区域,获取各像素点灰度值,确定满足目标灰度值的区域,得到目标主体,能够通过主体掩膜图确定目标主体,从而确定目标主体的质心区域,并以质心区域作为对焦区域进行对焦,能够在人脸过小或者光照过暗时可以迅速找到适当的位置进行自动对焦,提高对焦效率,同时避免对焦到背景区域,提高拍摄对象的清晰度。The focusing device in the embodiment of the present application performs subject detection on the first preview image to obtain the area where the target subject is located, obtains the gray value of each pixel, determines the area that meets the target gray value, and obtains the target subject, which can be passed through the subject mask The map determines the target subject, thereby determining the center of mass area of the target subject, and using the center of mass area as the focus area for focusing. It can quickly find the appropriate position for autofocus when the face is too small or the light is too dark, which improves the focusing efficiency while avoiding Focus on the background area to improve the clarity of the subject.
在一个实施例中,获取模块802用于获取第二预览图像,其中,第二预览图像是第一预览图像的前向帧图像。主体确定模块804用于对第二预览图像进行主体检测,得到参考主体;将参考主体作为第一预览图像中的目标主体。In one embodiment, the acquiring module 802 is configured to acquire a second preview image, where the second preview image is a forward frame image of the first preview image. The subject determination module 804 is configured to perform subject detection on the second preview image to obtain a reference subject; and use the reference subject as the target subject in the first preview image.
本申请实施例中的对焦装置,取第二预览图像,其中,第二预览图像是第一预览图像的前向帧图像,对第二预览图像进行主体检测,得到参考主体,由于相邻预设帧之间的图像差距较小,将参考主体作为第一预览图像中的目标主体,能提高图像处理效率,也提高对焦的效率。The focusing device in the embodiment of the present application takes a second preview image, where the second preview image is a forward frame image of the first preview image, and subject detection is performed on the second preview image to obtain a reference subject. The image gap between frames is small, and the reference subject is used as the target subject in the first preview image, which can improve the efficiency of image processing and the efficiency of focusing.
在一个实施例中,主体确定模块804用于将第二预览图像输入至主体检测模型中,得到第二预览图像中的参考主体,其中,主体检测模型是预先根据同一场景的可见光图、中心权重图及对应的已标注的主体进行训练得到的模型,或者主体检测模型是预先根据同一场景的可见光图、中心权重图、深度图及对应的已标注的主体进行训练得到的模型。In one embodiment, the subject determination module 804 is used to input the second preview image into the subject detection model to obtain the reference subject in the second preview image, where the subject detection model is based on the visible light image and center weight of the same scene in advance. The model obtained by training the image and the corresponding labeled subject, or the subject detection model is a model obtained by training in advance according to the visible light map, the center weight map, the depth map and the corresponding labeled subject of the same scene.
本申请实施例中的对焦装置,将第二预览图像输入至主体检测模型中,得到第二预览图像中的参考主体,能够准确检测到第二预览图像中的目标主体,从而准确检测到第一预览图像中的目标主体,提高对焦的准确性以及拍摄对象的清晰度。The focusing device in the embodiment of the present application inputs the second preview image into the subject detection model to obtain the reference subject in the second preview image, and can accurately detect the target subject in the second preview image, thereby accurately detecting the first Preview the target subject in the image to improve the accuracy of focus and the clarity of the subject.
在一个实施例中,主体确定模块804用于生成与第二预览图像对应的中心权重图;将第二预览图像和中心权重图输入到主体检测模型中,得到主体区域置信度图;对主体区域置信度图进行处理,得到主体掩膜图;根据主体掩膜图确定第二预览图像中的参考主体。In one embodiment, the subject determination module 804 is used to generate a center weight map corresponding to the second preview image; input the second preview image and the center weight map into the subject detection model to obtain a confidence map of the subject area; The confidence map is processed to obtain the subject mask map; the reference subject in the second preview image is determined according to the subject mask map.
本申请实施例中的对焦装置,生成与第二预览图像对应的中心权重图,将第二预览图像和中心权重图输入到主体检测模型中,得到主体区域置信度图,对主体区域置信度图进行处理,得到主体掩膜图,根据主体掩膜图确定第二预览图像中的参考主体,能够精确地检测到第二预览图像中的目标主体,从而进行质心计算,提高对焦准确性。The focusing device in the embodiment of the present application generates a center weight map corresponding to the second preview image, and inputs the second preview image and the center weight map into the subject detection model to obtain a confidence map of the subject area and a confidence map of the subject area Processing is performed to obtain the subject mask map, and the reference subject in the second preview image is determined according to the subject mask map, and the target subject in the second preview image can be accurately detected, thereby performing centroid calculation and improving focus accuracy.
在一个实施例中,主体确定模块804用于对该主体区域置信度图进行自适应置信度阈值过滤处理,得到二值化掩膜图;对该二值化掩膜图进行形态学处理和引导滤波处理,得到主体掩膜图。In one embodiment, the subject determination module 804 is configured to perform adaptive confidence threshold filtering processing on the subject region confidence map to obtain a binarized mask map; perform morphological processing and guidance on the binarized mask map Filter processing to obtain the main body mask map.
本申请实施例中的对焦装置,对主体区域置信度图进行形态学处理和引导滤波处理可以保证得到的主体掩膜图的噪点少或没有噪点,边缘更加柔和,从而提高质心计算的准确性,进而提高对焦的准确性以及拍摄对象的清晰度。The focusing device in the embodiment of the present application performs morphological processing and guided filtering processing on the confidence map of the subject area to ensure that the resulting subject mask image has less or no noise, and the edges are softer, thereby improving the accuracy of centroid calculation. In turn, the accuracy of focusing and the sharpness of the subject are improved.
在一个实施例中,获取模块802用于获取第一预览图像的后向帧图像。该对焦装置还包括追踪模块。追踪模块用于采用目标跟踪算法对第一预览图像中的目标主体进行追踪,得到后向帧图像中的主体;当追踪的后向帧图像的帧数达到预设帧数时,重新确定图像中的主体。In one embodiment, the acquiring module 802 is used to acquire the backward frame image of the first preview image. The focusing device also includes a tracking module. The tracking module is used to use the target tracking algorithm to track the target subject in the first preview image to obtain the subject in the backward frame image; when the number of frames of the tracked backward frame image reaches the preset frame number, re-determine the image Main body.
本申请实施例中的对焦装置,获取第一预览图像的后向帧图像,采用目标跟踪算法对第一预览图像中的目标主体进行追踪,得到后向帧图像中的主体,当追踪的后向帧图像的帧数达到预设帧数时,重新确定图像中的主体,能够提高主体检测的效率,从而提高对焦效率。The focusing device in the embodiment of the present application obtains the backward frame image of the first preview image, and uses the target tracking algorithm to track the target subject in the first preview image to obtain the subject in the backward frame image. When the number of frames of the frame image reaches the preset number of frames, re-determining the subject in the image can improve the efficiency of subject detection, thereby improving the focusing efficiency.
在一个实施例中,主体确定模块804用于当存在至少两个主体时,根据每个主体所属类别的优先级、每个主体在第一预览图像中所占的面积、每个主体在第一预览图像中的区域中的至少一种,确定第一预览图像中的目标主体。In one embodiment, the subject determination module 804 is configured to, when there are at least two subjects, according to the priority of each subject's category, the area occupied by each subject in the first preview image, and the location of each subject in the first preview image. At least one of the areas in the preview image is used to determine the target subject in the first preview image.
本申请实施例中的对焦装置,当存在至少两个主体时,根据每个主体所属类别的优先级、每个主体在第一预览图像中所占的面积、每个主体在第一预览图像中的区域中的至少一种,确定第一预览图像中的目标主体,能够在存在多个主体的情况下确定目标主体,提高主体检测的准确性,从而提高对焦准确性。In the focusing device in the embodiment of the present application, when there are at least two subjects, it is based on the priority of each subject's category, the area occupied by each subject in the first preview image, and the location of each subject in the first preview image. Determine the target subject in the first preview image, which can determine the target subject when there are multiple subjects, improve the accuracy of subject detection, and thereby improve the accuracy of focusing.
在一个实施例中,对焦模块808还用于当满足人脸面积大于人脸面积阈值且第一预览图像的亮度大于亮度阈值时,按照预设对焦区域进行自动对焦。In one embodiment, the focusing module 808 is further configured to perform automatic focusing according to the preset focus area when it is satisfied that the face area is greater than the face area threshold and the brightness of the first preview image is greater than the brightness threshold.
本申请实施例中的对焦装置,当满足人脸面积大于人脸面积阈值且第一预览图像的亮度大于亮度阈值时,按照预设对焦区域进行自动对焦,不需要计算质心坐标,提高对焦效率。The focusing device in the embodiment of the present application, when it is satisfied that the face area is greater than the face area threshold and the brightness of the first preview image is greater than the brightness threshold, autofocus is performed according to the preset focus area without calculating the centroid coordinates, which improves focus efficiency.
上述对焦装置中各个模块的划分仅用于举例说明,在其他实施例中,可将对焦装置按照需要划分为不同的模块,以完成上述对焦装置的全部或部分功能。The division of the modules in the above-mentioned focusing device is only used for illustration. In other embodiments, the focusing device can be divided into different modules as required to complete all or part of the functions of the above-mentioned focusing device.
关于对焦装置的具体限定可以参见上文中对于对焦方法的限定,在此不再赘述。上述对焦装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the focusing device, please refer to the above limitation of the focusing method, which will not be repeated here. Each module in the above-mentioned focusing device can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned modules may be embedded in the form of hardware or independent of the processor in the computer equipment, or may be stored in the memory of the computer equipment in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned modules.
图9为一个实施例中电子设备的内部结构示意图。如图9所示,该电子设备包括通过系统总线连接的处理器和存储器。其中,该处理器用于提供计算和控制能力,支撑整个电子设备的运行。存储器可包括非易失性存储介质及内存储器。非易失性存储介质存储有操作系统和计算机程序。该计算机程序可被处理器所执行,以用于实现以下各个实施例所提供的一种对焦方法。内存储器为非易失性存储介质中的操作系统计算机程序提供高速缓存的运行环境。该电子设备可以是手机、平板电脑或者个人数字助理或穿戴式设备等。Fig. 9 is a schematic diagram of the internal structure of an electronic device in an embodiment. As shown in FIG. 9, the electronic device includes a processor and a memory connected through a system bus. Among them, the processor is used to provide computing and control capabilities to support the operation of the entire electronic device. The memory may include a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and a computer program. The computer program can be executed by a processor to implement a focusing method provided in the following embodiments. The internal memory provides a cached operating environment for the operating system computer program in the non-volatile storage medium. The electronic device can be a mobile phone, a tablet computer, or a personal digital assistant or a wearable device.
本申请实施例中提供的对焦装置中的各个模块的实现可为计算机程序的形式。该计算机程序可在终端或服务器上运行。该计算机程序构成的程序模块可存储在终端或服务器的存储器上。该计算机程序被处理器执行时,实现本申请实施例中所描述方法的操作。The implementation of each module in the focusing device provided in the embodiment of the present application may be in the form of a computer program. The computer program can be run on a terminal or a server. The program module composed of the computer program can be stored in the memory of the terminal or the server. When the computer program is executed by the processor, the operation of the method described in the embodiment of the present application is realized.
本申请实施例还提供了一种计算机可读存储介质。一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行对焦方法的操作。The embodiment of the present application also provides a computer-readable storage medium. One or more non-volatile computer-readable storage media containing computer-executable instructions, when the computer-executable instructions are executed by one or more processors, cause the processors to perform the operations of the focusing method.
一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行对焦方法。A computer program product containing instructions that, when run on a computer, causes the computer to execute the focusing method.
本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM),它用作外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDR SDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)。Any reference to memory, storage, database, or other media used in this application may include non-volatile and/or volatile memory. Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which acts as external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation manners of the present application, and their description is relatively specific and detailed, but they should not be understood as a limitation to the scope of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of this application, several modifications and improvements can be made, and these all fall within the protection scope of this application. Therefore, the scope of protection of the patent of this application shall be subject to the appended claims.

Claims (20)

  1. 一种对焦方法,其特征在于,包括:A focusing method, characterized in that it comprises:
    获取第一预览图像;Obtain the first preview image;
    确定所述第一预览图像中的目标主体;Determining the target subject in the first preview image;
    当所述第一预览图像满足预设条件时,确定所述目标主体的质心区域,其中,所述预设条件包括所述目标主体对应的人脸面积小于或等于人脸面积阈值、所述第一预览图像的亮度小于或等于亮度阈值中至少一种;及When the first preview image satisfies a preset condition, the centroid area of the target subject is determined, where the preset condition includes that the face area corresponding to the target subject is less than or equal to a face area threshold, and the first The brightness of a preview image is less than or equal to at least one of the brightness thresholds; and
    根据所述质心区域进行对焦。Focusing is performed according to the center of mass area.
  2. 根据权利要求1所述的方法,其特征在于,所述确定所述目标主体的质心区域,包括:The method according to claim 1, wherein the determining the center of mass region of the target subject comprises:
    获取所述目标主体对应的像素点的集合;Acquiring a set of pixels corresponding to the target subject;
    获取所述目标主体所对应的像素点的集合中各个像素点的坐标;Acquiring the coordinates of each pixel in the set of pixel points corresponding to the target subject;
    根据所述各个像素点的坐标,得到所述目标主体的质心坐标;Obtain the centroid coordinates of the target subject according to the coordinates of the respective pixel points;
    确定所述质心坐标所在区域;Determine the area where the centroid coordinates are located;
    将所述质心坐标所在区域作为所述目标主体的质心区域。The area where the centroid coordinates are located is taken as the centroid area of the target subject.
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述各个像素点的坐标,得到所述目标主体的质心坐标,包括:The method according to claim 2, wherein the obtaining the coordinates of the center of mass of the target subject according to the coordinates of the respective pixel points comprises:
    将所述各个像素点的坐标求加权平均值,得到所述目标主体的质心坐标。A weighted average of the coordinates of each pixel point is calculated to obtain the centroid coordinates of the target body.
  4. 根据权利要求1所述的方法,其特征在于,所述当所述第一预览图像满足预设条件时,确定所述目标主体的质心区域,其中,所述预设条件包括所述目标主体对应的人脸面积小于或等于人脸面积阈值、所述第一预览图像的亮度小于或等于亮度阈值中至少一种,包括:The method according to claim 1, wherein when the first preview image satisfies a preset condition, the center of mass region of the target subject is determined, wherein the preset condition includes that the target subject corresponds to At least one of the face area of is less than or equal to the face area threshold, and the brightness of the first preview image is less than or equal to the brightness threshold, including:
    当所述第一预览图像满足所述目标主体对应的人脸面积大于所述人脸面积阈值时,判断所述第一预览图像的亮度是否大于所述亮度阈值;When the first preview image satisfies that the face area corresponding to the target subject is greater than the face area threshold, judging whether the brightness of the first preview image is greater than the brightness threshold;
    当所述第一预览图像的亮度小于或等于所述亮度阈值时,确定所述目标主体的质心区域。When the brightness of the first preview image is less than or equal to the brightness threshold, the center of mass region of the target subject is determined.
  5. 根据权利要求1所述的方法,其特征在于,所述确定所述第一预览图像中的目标主体,包括:The method according to claim 1, wherein the determining the target subject in the first preview image comprises:
    对所述第一预览图像进行主体检测,得到目标主体所在区域,其中,所述目标主体所在区域对应的图像为主体掩膜图;Performing subject detection on the first preview image to obtain the area where the target subject is located, wherein the image corresponding to the area where the target subject is located is a subject mask map;
    获取目标主体所在区域中各像素点的灰度值;Obtain the gray value of each pixel in the area where the target subject is located;
    确定所述目标主体所在区域中满足目标灰度值的目标像素点集合;Determine a set of target pixels that meet the target gray value in the area where the target subject is located;
    将所述目标像素点集合对应的区域作为目标主体。The area corresponding to the set of target pixel points is taken as the target subject.
  6. 根据权利要求1所述的方法,其特征在于,所述确定所述第一预览图像中的目标主体,包括:The method according to claim 1, wherein the determining the target subject in the first preview image comprises:
    获取第二预览图像,其中,所述第二预览图像是所述第一预览图像的前向帧图像;Acquiring a second preview image, where the second preview image is a forward frame image of the first preview image;
    对所述第二预览图像进行主体检测,得到参考主体;Subject detection on the second preview image to obtain a reference subject;
    将所述参考主体作为第一预览图像中的目标主体。The reference subject is used as the target subject in the first preview image.
  7. 根据权利要求6所述的方法,其特征在于,所述对所述第二预览图像进行主体检测,得到参考主体,包括:The method according to claim 6, wherein said performing subject detection on the second preview image to obtain a reference subject comprises:
    将所述第二预览图像输入至主体检测模型中,得到所述第二预览图像中的参考主体,其中,所述主体检测模型是预先根据同一场景的可见光图、中心权重图及对应的已标注的主体进行训练得到的模型,或者所述主体检测模型是预先根据同一场景的可见光图、中心权重图、深度图及对应的已标注的主体进行训练得到的模型。The second preview image is input into the subject detection model to obtain the reference subject in the second preview image, wherein the subject detection model is based on the visible light map, the center weight map and the corresponding labeled map of the same scene in advance A model obtained by training the subject, or the subject detection model is a model obtained by training in advance according to the visible light map, the center weight map, the depth map and the corresponding labeled subject of the same scene.
  8. 根据权利要求7所述的方法,其特征在于,所述将所述第二预览图像输入至主体检测模型中,得到所述第二预览图像中的参考主体,包括:8. The method according to claim 7, wherein said inputting said second preview image into a subject detection model to obtain a reference subject in said second preview image comprises:
    生成与所述第二预览图像对应的中心权重图;Generating a center weight map corresponding to the second preview image;
    将所述第二预览图像和所述中心权重图输入到主体检测模型中,得到主体区域置信度图;Inputting the second preview image and the center weight map into the subject detection model to obtain the subject area confidence map;
    对所述主体区域置信度图进行处理,得到主体掩膜图;Processing the confidence map of the subject area to obtain a subject mask map;
    根据所述主体掩膜图确定所述第二预览图像中的参考主体。The reference subject in the second preview image is determined according to the subject mask map.
  9. 根据权利要求8所述的方法,其特征在于,所述对所述主体区域置信度图进行处理,得到主体掩膜图,包括:The method according to claim 8, wherein the processing the confidence map of the subject area to obtain a subject mask map comprises:
    对所述主体区域置信度图进行自适应置信度阈值过滤处理,得到二值化掩膜图;Performing adaptive confidence threshold filtering processing on the confidence map of the main body area to obtain a binarized mask map;
    对所述二值化掩膜图进行形态学处理和引导滤波处理,得到主体掩膜图。Morphological processing and guided filtering processing are performed on the binarized mask image to obtain a main body mask image.
  10. 根据权利要求1至9任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 9, wherein the method further comprises:
    获取所述第一预览图像的后向帧图像;Acquiring a backward frame image of the first preview image;
    采用目标跟踪算法对所述第一预览图像中的目标主体进行追踪,得到后向帧图像中的主体;Using a target tracking algorithm to track the target subject in the first preview image to obtain the subject in the backward frame image;
    当追踪的后向帧图像的帧数达到预设帧数时,重新确定图像中的主体。When the number of frames of the tracked backward frame image reaches the preset number of frames, the subject in the image is re-determined.
  11. 根据权利要求1至9任一项所述的方法,其特征在于,所述确定所述第一预览图像中的目标主体,包括:The method according to any one of claims 1 to 9, wherein the determining the target subject in the first preview image comprises:
    当存在至少两个主体时,根据每个主体所属类别的优先级、每个主体在所述第一预览图像中所占的面积、每个主体在所述第一预览图像中的区域中的至少一种,确定所述第一预览图像中的目标主体。When there are at least two subjects, according to the priority of each subject's category, the area occupied by each subject in the first preview image, and at least the area of each subject in the first preview image One is to determine the target subject in the first preview image.
  12. 根据权利要求1至9任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 9, wherein the method further comprises:
    当满足所述人脸面积大于人脸面积阈值且所述第一预览图像的亮度大于所述亮度阈值时,按照预设对焦区域进行自动对焦。When it is satisfied that the face area is greater than the face area threshold and the brightness of the first preview image is greater than the brightness threshold, autofocus is performed according to the preset focus area.
  13. 一种对焦装置,其特征在于,包括:A focusing device is characterized in that it comprises:
    获取模块,用于获取第一预览图像;An obtaining module for obtaining the first preview image;
    主体确定模块,用于确定所述第一预览图像中的目标主体;A subject determination module, configured to determine the target subject in the first preview image;
    质心区域确定模块,用于当所述第一预览图像满足预设条件时,确定所述目标主体的质心区域,其中,所述预设条件包括所述目标主体对应的人脸面积小于或等于人脸面积阈值、所述第一预览图像的亮度小于或等于亮度阈值中至少一种;The centroid region determining module is configured to determine the centroid region of the target subject when the first preview image meets a preset condition, wherein the preset condition includes that the face area corresponding to the target subject is less than or equal to that of a person At least one of the face area threshold and the brightness of the first preview image is less than or equal to the brightness threshold;
    对焦模块,用于根据所述质心区域进行对焦。The focusing module is used for focusing according to the center of mass region.
  14. 根据权利要求13所述的装置,其特征在于,所述质心确定模块用于获取所述目标主体对应的像素点的集合;The device according to claim 13, wherein the centroid determining module is used to obtain a set of pixels corresponding to the target subject;
    获取所述目标主体所对应的像素点的集合中各个像素点的坐标;Acquiring the coordinates of each pixel in the set of pixel points corresponding to the target subject;
    根据所述各个像素点的坐标,得到所述目标主体的质心坐标;Obtain the centroid coordinates of the target subject according to the coordinates of the respective pixel points;
    确定所述质心坐标所在区域;Determine the area where the centroid coordinates are located;
    将所述质心坐标所在区域作为所述目标主体的质心区域。The area where the centroid coordinates are located is taken as the centroid area of the target subject.
  15. 根据权利要求14所述的装置,其特征在于,所述质心确定模块用于将所述各个像素点的坐标求加权平均值,得到所述目标主体的质心坐标。The device according to claim 14, wherein the centroid determination module is configured to calculate a weighted average of the coordinates of the respective pixel points to obtain the centroid coordinates of the target subject.
  16. 根据权利要求13所述的装置,其特征在于,所述质心确定模块用于当所述第一预览图像满足所述目标主体对应的人脸面积大于所述人脸面积阈值时,判断所述第一预览图像的亮度是否大于所述亮度阈值;The device according to claim 13, wherein the centroid determining module is configured to determine the first preview image when the face area corresponding to the target subject is greater than the face area threshold value. Whether the brightness of a preview image is greater than the brightness threshold;
    当所述第一预览图像的亮度小于或等于所述亮度阈值时,确定所述目标主体的质心区域。When the brightness of the first preview image is less than or equal to the brightness threshold, the center of mass region of the target subject is determined.
  17. 根据权利要求13所述的装置,其特征在于,所述主体确定模块用于对所述第一 预览图像进行主体检测,得到目标主体所在区域,其中,所述目标主体所在区域对应的图像为主体掩膜图;The device according to claim 13, wherein the subject determination module is configured to perform subject detection on the first preview image to obtain the area where the target subject is located, wherein the image corresponding to the area where the target subject is located is the subject Mask map
    获取目标主体所在区域中各像素点的灰度值;Obtain the gray value of each pixel in the area where the target subject is located;
    确定所述目标主体所在区域中满足目标灰度值的目标像素点集合;Determine a set of target pixels that meet the target gray value in the area where the target subject is located;
    将所述目标像素点集合对应的区域作为目标主体。The area corresponding to the set of target pixel points is taken as the target subject.
  18. 根据权利要求13所述的装置,其特征在于,所述主体确定模块用于获取第二预览图像,其中,所述第二预览图像是所述第一预览图像的前向帧图像;The device according to claim 13, wherein the subject determination module is configured to obtain a second preview image, wherein the second preview image is a forward frame image of the first preview image;
    对所述第二预览图像进行主体检测,得到参考主体;Subject detection on the second preview image to obtain a reference subject;
    将所述参考主体作为第一预览图像中的目标主体。The reference subject is used as the target subject in the first preview image.
  19. 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求1至12中任一项所述的对焦方法的步骤。An electronic device, comprising a memory and a processor, and a computer program is stored in the memory. When the computer program is executed by the processor, the processor executes any one of claims 1 to 12 The steps of the focusing method.
  20. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至12中任一项所述的方法的步骤。A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the method according to any one of claims 1 to 12 when the computer program is executed by a processor.
PCT/CN2020/116481 2019-09-29 2020-09-21 Focusing method and apparatus, electronic device, and computer readable storage medium WO2021057652A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910931431.2 2019-09-29
CN201910931431.2A CN110536068B (en) 2019-09-29 2019-09-29 Focusing method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
WO2021057652A1 true WO2021057652A1 (en) 2021-04-01

Family

ID=68670696

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/116481 WO2021057652A1 (en) 2019-09-29 2020-09-21 Focusing method and apparatus, electronic device, and computer readable storage medium

Country Status (2)

Country Link
CN (2) CN110536068B (en)
WO (1) WO2021057652A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113221754A (en) * 2021-05-14 2021-08-06 深圳前海百递网络有限公司 Express waybill image detection method and device, computer equipment and storage medium
CN113610864A (en) * 2021-07-23 2021-11-05 Oppo广东移动通信有限公司 Image processing method, image processing device, electronic equipment and computer readable storage medium
WO2023060057A1 (en) 2021-10-05 2023-04-13 Genentech, Inc. Cyclopentylpyrazole cdk2 inhibitors

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110536068B (en) * 2019-09-29 2021-09-28 Oppo广东移动通信有限公司 Focusing method and device, electronic equipment and computer readable storage medium
CN111768414A (en) * 2020-06-05 2020-10-13 哈尔滨新光光电科技股份有限公司 Photoelectric rapid aiming method and device for laser countermeasure system
CN111881720B (en) * 2020-06-09 2024-01-16 山东大学 Automatic enhancement and expansion method, recognition method and system for data for deep learning
CN113259594A (en) * 2021-06-22 2021-08-13 展讯通信(上海)有限公司 Image processing method and device, computer readable storage medium and terminal
CN114143594A (en) * 2021-12-06 2022-03-04 百度在线网络技术(北京)有限公司 Video picture processing method, device and equipment and readable storage medium
CN114286004A (en) * 2021-12-28 2022-04-05 维沃移动通信有限公司 Focusing method, shooting device, electronic equipment and medium
CN115103107B (en) * 2022-06-01 2023-11-07 上海传英信息技术有限公司 Focusing control method, intelligent terminal and storage medium
CN115174803A (en) * 2022-06-20 2022-10-11 平安银行股份有限公司 Automatic photographing method and related equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5030022B2 (en) * 2007-12-13 2012-09-19 カシオ計算機株式会社 Imaging apparatus and program thereof
CN106101540A (en) * 2016-06-28 2016-11-09 北京旷视科技有限公司 Focusing determines method and device
CN106231189A (en) * 2016-08-02 2016-12-14 乐视控股(北京)有限公司 Take pictures treating method and apparatus
CN110248096A (en) * 2019-06-28 2019-09-17 Oppo广东移动通信有限公司 Focusing method and device, electronic equipment, computer readable storage medium
CN110276767A (en) * 2019-06-28 2019-09-24 Oppo广东移动通信有限公司 Image processing method and device, electronic equipment, computer readable storage medium
CN110536068A (en) * 2019-09-29 2019-12-03 Oppo广东移动通信有限公司 Focusing method and device, electronic equipment, computer readable storage medium
CN111385460A (en) * 2018-12-28 2020-07-07 北京字节跳动网络技术有限公司 Image processing method and device

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107124546B (en) * 2012-05-18 2020-10-16 华为终端有限公司 Method for automatically switching terminal focusing modes and terminal
CN102984454B (en) * 2012-11-15 2015-08-19 广东欧珀移动通信有限公司 A kind of system of automatic adjustment camera focus, method and mobile phone
US9571741B1 (en) * 2015-10-08 2017-02-14 Gopro, Inc. Smart shutter in low light
CN105450932B (en) * 2015-12-31 2018-11-09 华为技术有限公司 Backlight photographic method and device
CN105915782A (en) * 2016-03-29 2016-08-31 维沃移动通信有限公司 Picture obtaining method based on face identification, and mobile terminal
CN106060419B (en) * 2016-06-30 2019-05-17 维沃移动通信有限公司 A kind of photographic method and mobile terminal
CN107360361B (en) * 2017-06-14 2020-07-31 中科创达软件科技(深圳)有限公司 Method and device for shooting people in backlight mode
CN108062525B (en) * 2017-12-14 2021-04-23 中国科学技术大学 Deep learning hand detection method based on hand region prediction
CN107911616A (en) * 2017-12-26 2018-04-13 Tcl移动通信科技(宁波)有限公司 A kind of camera automatic focusing method, storage device and mobile terminal
CN109963072B (en) * 2017-12-26 2021-03-02 Oppo广东移动通信有限公司 Focusing method, focusing device, storage medium and electronic equipment
CN107911618A (en) * 2017-12-27 2018-04-13 上海传英信息技术有限公司 Processing method, terminal and the terminal readable storage medium storing program for executing taken pictures
CN108111768B (en) * 2018-01-31 2020-09-22 Oppo广东移动通信有限公司 Method and device for controlling focusing, electronic equipment and computer readable storage medium
CN108259754B (en) * 2018-03-06 2021-02-02 Oppo广东移动通信有限公司 Image processing method and device, computer readable storage medium and computer device
CN109167921B (en) * 2018-10-18 2020-10-20 北京小米移动软件有限公司 Shooting method, shooting device, shooting terminal and storage medium
CN109858436B (en) * 2019-01-29 2020-11-27 中国科学院自动化研究所 Target class correction method and detection method based on video dynamic foreground mask
CN110149482B (en) * 2019-06-28 2021-02-02 Oppo广东移动通信有限公司 Focusing method, focusing device, electronic equipment and computer readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5030022B2 (en) * 2007-12-13 2012-09-19 カシオ計算機株式会社 Imaging apparatus and program thereof
CN106101540A (en) * 2016-06-28 2016-11-09 北京旷视科技有限公司 Focusing determines method and device
CN106231189A (en) * 2016-08-02 2016-12-14 乐视控股(北京)有限公司 Take pictures treating method and apparatus
CN111385460A (en) * 2018-12-28 2020-07-07 北京字节跳动网络技术有限公司 Image processing method and device
CN110248096A (en) * 2019-06-28 2019-09-17 Oppo广东移动通信有限公司 Focusing method and device, electronic equipment, computer readable storage medium
CN110276767A (en) * 2019-06-28 2019-09-24 Oppo广东移动通信有限公司 Image processing method and device, electronic equipment, computer readable storage medium
CN110536068A (en) * 2019-09-29 2019-12-03 Oppo广东移动通信有限公司 Focusing method and device, electronic equipment, computer readable storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113221754A (en) * 2021-05-14 2021-08-06 深圳前海百递网络有限公司 Express waybill image detection method and device, computer equipment and storage medium
CN113610864A (en) * 2021-07-23 2021-11-05 Oppo广东移动通信有限公司 Image processing method, image processing device, electronic equipment and computer readable storage medium
CN113610864B (en) * 2021-07-23 2024-04-09 Oppo广东移动通信有限公司 Image processing method, device, electronic equipment and computer readable storage medium
WO2023060057A1 (en) 2021-10-05 2023-04-13 Genentech, Inc. Cyclopentylpyrazole cdk2 inhibitors

Also Published As

Publication number Publication date
CN113766125B (en) 2022-10-25
CN110536068A (en) 2019-12-03
CN113766125A (en) 2021-12-07
CN110536068B (en) 2021-09-28

Similar Documents

Publication Publication Date Title
WO2021057652A1 (en) Focusing method and apparatus, electronic device, and computer readable storage medium
CN110149482B (en) Focusing method, focusing device, electronic equipment and computer readable storage medium
CN110248096B (en) Focusing method and device, electronic equipment and computer readable storage medium
US11457138B2 (en) Method and device for image processing, method for training object detection model
WO2019105154A1 (en) Image processing method, apparatus and device
US20220166930A1 (en) Method and device for focusing on target subject, and electronic device
WO2019085792A1 (en) Image processing method and device, readable storage medium and electronic device
US20210014411A1 (en) Method for image processing, electronic device, and computer readable storage medium
EP3480784B1 (en) Image processing method, and device
WO2020259474A1 (en) Focus tracking method and apparatus, terminal device, and computer-readable storage medium
CN108846807B (en) Light effect processing method and device, terminal and computer-readable storage medium
CN110248101B (en) Focusing method and device, electronic equipment and computer readable storage medium
US20220222830A1 (en) Subject detecting method and device, electronic device, and non-transitory computer-readable storage medium
CN108717530B (en) Image processing method, image processing device, computer-readable storage medium and electronic equipment
CN110191287B (en) Focusing method and device, electronic equipment and computer readable storage medium
CN110349163B (en) Image processing method and device, electronic equipment and computer readable storage medium
CN110881103B (en) Focusing control method and device, electronic equipment and computer readable storage medium
CN110490196B (en) Subject detection method and apparatus, electronic device, and computer-readable storage medium
US11977319B2 (en) Saliency based capture or image processing
CN113313626A (en) Image processing method, image processing device, electronic equipment and storage medium
CN112866553B (en) Focusing method and device, electronic equipment and computer readable storage medium
CN110365897B (en) Image correction method and device, electronic equipment and computer readable storage medium
CN110650288B (en) Focusing control method and device, electronic equipment and computer readable storage medium
CN110689007B (en) Subject recognition method and device, electronic equipment and computer-readable storage medium
CN110399823B (en) Subject tracking method and apparatus, electronic device, and computer-readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20867177

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20867177

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 20867177

Country of ref document: EP

Kind code of ref document: A1