[go: up one dir, main page]

CN112802116B - Image processing method, camera calibration method, device, storage medium and electronic device - Google Patents

Image processing method, camera calibration method, device, storage medium and electronic device Download PDF

Info

Publication number
CN112802116B
CN112802116B CN202011602675.5A CN202011602675A CN112802116B CN 112802116 B CN112802116 B CN 112802116B CN 202011602675 A CN202011602675 A CN 202011602675A CN 112802116 B CN112802116 B CN 112802116B
Authority
CN
China
Prior art keywords
image
temperature
reference image
light emitter
camera
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011602675.5A
Other languages
Chinese (zh)
Other versions
CN112802116A (en
Inventor
郭子青
周海涛
欧锦荣
谭筱
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202011602675.5A priority Critical patent/CN112802116B/en
Publication of CN112802116A publication Critical patent/CN112802116A/en
Application granted granted Critical
Publication of CN112802116B publication Critical patent/CN112802116B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/80Analysis of captured images to determine intrinsic or extrinsic camera parameters, i.e. camera calibration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/50Depth or shape recovery
    • G06T7/55Depth or shape recovery from multiple images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10028Range image; Depth image; 3D point clouds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30204Marker

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Studio Devices (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

The application relates to an image processing method, a camera calibration device, a computer readable storage medium and an electronic device. The method comprises the following steps: controlling the temperature of the camera module to reach at least two different designated temperatures, wherein the camera module comprises a light emitter and a camera; controlling the camera to acquire a reference image formed when the light emitter irradiates a reference plane at the specified temperature; storing the specified temperature in correspondence with a reference image; wherein the reference image carries reference depth information, which is used to calculate depth information of the object. The image processing method, the camera calibration device, the computer readable storage medium and the electronic equipment can realize the accuracy of image processing.

Description

图像处理方法、摄像头标定方法、装置、存储介质和电子设备Image processing method, camera calibration method, device, storage medium and electronic device

本申请是申请日为2018年6月28日、发明名称为“摄像头标定方法、装置、计算机可读存储介质和电子设备”、申请号为201810690949.7的专利申请的分案申请。This application is a divisional application of a patent application with an application date of June 28, 2018, an invention name of “Camera calibration method, device, computer-readable storage medium and electronic device” and an application number of 201810690949.7.

技术领域Technical Field

本申请涉及计算机技术领域,特别是涉及一种图像处理方法、摄像头标定方法、装置、计算机可读存储介质和电子设备。The present application relates to the field of computer technology, and in particular to an image processing method, a camera calibration method, a device, a computer-readable storage medium, and an electronic device.

背景技术Background Art

结构光可用于解锁、支付、美颜等应用中。具体地,可以通过一个激光发射器发射具有一定结构特征的红外光线,然后通过激光摄像头采集这些红外光线形成的图像,通过采集的这些红外光线形成的图像可以计算物体到摄像头的深度信息。如果激光发射器和激光摄像头产生形变,就会导致采集的图像发生变化,从而导致计算得到的深度信息也会产生误差。Structured light can be used in applications such as unlocking, payment, and beautification. Specifically, a laser emitter can emit infrared light with certain structural features, and then a laser camera can collect images formed by these infrared lights. The images formed by these collected infrared lights can be used to calculate the depth information from the object to the camera. If the laser emitter and the laser camera are deformed, the collected image will change, which will cause errors in the calculated depth information.

发明内容Summary of the invention

本申请实施例提供一种摄像头标定方法、装置、计算机可读存储介质和电子设备,可以图像处理的准确性。The embodiments of the present application provide a camera calibration method, device, computer-readable storage medium, and electronic device, which can improve the accuracy of image processing.

一种摄像头标定方法,所述方法包括:A camera calibration method, the method comprising:

控制摄像头模组的温度到达至少两个不同的指定温度,其中所述摄像头模组中包括光发射器和摄像头;Controlling the temperature of a camera module to reach at least two different specified temperatures, wherein the camera module includes a light emitter and a camera;

控制所述摄像头采集所述光发射器在所述指定温度下照射参考平面时所形成的参考图像;Controlling the camera to collect a reference image formed when the light emitter illuminates the reference plane at the specified temperature;

将所述指定温度与参考图像对应地进行存储;其中,所述参考图像带有参考深度信息,所述参考深度信息用于计算物体的深度信息。The designated temperature is stored corresponding to a reference image; wherein the reference image carries reference depth information, and the reference depth information is used to calculate depth information of an object.

一种摄像头标定装置,所述装置包括:A camera calibration device, the device comprising:

温度控制模块,用于控制摄像头模组的温度到达至少两个不同的指定温度,其中所述摄像头模组中包括光发射器和摄像头;A temperature control module, used to control the temperature of a camera module to reach at least two different specified temperatures, wherein the camera module includes a light emitter and a camera;

图像获取模块,用于控制所述摄像头采集所述光发射器在所述指定温度下照射参考平面时所形成的参考图像;An image acquisition module, used for controlling the camera to collect a reference image formed when the light emitter illuminates the reference plane at the specified temperature;

图像存储模块,用于将所述指定温度与参考图像对应地进行存储;其中,所述参考图像带有参考深度信息,所述参考深度信息用于计算物体的深度信息。The image storage module is used to store the specified temperature and the reference image in correspondence; wherein the reference image carries reference depth information, and the reference depth information is used to calculate the depth information of the object.

一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

控制摄像头模组的温度到达至少两个不同的指定温度,其中所述摄像头模组中包括光发射器和摄像头;Controlling the temperature of a camera module to reach at least two different specified temperatures, wherein the camera module includes a light emitter and a camera;

控制所述摄像头采集所述光发射器在所述指定温度下照射参考平面时所形成的参考图像;Controlling the camera to collect a reference image formed when the light emitter illuminates the reference plane at the specified temperature;

将所述指定温度与参考图像对应地进行存储;其中,所述参考图像带有参考深度信息,所述参考深度信息用于计算物体的深度信息。The designated temperature is stored corresponding to a reference image; wherein the reference image carries reference depth information, and the reference depth information is used to calculate depth information of an object.

一种电子设备,包括存储器及处理器,所述存储器中储存有计算机可读指令,所述指令被所述处理器执行时,使得所述处理器执行如下步骤:An electronic device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the instructions are executed by the processor, the processor performs the following steps:

控制摄像头模组的温度到达至少两个不同的指定温度,其中所述摄像头模组中包括光发射器和摄像头;Controlling the temperature of a camera module to reach at least two different specified temperatures, wherein the camera module includes a light emitter and a camera;

控制所述摄像头采集所述光发射器在所述指定温度下照射参考平面时所形成的参考图像;Controlling the camera to collect a reference image formed when the light emitter illuminates the reference plane at the specified temperature;

将所述指定温度与参考图像对应地进行存储;其中,所述参考图像带有参考深度信息,所述参考深度信息用于计算物体的深度信息。The designated temperature is stored corresponding to a reference image; wherein the reference image carries reference depth information, and the reference depth information is used to calculate depth information of an object.

上述摄像头标定方法、装置、计算机可读存储介质和电子设备,可以控制摄像头模组的温度到达至少两个不同的指定温度,并控制摄像头模组采集在不同指定温度下所形成的参考图像,然后将参考图像与指定温度对应地进行存储。由于摄像头模组在不同的温度下会产生形变,同时温度本身也会对摄像头模组采集的图像产生影响,所以在摄像头标定的时候控制摄像头模组在不同的指定温度下采集图像。这样就可以根据摄像头模组的温度来获取对应的参考图像,并根据参考图像中的参考深度信息来计算物体的深度信息,避免摄像头模组的温度变化所带来的误差,提高了图像处理的准确性。The above-mentioned camera calibration method, device, computer-readable storage medium and electronic device can control the temperature of the camera module to reach at least two different specified temperatures, and control the camera module to collect reference images formed at different specified temperatures, and then store the reference images corresponding to the specified temperatures. Since the camera module will deform at different temperatures, and the temperature itself will also affect the image collected by the camera module, the camera module is controlled to collect images at different specified temperatures during camera calibration. In this way, the corresponding reference image can be obtained according to the temperature of the camera module, and the depth information of the object can be calculated according to the reference depth information in the reference image, thereby avoiding the error caused by the temperature change of the camera module and improving the accuracy of image processing.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

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

图1为一个实施例中摄像头标定方法的应用环境图;FIG1 is a diagram of an application environment of a camera calibration method according to an embodiment;

图2为一个实施例中安装摄像头模组的电子设备的示意图;FIG2 is a schematic diagram of an electronic device equipped with a camera module according to an embodiment;

图3为一个实施例中摄像头标定方法的流程图;FIG3 is a flow chart of a camera calibration method in one embodiment;

图4为另一个实施例中摄像头标定方法的流程图;FIG4 is a flow chart of a camera calibration method in another embodiment;

图5为一个实施例中计算深度信息的原理图;FIG5 is a schematic diagram showing a principle for calculating depth information in one embodiment;

图6为又一个实施例中摄像头标定方法的流程图;FIG6 is a flow chart of a camera calibration method in another embodiment;

图7为又一个实施例中摄像头标定方法的流程图;FIG7 is a flow chart of a camera calibration method in another embodiment;

图8为一个实施例中实现摄像头标定方法的硬件结构图;FIG8 is a hardware structure diagram of a camera calibration method according to an embodiment;

图9为一个实施例中实现摄像头标定方法的交互图;FIG9 is an interaction diagram for implementing a camera calibration method in one embodiment;

图10为一个实施例中摄像头标定装置的结构示意图;FIG10 is a schematic diagram of the structure of a camera calibration device in one embodiment;

图11为另一个实施例中摄像头标定装置的结构示意图。FIG. 11 is a schematic diagram of the structure of a camera calibration device in another embodiment.

具体实施方式DETAILED DESCRIPTION

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

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

图1为一个实施例中摄像头标定方法的应用环境图。如图1所示,该应用环境中包含标定设备10和电子设备12。电子设备12上可安装摄像头模组,摄像头模组中包括光发射器和摄像头。将电子设备12固定在标定设备10上,通过标定设备10对电子设备12的摄像头模组进行标定。具体的,标定设备10中包括面光源100、参考平面102、激光传感器104、电动角位台106和电动升降台108。电动角位台106光可以调节电子设备10的角度,使电子设备10的摄像头模组的光轴垂直于参考平面102,电动升降台108可以调整电子设备12与参考平面102之间的垂直距离,并通过激光传感器104对该垂直距离进行测量。面光源100用于照亮参考平面102上的编码区域,电子设备12可控制摄像头模组的温度到达至少两个不同的指定温度,当光发射器在不同的指定温度下发射的光源照射到参考平面102时,通过摄像头采集不同指定温度下参考平面102上所形成的参考图像,并建立指定温度与参考图像之间的对应关系,然后将指定温度和参考图像对应地进行存储。FIG1 is an application environment diagram of a camera calibration method in an embodiment. As shown in FIG1 , the application environment includes a calibration device 10 and an electronic device 12. A camera module can be installed on the electronic device 12, and the camera module includes a light emitter and a camera. The electronic device 12 is fixed on the calibration device 10, and the camera module of the electronic device 12 is calibrated by the calibration device 10. Specifically, the calibration device 10 includes a surface light source 100, a reference plane 102, a laser sensor 104, an electric angle table 106, and an electric lifting platform 108. The electric angle table 106 can adjust the angle of the electronic device 10 so that the optical axis of the camera module of the electronic device 10 is perpendicular to the reference plane 102. The electric lifting platform 108 can adjust the vertical distance between the electronic device 12 and the reference plane 102, and measure the vertical distance through the laser sensor 104. The surface light source 100 is used to illuminate the coding area on the reference plane 102. The electronic device 12 can control the temperature of the camera module to reach at least two different specified temperatures. When the light source emitted by the light emitter at different specified temperatures irradiates the reference plane 102, the reference image formed on the reference plane 102 at different specified temperatures is collected by the camera, and a corresponding relationship between the specified temperature and the reference image is established, and then the specified temperature and the reference image are stored accordingly.

图2为一个实施例中安装摄像头模组的电子设备的示意图。如图2所示,该电子设备20上安装了摄像头模组,包括光发射器202和摄像头204。在对摄像头标定的过程中,电子设备20可以控制摄像头模组的温度达到不同的指定温度,并在不同指定温度时通过光发射器202发射光线,并通过摄像头204采集光线照射到参考平面时所形成的参考图像。最后电子设备20可以建立指定温度和参考图像的对应关系,并将指定温度和参考图像进行存储。FIG2 is a schematic diagram of an electronic device with a camera module installed in an embodiment. As shown in FIG2 , the electronic device 20 is equipped with a camera module, including a light emitter 202 and a camera 204. In the process of calibrating the camera, the electronic device 20 can control the temperature of the camera module to reach different specified temperatures, and emit light through the light emitter 202 at different specified temperatures, and collect the reference image formed when the light is irradiated to the reference plane through the camera 204. Finally, the electronic device 20 can establish a corresponding relationship between the specified temperature and the reference image, and store the specified temperature and the reference image.

图3为一个实施例中摄像头标定方法的流程图。如图3所示,该摄像头标定方法中包括步骤302至步骤306。其中:FIG3 is a flow chart of a camera calibration method in one embodiment. As shown in FIG3 , the camera calibration method includes steps 302 to 306. Among them:

步骤302,控制摄像头模组的温度到达至少两个不同的指定温度,其中摄像头模组中包括光发射器和摄像头。Step 302: Control the temperature of a camera module to reach at least two different specified temperatures, wherein the camera module includes a light emitter and a camera.

在一个实施例中,电子设备上可以安装摄像头,并通过安装的摄像头获取图像。摄像头可以根据获取的图像的不同分为激光摄像头、可见光摄像头等类型,激光摄像头可以获取激光照射到物体上所形成的图像,可见光图像可以获取可见光照射到物体上所形成的图像。电子设备上可以安装若干个摄像头,且安装的位置不做限定。例如,可以在电子设备的正面面板上安装一个摄像头,在背面面板上安装两个摄像头,摄像头还可以以内嵌的方式安装于电子设备的内部,然后通过旋转或滑动的方式打开摄像头。具体地,电子设备上可安装前置摄像头和后置摄像头,前置摄像头和后置摄像头可以从不同的视角获取图像,一般前置摄像头可以从电子设备的正面视角获取图像,后置摄像头可以从电子设备的背面视角获取图像。In one embodiment, a camera can be installed on the electronic device, and an image can be acquired through the installed camera. Cameras can be divided into laser cameras, visible light cameras and other types according to the different images acquired. Laser cameras can acquire images formed by irradiating lasers onto objects, and visible light cameras can acquire images formed by irradiating visible light onto objects. Several cameras can be installed on an electronic device, and the installation locations are not limited. For example, a camera can be installed on the front panel of the electronic device, and two cameras can be installed on the back panel. The camera can also be installed inside the electronic device in an embedded manner, and then the camera can be opened by rotating or sliding. Specifically, a front camera and a rear camera can be installed on the electronic device. The front camera and the rear camera can acquire images from different perspectives. Generally, the front camera can acquire images from the front perspective of the electronic device, and the rear camera can acquire images from the back perspective of the electronic device.

电子设备可通过拍摄的图像测量场景中的物体到电子设备的深度信息,具体可以通过结构光来测量该深度信息。在通过结构光获取深度信息时,电子设备上可安装包含光发射器和摄像头的摄像头模组,获取深度信息的过程具体可包括摄像头标定阶段和测量阶段。在摄像头标定阶段,光发射器可以发射光线,光线照射到参考平面时,可形成参考图像,然后通过摄像头来获取该参考图像。参考平面到电子设备的距离是已知的,然后就可以建立该已知距离和参考图像的对应关系。在测量阶段,就可以根据实时获取的图像以及上述对应关系来计算物体实际的距离。The electronic device can measure the depth information from the object in the scene to the electronic device through the captured image, and the depth information can be measured specifically through structured light. When obtaining depth information through structured light, a camera module including a light emitter and a camera can be installed on the electronic device, and the process of obtaining depth information can specifically include a camera calibration stage and a measurement stage. In the camera calibration stage, the light emitter can emit light, and when the light is irradiated to the reference plane, a reference image can be formed, and then the reference image is obtained through the camera. The distance from the reference plane to the electronic device is known, and then the correspondence between the known distance and the reference image can be established. In the measurement stage, the actual distance of the object can be calculated based on the image obtained in real time and the above correspondence.

可以理解的是,摄像头模组在工作过程中可能会产生热量,而摄像头模组的参数和形状可能会受到温度变化的影响。因此为了减少温度带来的误差,就可以在对摄像头标定的过程中,控制摄像头模组达到不同的温度,并在不同温度下控制摄像头模组来采集参考图像。具体地,可控制摄像头模组的温度到达至少两个不同的指定温度,并分别在不同的指定温度下完整标定。It is understandable that the camera module may generate heat during operation, and the parameters and shape of the camera module may be affected by temperature changes. Therefore, in order to reduce the error caused by temperature, the camera module can be controlled to reach different temperatures during the camera calibration process, and the camera module can be controlled at different temperatures to collect reference images. Specifically, the temperature of the camera module can be controlled to reach at least two different specified temperatures, and the camera module can be fully calibrated at different specified temperatures.

步骤304,控制摄像头采集光发射器在指定温度下照射参考平面时所形成的参考图像。Step 304 , controlling the camera to collect a reference image formed when the light emitter illuminates the reference plane at a specified temperature.

摄像头模组中的光发射器和摄像头一般在同一水平线上,标定设备首先需要调节电子设备的位置,使光发射器和摄像头形成的光轴与参考平面垂直,这样就可以计算电子设备到参考平面的垂直距离。可以理解的是,上述垂直距离是可以调节的,电子设备到参考平面的垂直距离不同时,所形成的参考图像也不同。当摄像头模组的温度到达不同指定温度的时候,可以控制光源发生器发射光线。光线照射到参考平面时,通过摄像头来采集所形成的参考图像。The light emitter and camera in the camera module are generally on the same horizontal line. The calibration device first needs to adjust the position of the electronic device so that the optical axis formed by the light emitter and the camera is perpendicular to the reference plane, so that the vertical distance from the electronic device to the reference plane can be calculated. It is understandable that the above vertical distance is adjustable, and when the vertical distance from the electronic device to the reference plane is different, the reference image formed is also different. When the temperature of the camera module reaches different specified temperatures, the light source generator can be controlled to emit light. When the light is irradiated to the reference plane, the reference image formed is collected by the camera.

步骤306,将指定温度与参考图像对应地进行存储;其中,参考图像带有参考深度信息,参考深度信息用于计算物体的深度信息。Step 306, storing the designated temperature and the reference image in correspondence; wherein the reference image carries reference depth information, and the reference depth information is used to calculate the depth information of the object.

光发射器可以发射包含若干个散斑点的激光,然后通过摄像头采集上述包含散斑点的激光照射到参考平面上所形成的参考图像。参考深度信息即为电子设备到参考平面的距离,参考深度信息是已知的,可以根据参考图像和参考深度信息得到计算深度信息的模型。在测量过程中,可获取激光照射到物体上时所形成的散斑图像,根据上述模型就可以计算出散斑图像中包含的物体的深度信息。The light transmitter can emit a laser containing a number of scattered spots, and then the camera can be used to collect a reference image formed by the laser containing scattered spots irradiating the reference plane. The reference depth information is the distance from the electronic device to the reference plane. The reference depth information is known, and a model for calculating the depth information can be obtained based on the reference image and the reference depth information. During the measurement process, the speckle image formed when the laser is irradiated onto the object can be obtained, and the depth information of the object contained in the speckle image can be calculated based on the above model.

在摄像头标定过程中,会采集不同指定温度对应的参考图像,并将参考图像进行存储。在测量深度信息的过程中,就可以首先获取摄像头模组的温度,并根据温度获取对应的参考图像,根据获取的参考图像计算物体的深度信息。例如,控制摄像头模组分别在30℃(Degree Celsius,摄氏度)和80℃时,分别采集一张参考图像,然后将参考图像与摄像头模组对应的进行存储。在测量过程中,首先获取摄像头模组的当前温度,获取与当前温度最靠近的指定温度所对应的参考图像来计算深度信息。During the camera calibration process, reference images corresponding to different specified temperatures are collected and stored. In the process of measuring depth information, the temperature of the camera module can be first obtained, and the corresponding reference image can be obtained according to the temperature, and the depth information of the object can be calculated according to the obtained reference image. For example, the camera module is controlled to collect a reference image at 30°C (Degree Celsius) and 80°C respectively, and then the reference image and the camera module are stored accordingly. During the measurement process, the current temperature of the camera module is first obtained, and the reference image corresponding to the specified temperature closest to the current temperature is obtained to calculate the depth information.

上述实施例提供的摄像头标定方法,可以控制摄像头模组的温度到达至少两个不同的指定温度,并控制摄像头模组采集在不同指定温度下所形成的参考图像,然后将参考图像与指定温度对应地进行存储。由于摄像头模组在不同的温度下会产生形变,同时温度本身也会对摄像头模组采集的图像产生影响,所以在摄像头标定的时候控制摄像头模组在不同的指定温度下采集图像。这样就可以根据摄像头模组的温度来获取对应的参考图像,并根据参考图像中的参考深度信息来计算物体的深度信息,避免摄像头模组的温度变化所带来的误差,提高了图像处理的准确性。The camera calibration method provided in the above embodiment can control the temperature of the camera module to reach at least two different specified temperatures, and control the camera module to collect reference images formed at different specified temperatures, and then store the reference images corresponding to the specified temperatures. Since the camera module will deform at different temperatures, and the temperature itself will also affect the image collected by the camera module, the camera module is controlled to collect images at different specified temperatures during camera calibration. In this way, the corresponding reference image can be obtained according to the temperature of the camera module, and the depth information of the object can be calculated according to the reference depth information in the reference image, thereby avoiding the error caused by the temperature change of the camera module and improving the accuracy of image processing.

图4为另一个实施例中摄像头标定方法的流程图。如图4所示,该摄像头标定方法包括步骤402至步骤412。其中:FIG4 is a flow chart of a camera calibration method in another embodiment. As shown in FIG4 , the camera calibration method includes steps 402 to 412. Among them:

步骤402,向光发射器输入至少两个不同频率的脉冲宽度调制PWM,通过脉冲宽度调制PWM控制光发射器的温度到达至少两个不同的指定温度。Step 402: inputting at least two pulse width modulations (PWM) of different frequencies into the light emitter, and controlling the temperature of the light emitter to reach at least two different designated temperatures through the pulse width modulation (PWM).

在一个实施例中,光发射器可与处理器进行连接,通过处理器对光发射器发射指令,控制光发射器的开关。具体的,在摄像头标定过程中,可通过光发射器发射激光散斑,再通过激光摄像头采集激光散斑照射到物体上所形成的参考图像。光发射器的工作可以通过一个脉冲波进行控制的,这样工作频率越高,光发射器的温度就会越高,从而使得摄像头模组的温度也会升高。因此在标定过程中,可以通过控制光发射器的工作频率来调节摄像头模组的温度。具体地,控制光发射器在指定频率下工作,通过在指定频率下工作的光发射器控制摄像头模组的温度到达指定温度。In one embodiment, the light emitter can be connected to the processor, and the processor sends instructions to the light emitter to control the switch of the light emitter. Specifically, during the camera calibration process, the laser speckle can be emitted by the light emitter, and then the reference image formed by the laser speckle irradiated on the object can be collected by the laser camera. The operation of the light emitter can be controlled by a pulse wave, so that the higher the operating frequency, the higher the temperature of the light emitter will be, and the temperature of the camera module will also increase. Therefore, during the calibration process, the temperature of the camera module can be adjusted by controlling the operating frequency of the light emitter. Specifically, the light emitter is controlled to work at a specified frequency, and the temperature of the camera module is controlled to reach a specified temperature by the light emitter working at the specified frequency.

具体的,可以通过处理器与摄像头模组进行连接,并通过处理器来控制光发射器的工作频率。处理器会向光发射器输入一个脉冲信号,并通过该脉冲信号来控制光发射器的开关。上述脉冲信号可以是PWM(Pulse Width Modulation,脉冲宽度调制),处理器可以向光发射器输入不同频率的PWM,从而使得光发射器到达不同的指定温度。Specifically, the processor can be connected to the camera module and the operating frequency of the light emitter can be controlled by the processor. The processor will input a pulse signal to the light emitter and control the switch of the light emitter through the pulse signal. The above pulse signal can be PWM (Pulse Width Modulation). The processor can input PWM of different frequencies to the light emitter, so that the light emitter reaches different specified temperatures.

步骤404,控制摄像头采集光发射器在指定温度下照射参考平面时所形成的参考图像。Step 404 , controlling the camera to collect a reference image formed when the light emitter illuminates the reference plane at a specified temperature.

每获取一次参考图像,电子设备都可以将获取的该参考图像与指定温度建立对应关系。在获取到参考图像之后,电子设备会将参考图像与对应的指定温度进行存储。这样在实际拍摄的过程中,就可以根据摄像头模组的温度来获取对应的参考图像。Each time a reference image is acquired, the electronic device can establish a corresponding relationship between the acquired reference image and the specified temperature. After acquiring the reference image, the electronic device will store the reference image and the corresponding specified temperature. In this way, during the actual shooting process, the corresponding reference image can be acquired according to the temperature of the camera module.

步骤406,建立指定温度和参考图像的对应关系,将指定温度和参考图像写入到终端的安全运行环境中进行存储。Step 406: establish a corresponding relationship between the specified temperature and the reference image, and write the specified temperature and the reference image into the secure operation environment of the terminal for storage.

可以理解的是,可以直接建立指定温度和参考图像的对应关系,也可以根据指定温度划定一个温度范围,并建立温度范围和参考图像的对应关系,然后将温度范围和参考图像写入到终端中。例如,采集光发射器在指定温度为30℃、60℃和90℃时所形成的参考图像,分别为“pic-01”、“pic-02”和“pic-03”。若上述指定温度对应的温度范围分别为[0,50℃]、[50℃,90℃]、[90℃,+∞),那么在测距过程中,就可以确定光发射器所落入的温度范围,并根据温度范围获取对应的参考图像。It is understandable that the correspondence between the specified temperature and the reference image can be directly established, or a temperature range can be defined according to the specified temperature, and the correspondence between the temperature range and the reference image can be established, and then the temperature range and the reference image can be written into the terminal. For example, the reference images formed by the light emitter at the specified temperatures of 30°C, 60°C and 90°C are respectively "pic-01", "pic-02" and "pic-03". If the temperature ranges corresponding to the above specified temperatures are [0,50°C], [50°C,90°C], [90°C,+∞), then in the ranging process, the temperature range into which the light emitter falls can be determined, and the corresponding reference image can be obtained according to the temperature range.

一般地,为保证图像处理的安全性,电子设备都会在安全运行环境中计算深度信息。因此可以将采集的参考图像及对应的指定温度,存储在安全运行环境中,在测量过程中,就可以直接在安全环境中计算深度信息。例如,电子设备的上层应用发起人脸支付指令,在人脸支付的过程中可以通过摄像头模组来获取深度信息,并通过深度信息来判断人脸是否为活体,那么就需要保证深度信息是在一个安全运行环境中计算得到的。Generally, to ensure the security of image processing, electronic devices will calculate depth information in a safe operating environment. Therefore, the collected reference image and the corresponding specified temperature can be stored in a safe operating environment, and during the measurement process, the depth information can be calculated directly in the safe environment. For example, the upper-layer application of the electronic device initiates a face payment instruction. During the face payment process, the depth information can be obtained through the camera module, and the depth information is used to determine whether the face is alive. Therefore, it is necessary to ensure that the depth information is calculated in a safe operating environment.

在本申请提供的实施例中,终端中的安全运行环境可分为第一安全运行环境和第二安全运行环境,第一安全运行环境中的存储空间大于第二安全运行环境的存储空间。为了避免第二安全运行环境中的存储空间被过度占用,影响图像的处理,就可以在标定过程中,将指定温度和参考图像写入到终端的第一安全运行环境中进行存储。当检测到终端开机时,将指定温度和参考图像从第一安全运行环境中加载到第二安全运行环境中进行存储。In the embodiment provided in the present application, the safe operation environment in the terminal can be divided into a first safe operation environment and a second safe operation environment, and the storage space in the first safe operation environment is larger than the storage space in the second safe operation environment. In order to avoid excessive occupation of the storage space in the second safe operation environment and affect the processing of the image, the specified temperature and reference image can be written into the first safe operation environment of the terminal for storage during the calibration process. When it is detected that the terminal is turned on, the specified temperature and reference image are loaded from the first safe operation environment to the second safe operation environment for storage.

步骤408,当检测到摄像头模组被打开时,控制摄像头模组采集散斑图像。Step 408: When it is detected that the camera module is turned on, the camera module is controlled to collect a speckle image.

具体的,终端的处理单元可以接收来自上层应用程序的指令,当处理单元接收到图像采集指令时,就可以控制摄像头模组进行工作,通过摄像头采集散斑图像。处理单元连接于摄像头,摄像头获取的图像就可以传输给处理单元,并通过处理单元进行裁剪、亮度调节、人脸检测、人脸识别等处理。具体地,当处理单元接收到图像采集指令时,处理单元会控制光发射器进行工作,当光发射器开启时,通过激光摄像头采集光发射器照射到物体上所形成的散斑图像。Specifically, the processing unit of the terminal can receive instructions from the upper-layer application. When the processing unit receives the image acquisition instruction, it can control the camera module to work and collect speckle images through the camera. The processing unit is connected to the camera, and the image acquired by the camera can be transmitted to the processing unit, and the processing unit performs processing such as cropping, brightness adjustment, face detection, and face recognition. Specifically, when the processing unit receives the image acquisition instruction, the processing unit controls the light emitter to work. When the light emitter is turned on, the laser camera collects the speckle image formed by the light emitter irradiating the object.

可以理解的是,上述光发射器可以是激光发射器,当激光照射在平均起伏大于波长数量级的光学粗糙表面上时,这些表面上无规分布的面元散射的子波相互叠加使反射光场具有随机的空间光强分布,呈现出颗粒状的结构,这就是激光散斑。形成的激光散斑具有高度随机性,因此不同的激光发射器发射出来的激光所生成的激光散斑不同。当形成的激光散斑照射到不同深度和形状的物体上时,生成的散斑图像是不一样的。通过不同的激光发射器形成的激光散斑具有唯一性,从而得到的散斑图像也具有唯一性。光发射器形成的激光散斑可以照射到物体上,然后通过激光摄像头来采集的激光散斑照射到物体上所形成的散斑图像。It is understandable that the above-mentioned light emitter can be a laser emitter. When the laser is irradiated on an optically rough surface whose average fluctuation is greater than the order of the wavelength, the sub-waves scattered by the randomly distributed surface elements on these surfaces are superimposed on each other so that the reflected light field has a random spatial light intensity distribution and presents a granular structure, which is the laser speckle. The formed laser speckle is highly random, so the laser speckles generated by lasers emitted by different laser emitters are different. When the formed laser speckle is irradiated on objects of different depths and shapes, the generated speckle images are different. The laser speckle formed by different laser emitters is unique, and thus the obtained speckle image is also unique. The laser speckle formed by the light emitter can be irradiated on an object, and then the speckle image formed by the laser speckle irradiated on the object is collected by a laser camera.

图像采集指令是指用于触发图像采集操作的指令。例如,当用户对智能手机进行解锁的时候,可以通过获取人脸图像进行验证解锁,则上层应用可以发起图像采集指令,并通过图像采集指令控制摄像头模组来采集图像。具体地,第一处理单元可以接收上层应用程序发起的图像采集指令,当第一处理单元检测到图像采集指令时,会控制摄像头模组开启,然后控制摄像头模组采集散斑图像。摄像头模组采集的散斑图像可以发送给第二处理单元,第二处理单元再根据散斑图像计算深度信息。Image acquisition instructions refer to instructions for triggering image acquisition operations. For example, when a user unlocks a smartphone, he can verify the unlocking by acquiring a face image. The upper-layer application can initiate an image acquisition instruction and control the camera module to acquire images through the image acquisition instruction. Specifically, the first processing unit can receive an image acquisition instruction initiated by an upper-layer application. When the first processing unit detects the image acquisition instruction, it controls the camera module to turn on and then controls the camera module to acquire a speckle image. The speckle image acquired by the camera module can be sent to the second processing unit, and the second processing unit calculates the depth information based on the speckle image.

步骤410,当检测到光发射器的温度变化超过温度阈值时,获取光发射器的当前温度。Step 410: When it is detected that the temperature change of the light emitter exceeds the temperature threshold, the current temperature of the light emitter is obtained.

在检测到摄像头模组被打开后,可以通过一个温度传感器定时检测光发射器的温度,并将检测到的温度发送给第二处理单元。第二处理单元判断光发射器的温度变化是否超过温度阈值,若是则将该温度作为光发射器的当前温度,并根据当前温度来获取对应的目标参考图像,根据获取的目标参考图像计算深度信息。例如,温度阈值可以为5℃,当光发射器的温度变化超过5℃时,就可以根据获取的光发射器的温度确定对应的目标参考图像。可以理解的是,为保证准确性,采集散斑图像和获取当前温度时所间隔的时间不能太长。After detecting that the camera module is turned on, a temperature sensor can be used to periodically detect the temperature of the light emitter, and the detected temperature can be sent to the second processing unit. The second processing unit determines whether the temperature change of the light emitter exceeds the temperature threshold. If so, the temperature is used as the current temperature of the light emitter, and the corresponding target reference image is obtained based on the current temperature, and the depth information is calculated based on the obtained target reference image. For example, the temperature threshold can be 5°C. When the temperature change of the light emitter exceeds 5°C, the corresponding target reference image can be determined based on the obtained temperature of the light emitter. It can be understood that in order to ensure accuracy, the time interval between collecting the speckle image and obtaining the current temperature cannot be too long.

步骤412,根据光发射器的当前温度获取对应的目标参考图像,并根据散斑图像和目标参考图像计算深度图像,深度图像用于表示物体的深度信息。Step 412: acquiring a corresponding target reference image according to the current temperature of the light emitter, and calculating a depth image according to the speckle image and the target reference image, wherein the depth image is used to represent the depth information of the object.

指定温度和参考图像对应地进行存储,那么在测量深度信息的过程中,就可以根据光发射器的当前温度来确定对应的目标参考图像,然后根据散斑图像和目标参考图像计算深度图像。具体的,可以将目标参考图像与散斑图像进行比较得到偏移信息,偏移信息用于表示散斑图像中散斑点相对于目标参考图像中对应散斑点的水平偏移量,根据偏移信息和参考深度信息计算得到深度图像。。The specified temperature and the reference image are stored correspondingly. Then, in the process of measuring the depth information, the corresponding target reference image can be determined according to the current temperature of the light emitter, and then the depth image can be calculated according to the speckle image and the target reference image. Specifically, the target reference image can be compared with the speckle image to obtain the offset information. The offset information is used to indicate the horizontal offset of the speckle spots in the speckle image relative to the corresponding speckle spots in the target reference image. The depth image is calculated according to the offset information and the reference depth information.

在一个实施例中,遍历散斑图像中每一个像素点(x,y),以该像素点为中心,选择一个预设大小像素块。例如,可以是选取31pixel*31pixel大小的像素块。然后在目标参考图像上搜索相匹配的像素块,计算在目标参考图像上匹配的像素点的坐标与像素点(x,y)坐标的水平偏移量,向右偏移即为正,向左偏移记为负。再把计算出的水平偏移量带入公式(1)可以得到像素点(x,y)的深度信息。这样依次计算散斑图像中每个像素点的深度信息,就可以得到带有散斑图像中各个像素点所对应的深度信息。In one embodiment, each pixel point (x, y) in the speckle image is traversed, and a pixel block of a preset size is selected with the pixel point as the center. For example, a pixel block of 31 pixels*31 pixels can be selected. Then, a matching pixel block is searched on the target reference image, and the horizontal offset between the coordinates of the matching pixel point on the target reference image and the coordinates of the pixel point (x, y) is calculated. The offset to the right is positive, and the offset to the left is negative. Then, the calculated horizontal offset is substituted into formula (1) to obtain the depth information of the pixel point (x, y). In this way, the depth information of each pixel point in the speckle image is calculated in turn, and the depth information corresponding to each pixel point in the speckle image can be obtained.

深度图像可以用于表示被拍摄物体对应的深度信息,深度图像中包含的每一个像素点表示一个深度信息。具体地,参考图像中的每一个散斑点都对应一个参考深度信息,当获取到参考图像中散斑点与散斑图像中散斑点的水平偏移量后,可以根据该水平偏移量计算得到散斑图像中的物体到参考平面的相对深度信息,然后再根据相对深度信息和参考深度信息,就可以计算得到物体到摄像头的实际深度信息,即得到最后的深度图像。The depth image can be used to represent the depth information corresponding to the photographed object, and each pixel contained in the depth image represents a depth information. Specifically, each scattered speckle in the reference image corresponds to a reference depth information. After obtaining the horizontal offset between the scattered speckle in the reference image and the scattered speckle in the speckle image, the relative depth information from the object in the speckle image to the reference plane can be calculated based on the horizontal offset. Then, based on the relative depth information and the reference depth information, the actual depth information from the object to the camera can be calculated, that is, the final depth image can be obtained.

图5为一个实施例中计算深度信息的原理图。如图5所示,镭射灯502可以生成激光散斑,激光散斑经过物体进行反射后,通过激光摄像头504获取形成的图像。在摄像头的标定过程中,镭射灯502发射的激光散斑会经过参考平面508进行反射,然后通过激光摄像头504采集反射光线,通过成像平面510成像得到参考图像。参考平面508到镭射灯502的参考深度为L,该参考深度为已知的。在实际计算深度信息的过程中,镭射灯502发射的激光散斑会经过物体506进行反射,再由激光摄像头504采集反射光线,通过成像平面510成像得到实际的散斑图像。则可以得到实际的深度信息的计算公式为:FIG5 is a schematic diagram of a principle for calculating depth information in one embodiment. As shown in FIG5 , the laser lamp 502 can generate laser speckles, and after the laser speckles are reflected by an object, the formed image is acquired by the laser camera 504. During the calibration process of the camera, the laser speckles emitted by the laser lamp 502 will be reflected by the reference plane 508, and then the reflected light will be collected by the laser camera 504, and the reference image will be obtained by imaging the imaging plane 510. The reference depth from the reference plane 508 to the laser lamp 502 is L, and the reference depth is known. In the actual process of calculating the depth information, the laser speckles emitted by the laser lamp 502 will be reflected by the object 506, and then the reflected light will be collected by the laser camera 504, and the actual speckle image will be obtained by imaging the imaging plane 510. The calculation formula for the actual depth information can be obtained as follows:

其中,L是镭射灯502到与参考平面508之间的距离,f为激光摄像头504中透镜的焦距,CD为镭射灯502到激光摄像头504之间的距离,AB为物体506的成像与参考平面508的成像之间的偏移距离。AB可为像素偏移量n与像素点的实际距离p的乘积。当物体504到镭射灯502之间的距离Dis大于参考平面506到镭射灯502之间的距离L时,AB为负值;当物体504到镭射灯502之间的距离Dis小于参考平面506到镭射灯502之间的距离L时,AB为正值。Wherein, L is the distance between the laser light 502 and the reference plane 508, f is the focal length of the lens in the laser camera 504, CD is the distance between the laser light 502 and the laser camera 504, and AB is the offset distance between the image of the object 506 and the image of the reference plane 508. AB can be the product of the pixel offset n and the actual distance p of the pixel point. When the distance Dis between the object 504 and the laser light 502 is greater than the distance L between the reference plane 506 and the laser light 502, AB is a negative value; when the distance Dis between the object 504 and the laser light 502 is less than the distance L between the reference plane 506 and the laser light 502, AB is a positive value.

在一个实施例中,摄像头模组中可以包括第一摄像头模组和第二摄像头模组,第一摄像头模组是由泛光灯和激光摄像头构成的,第二摄像头模组是由镭射灯和激光摄像头构成的,第一摄像头模组的激光摄像头和第二摄像头模组的激光摄像头可以是同一个激光摄像头,也可以是不同的激光摄像头,在此不做限定。镭射灯可以发射激光散斑,通过第一摄像头模组可以采集散斑图像。泛光灯可以发生激光,通过第二摄像头模组可以采集红外图像。In one embodiment, the camera module may include a first camera module and a second camera module. The first camera module is composed of a floodlight and a laser camera, and the second camera module is composed of a laser light and a laser camera. The laser camera of the first camera module and the laser camera of the second camera module may be the same laser camera or different laser cameras, which is not limited here. The laser light may emit laser speckle, and the speckle image may be collected by the first camera module. The floodlight may emit laser, and the infrared image may be collected by the second camera module.

其中,红外图像可以表示被拍摄物体的细节信息,根据散斑图像可以获取被拍摄物体的深度信息。为了保证电子设备采集的红外图像和散斑图像是相对应的,就需要控制摄像头模组同时采集红外图像和散斑图像。假设第一摄像头模组和第二摄像头模组为分时工作的话,就必须保证采集红外图像和散斑图像的时间间隔非常短。具体地,根据图像采集指令控制第一摄像头模组采集红外图像,并控制第二摄像头模组采集散斑图像;其中,采集红外图像的第一时刻与采集散斑图像的第二时刻之间的时间间隔小于第一阈值。Among them, the infrared image can represent the detailed information of the photographed object, and the depth information of the photographed object can be obtained according to the speckle image. In order to ensure that the infrared image and the speckle image collected by the electronic device are corresponding, it is necessary to control the camera module to collect the infrared image and the speckle image at the same time. Assuming that the first camera module and the second camera module work in time-sharing, it is necessary to ensure that the time interval between collecting the infrared image and the speckle image is very short. Specifically, according to the image acquisition instruction, the first camera module is controlled to collect the infrared image, and the second camera module is controlled to collect the speckle image; wherein the time interval between the first moment of collecting the infrared image and the second moment of collecting the speckle image is less than the first threshold.

第一阈值一般是一个比较小的值,当时间间隔小于第一阈值时,认为被摄物体没有发生变化,采集的红外图像和散斑图像是对应的。可以理解的是,还可以根据被拍摄物体的变化规律进行调整。被拍摄物体的变化越快,对应获取的第一阈值越小。假设被拍摄物体长时间处于静止状态的话,该第一阈值就可以设置为一个较大的值。具体的,获取被拍摄物体的变化速度,根据该变化速度获取对应的第一阈值。The first threshold is generally a relatively small value. When the time interval is less than the first threshold, it is considered that the object has not changed, and the collected infrared image and speckle image are corresponding. It can be understood that it can also be adjusted according to the change law of the object being photographed. The faster the change of the object being photographed, the smaller the corresponding first threshold is. Assuming that the object being photographed is in a stationary state for a long time, the first threshold can be set to a larger value. Specifically, the change speed of the object being photographed is obtained, and the corresponding first threshold is obtained according to the change speed.

举例来说,当手机需要通过人脸进行认证解锁时,用户可以点击解锁键发起解锁指令,并将前置摄像头对准脸部进行拍摄。手机会将解锁指令发送到处理单元,处理单元再控制摄像头进行工作。首先通过第一摄像头模组采集红外图像,间隔1毫秒时间后,再控制第二摄像头模组采集散斑图像,并通过采集的红外图像和散斑图像进行认证解锁。For example, when a mobile phone needs to be unlocked through face authentication, the user can click the unlock button to initiate the unlock command and aim the front camera at the face to take a picture. The mobile phone will send the unlock command to the processing unit, which will then control the camera to work. First, the first camera module collects infrared images, and after an interval of 1 millisecond, the second camera module is controlled to collect speckle images, and the collected infrared images and speckle images are used for authentication and unlocking.

更进一步地,在第一时刻控制摄像头模组采集红外图像,并在第二时刻控制摄像头模组采集散斑图像;第一时刻与目标时刻之间的时间间隔小于第二阈值;第二时刻与目标时刻之间的时间间隔小于第三阈值。若第一时刻与目标时刻之间的时间间隔小于第二阈值,则控制摄像头模组采集红外图像;若第一时刻与目标时刻之间的时间间隔大于第二阈值,则可向应用程序返回响应超时的提示信息,并等待应用程序重新发起图像采集指令。Furthermore, at the first moment, the camera module is controlled to collect infrared images, and at the second moment, the camera module is controlled to collect speckle images; the time interval between the first moment and the target moment is less than the second threshold; the time interval between the second moment and the target moment is less than the third threshold. If the time interval between the first moment and the target moment is less than the second threshold, the camera module is controlled to collect infrared images; if the time interval between the first moment and the target moment is greater than the second threshold, a prompt message indicating a response timeout may be returned to the application, and the application is waited to re-initiate an image acquisition instruction.

摄像头模组采集红外图像之后,处理单元可控制摄像头模组采集散斑图像,采集散斑图像的第二时刻与第一时刻之间的时间间隔小于第一阈值,同时第二时刻与目标时刻之间的时间间隔小于第三阈值。若第二时刻与第一时刻之间的时间间隔大于第一阈值,或第二时刻与目标时刻之间的时间间隔大于第三阈值,则可向应用程序返回响应超时的提示信息,并等待应用程序重新发起图像采集指令。可以理解的是,采集散斑图像的第二时刻可以大于采集红外图像的第一时刻,也可以小于采集红外图像的第一时刻,在此不做限定。After the camera module acquires the infrared image, the processing unit may control the camera module to acquire the speckle image, and the time interval between the second moment and the first moment of acquiring the speckle image is less than the first threshold, and the time interval between the second moment and the target moment is less than the third threshold. If the time interval between the second moment and the first moment is greater than the first threshold, or the time interval between the second moment and the target moment is greater than the third threshold, a prompt message of response timeout may be returned to the application, and the application is waited to re-initiate the image acquisition instruction. It can be understood that the second moment of acquiring the speckle image may be greater than the first moment of acquiring the infrared image, or may be less than the first moment of acquiring the infrared image, which is not limited here.

具体地,电子设备可分别设置泛光灯控制器和镭射灯控制器,通过两路PWM(PulseWidth Modulation,脉冲宽度调制)分别连接泛光灯控制器和镭射灯控制器,处理单元可向泛光灯控制器输入PWM控制泛光灯开启或向镭射灯控制器输入PWM控制镭射灯开启。Specifically, the electronic device can be provided with a floodlight controller and a laser light controller respectively, and the floodlight controller and the laser light controller are respectively connected through two PWM (Pulse Width Modulation) channels. The processing unit can input PWM to the floodlight controller to control the floodlight to turn on, or input PWM to the laser light controller to control the laser light to turn on.

在本申请提供的实施例中,存储参考图像的步骤还可以包括:In the embodiment provided in the present application, the step of storing the reference image may further include:

步骤602,获取摄像头模组的模组标识,并建立模组标识、指定温度与参考图像的对应关系。Step 602, obtaining the module identification of the camera module, and establishing a corresponding relationship between the module identification, the specified temperature and the reference image.

可以理解的是,在对摄像头进行标定的过程中,可以是对终端上安装的摄像头模组进行标定,也可以是单独对摄像头模组进行标定。这样假设终端上的摄像头模组被损坏,在更换摄像头模组之后,就可以直接将标定得到的摄像头模组的参考图像写入到终端中。It is understandable that in the process of calibrating the camera, the camera module installed on the terminal can be calibrated, or the camera module can be calibrated separately. In this way, if the camera module on the terminal is damaged, after replacing the camera module, the reference image of the calibrated camera module can be directly written into the terminal.

具体的,每一个摄像头模组都有对应的模组标识,模组标识可用于区分不同的摄像头模组。在对摄像头模组进行标定的时候,获取到参考图像后,可以建立模组标识、指定温度和参考图像的对应关系。这样终端在重新安装摄像头模组之后,就可以根据模组标识获取对应的指定温度和参考图像。Specifically, each camera module has a corresponding module ID, which can be used to distinguish different camera modules. When calibrating the camera module, after obtaining the reference image, a correspondence between the module ID, the specified temperature, and the reference image can be established. In this way, after the terminal reinstalls the camera module, it can obtain the corresponding specified temperature and reference image according to the module ID.

步骤604,将模组标识、指定温度与参考图像存储到服务器中。Step 604, storing the module identification, the specified temperature and the reference image in the server.

在单独对摄像头模组进行标定的过程中,可将获取的模组标识、指定温度与参考图像存储到服务器中。服务器可以以列表形式存储上述模组标识、指定温度与参考图像,根据模组标识就可以对指定温度和参考图像进行查询并获取。对摄像头模组标定完成之后,终端在重新安装摄像头模组时,可以从服务器上获取参考图像。具体的:In the process of calibrating the camera module alone, the obtained module identification, specified temperature and reference image can be stored in the server. The server can store the above module identification, specified temperature and reference image in a list form, and the specified temperature and reference image can be queried and obtained according to the module identification. After the camera module is calibrated, the terminal can obtain the reference image from the server when reinstalling the camera module. Specifically:

步骤702,当服务器接收到终端发送的参考图像获取请求时,根据参考图像获取请求中包含的模组标识获取对应的指定温度和参考图像。Step 702: When the server receives the reference image acquisition request sent by the terminal, the server acquires the corresponding specified temperature and reference image according to the module identifier included in the reference image acquisition request.

终端可重新安装摄像头模组,并在安装好摄像头模组之后,读取所安装的摄像头模组的模组标识。然后根据模组标识生成参考图像获取请求,并将该参考图像获取请求发送给服务器。具体的,终端发送参考图像获取请求时,可将其中包含的模组标识进行加密处理,再将加密后的参考图像获取请求发送给服务器。The terminal can reinstall the camera module, and after installing the camera module, read the module identification of the installed camera module. Then, a reference image acquisition request is generated according to the module identification, and the reference image acquisition request is sent to the server. Specifically, when the terminal sends the reference image acquisition request, the module identification contained therein can be encrypted, and then the encrypted reference image acquisition request can be sent to the server.

步骤704,将指定温度和参考图像发送至终端。Step 704: Send the designated temperature and the reference image to the terminal.

服务器在接收到参考图像获取请求之后,可以根据模组标识查找对应的指定温度和参考图像,并将指定温度和参考图像加密之后发送给终端。终端接收到指定温度和参考图像之后,进行解密处理。然后将解密处理后的指定温度和参考图像写入到终端中。具体的,对模组标识、指定温度和参考图像进行加密处理的算法不做限定。例如,可以是根据DES(Data Encryption Standard,数据加密标准)、MD5(Message-Digest Algorithm 5,信息-摘要算法5)、HAVAL(Diffie-Hellman,密钥交换算法)。After receiving the reference image acquisition request, the server can search for the corresponding specified temperature and reference image according to the module identifier, and send the specified temperature and reference image to the terminal after encryption. After receiving the specified temperature and reference image, the terminal performs decryption processing. Then the decrypted specified temperature and reference image are written to the terminal. Specifically, the algorithm for encrypting the module identifier, specified temperature and reference image is not limited. For example, it can be based on DES (Data Encryption Standard), MD5 (Message-Digest Algorithm 5), HAVAL (Diffie-Hellman, key exchange algorithm).

上述实施例提供的摄像头标定方法,可以控制摄像头模组的温度到达至少两个不同的指定温度,并控制摄像头模组采集在不同指定温度下所形成的参考图像,然后将参考图像与指定温度对应地进行存储。由于摄像头模组在不同的温度下会产生形变,同时温度本身也会对摄像头模组采集的图像产生影响,所以在摄像头标定的时候控制摄像头模组在不同的指定温度下采集图像。这样就可以根据摄像头模组的温度来获取对应的参考图像,并根据参考图像中的参考深度信息来计算物体的深度信息,避免摄像头模组的温度变化所带来的误差,提高了图像处理的准确性。The camera calibration method provided in the above embodiment can control the temperature of the camera module to reach at least two different specified temperatures, and control the camera module to collect reference images formed at different specified temperatures, and then store the reference images corresponding to the specified temperatures. Since the camera module will deform at different temperatures, and the temperature itself will also affect the image collected by the camera module, the camera module is controlled to collect images at different specified temperatures during camera calibration. In this way, the corresponding reference image can be obtained according to the temperature of the camera module, and the depth information of the object can be calculated according to the reference depth information in the reference image, thereby avoiding the error caused by the temperature change of the camera module and improving the accuracy of image processing.

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

图8为一个实施例中实现摄像头标定方法的硬件结构图。如图8所示,该电子设备中可包括摄像头模组810、中央处理器(CPU)820和第二处理单元830,上述摄像头模组810中包括激光摄像头812、泛光灯814、RGB(Red/Green/Blue,红/绿/蓝色彩模式)摄像头816和镭射灯818。第二处理单元830包括脉冲宽度调制模块832、SPI/I2C(Serial PeripheralInterface/Inter-Integrated Circuit,串行外设接口/双向二线制同步串行接口)模块834、RAM(Random Access Memory,随机存取存储器)模块836、Depth Engine模块838。其中,第一处理单元822可为处于TEE(Trusted execution environment,可信运行环境)下的CPU内核,第二处理单元830为MCU(Microcontroller Unit,微控制单元)处理器。可以理解的是,中央处理器820可以为多核运行模式,中央处理器820中的CPU内核可以在TEE或REE(Rich Execution Environment,自然运行环境)下运行。TEE和REE均为ARM模块(AdvancedRISC Machines,高级精简指令集处理器)的运行模式。通常情况下,电子设备中安全性较高的操作行为需要在TEE下执行,其他操作行为则可在REE下执行。FIG8 is a hardware structure diagram of a camera calibration method in one embodiment. As shown in FIG8 , the electronic device may include a camera module 810, a central processing unit (CPU) 820 and a second processing unit 830, wherein the camera module 810 includes a laser camera 812, a floodlight 814, an RGB (Red/Green/Blue, red/green/blue color mode) camera 816 and a laser light 818. The second processing unit 830 includes a pulse width modulation module 832, an SPI/I2C (Serial Peripheral Interface/Inter-Integrated Circuit, Serial Peripheral Interface/Bidirectional Two-Wire Synchronous Serial Interface) module 834, a RAM (Random Access Memory, Random Access Memory) module 836, and a Depth Engine module 838. Among them, the first processing unit 822 may be a CPU core in a TEE (Trusted execution environment), and the second processing unit 830 is an MCU (Microcontroller Unit) processor. It is understandable that the CPU 820 can be in a multi-core operation mode, and the CPU core in the CPU 820 can run in TEE or REE (Rich Execution Environment). Both TEE and REE are operation modes of ARM modules (Advanced RISC Machines). Generally, operations with higher security in electronic devices need to be executed under TEE, and other operations can be executed under REE.

在摄像头标定的过程中,可通过第二处理单元830中的脉冲宽度调制模块932控制镭射灯818到达至少两个不同的指定温度,并在到达不同的指定温度时,控制激光摄像头812采集镭射灯818照射参考平面时所形成的参考图像。采集到的参考图像和指定温度可以存储在处于可信运行环境(第一安全运行环境)中的第一处理单元822。当电子设备开机时,将指定温度和参考图像从第一处理单元822中加载到第二处理单元830进行存储。可以理解的是,第二处理单元830为外置与中央处理器820的处理单元,其输入和输出都是由处于可信运行环境中的第一处理单元822进行控制的,因此可认为第二处理单元830是处于第二安全运行环境中的。During the camera calibration process, the pulse width modulation module 932 in the second processing unit 830 can be used to control the laser lamp 818 to reach at least two different specified temperatures, and when reaching different specified temperatures, the laser camera 812 is controlled to collect the reference image formed when the laser lamp 818 illuminates the reference plane. The collected reference image and the specified temperature can be stored in the first processing unit 822 in the trusted operating environment (the first safe operating environment). When the electronic device is turned on, the specified temperature and the reference image are loaded from the first processing unit 822 to the second processing unit 830 for storage. It can be understood that the second processing unit 830 is a processing unit external to the central processing unit 820, and its input and output are controlled by the first processing unit 822 in the trusted operating environment, so it can be considered that the second processing unit 830 is in the second safe operating environment.

在测量深度信息的过程中,当中央处理器820接收到目标应用程序发起的图像采集指令,TEE下运行的CPU内核即第一处理单元822,会通过SECURE SPI/I2C向MCU830中SPI/I2C模块834发送图像采集指令至第二处理单元830。第二处理单元830在接收到图像采集指令后,通过脉冲宽度调制模块832发射脉冲波控制摄像头模组810中泛光灯814开启来采集红外图像、控制摄像头模组810中镭射灯818开启来采集散斑图像。摄像头模组810可将采集到的红外图像和散斑图像传送给第二处理单元830中Depth Engine模块838,Depth Engine模块838可根据红外图像计算红外视差图像,根据散斑图像和参考图像计算深度图像,并根据深度图像得到深度视差图像。然后将红外视差图像和深度视差图像发送给TEE下运行的第一处理单元822。第一处理单元822会根据红外视差图像进行校正得到校正红外图像,并根据深度视差图像进行校正得到校正深度图像。其中,激光摄像头812和RGB摄像头816因为安装的位置不同,所以在采集图像的时候,需要对两个摄像头采集的图像进行对齐校正,以避免拍摄角度带来的误差。也即需要将红外图像和深度图像进行校正,分别得到校正红外图像和校正深度图像。In the process of measuring depth information, when the central processor 820 receives an image acquisition instruction initiated by the target application, the CPU core running under the TEE, i.e., the first processing unit 822, sends the image acquisition instruction to the second processing unit 830 through the SECURE SPI/I2C to the SPI/I2C module 834 in the MCU830. After receiving the image acquisition instruction, the second processing unit 830 controls the floodlight 814 in the camera module 810 to turn on to collect infrared images and controls the laser light 818 in the camera module 810 to turn on to collect speckle images by emitting pulse waves through the pulse width modulation module 832. The camera module 810 can transmit the collected infrared image and speckle image to the Depth Engine module 838 in the second processing unit 830, and the Depth Engine module 838 can calculate the infrared parallax image according to the infrared image, calculate the depth image according to the speckle image and the reference image, and obtain the depth parallax image according to the depth image. Then, the infrared parallax image and the depth parallax image are sent to the first processing unit 822 running under the TEE. The first processing unit 822 will calibrate the infrared parallax image to obtain a calibrated infrared image, and calibrate the depth parallax image to obtain a calibrated depth image. Among them, because the laser camera 812 and the RGB camera 816 are installed in different positions, when collecting images, it is necessary to align and calibrate the images collected by the two cameras to avoid errors caused by shooting angles. That is, the infrared image and the depth image need to be calibrated to obtain a calibrated infrared image and a calibrated depth image, respectively.

在一个实施例中,可以根据校正红外图像进行人脸识别,检测上述校正红外图像中是否存在人脸以及检测到的人脸与存储的人脸是否匹配;若人脸识别通过,再根据上述校正红外图像和校正深度图像来进行活体检测,检测上述人脸是否为活体人脸。在获取到校正红外图像和校正深度图像后,可先进行活体检测再进行人脸识别,或同时进行人脸识别和活体检测。在人脸识别通过且检测到的人脸为活体人脸后,第一处理单元822可将上述校正红外图像、校正深度图像以及人脸识别结果中的一种或多种发送给目标应用程序。In one embodiment, face recognition can be performed based on the corrected infrared image to detect whether there is a face in the corrected infrared image and whether the detected face matches the stored face; if the face recognition is successful, liveness detection can be performed based on the corrected infrared image and the corrected depth image to detect whether the face is a live face. After obtaining the corrected infrared image and the corrected depth image, liveness detection can be performed first and then face recognition, or face recognition and liveness detection can be performed simultaneously. After face recognition is successful and the detected face is a live face, the first processing unit 822 can send one or more of the corrected infrared image, the corrected depth image, and the face recognition result to the target application.

图9为一个实施例中实现摄像头标定方法的交互图。如图9所示,该摄像头标定方法的交互过程可以包括步骤902至步骤920。其中:FIG9 is an interactive diagram of implementing a camera calibration method in an embodiment. As shown in FIG9 , the interactive process of the camera calibration method may include steps 902 to 920. Among them:

步骤902,标定设备控制摄像头模组的温度到达至少两个不同的指定温度。Step 902: The calibration device controls the temperature of the camera module to reach at least two different specified temperatures.

步骤904,标定设备控制摄像头采集光发射器在指定温度下照射参考平面时所形成的参考图像。Step 904: The calibration device controls the camera to collect a reference image formed when the light emitter illuminates the reference plane at a specified temperature.

步骤906,标定设备获取摄像头模组的模组标识,并建立模组标识、指定温度与参考图像的对应关系。Step 906: The calibration device obtains the module identification of the camera module and establishes a corresponding relationship between the module identification, the specified temperature and the reference image.

步骤908,标定设备发送模组标识、指定温度与参考图像给服务器。Step 908: The calibration device sends the module identification, the specified temperature and the reference image to the server.

步骤910,服务器接收并存储模组标识、指定温度与参考图像。Step 910: The server receives and stores the module identification, the specified temperature, and the reference image.

步骤912,终端安装摄像头模组,并获取安装的摄像头模组的模组标识,并根据模组标识生成图像获取请求。Step 912: The terminal installs a camera module, obtains a module identifier of the installed camera module, and generates an image acquisition request according to the module identifier.

步骤914,终端将生成的图像获取请求发送给服务器。Step 914: The terminal sends the generated image acquisition request to the server.

步骤916,服务器根据参考图像获取请求中包含的模组标识获取对应的指定温度和参考图像。Step 916: The server obtains the corresponding specified temperature and reference image according to the module identifier included in the reference image acquisition request.

步骤918,服务器将获取的指定温度与参考图像发送给终端。Step 918: The server sends the acquired designated temperature and reference image to the terminal.

步骤920,终端接收服务器发送的指定温度与参考图像,并将指定温度和参考图像写入到终端的安全运行环境中进行存储。Step 920: The terminal receives the designated temperature and the reference image sent by the server, and writes the designated temperature and the reference image into the secure operation environment of the terminal for storage.

上述实施例提供的摄像头标定装置,可以根据摄像头模组的温度来获取对应的参考图像,并根据参考图像中的参考深度信息来计算物体的深度信息,避免摄像头模组的温度变化所带来的误差,提高了图像处理的准确性。The camera calibration device provided in the above embodiment can obtain the corresponding reference image according to the temperature of the camera module, and calculate the depth information of the object according to the reference depth information in the reference image, thereby avoiding the error caused by the temperature change of the camera module and improving the accuracy of image processing.

图10为一个实施例中摄像头标定装置的结构示意图。如图10所示,该摄像头标定装置1000包括温度控制模块1002、图像获取模块1004和图像存储模块1006。其中:FIG10 is a schematic diagram of the structure of a camera calibration device in one embodiment. As shown in FIG10 , the camera calibration device 1000 includes a temperature control module 1002, an image acquisition module 1004 and an image storage module 1006. Among them:

温度控制模块1002,用于控制摄像头模组的温度到达至少两个不同的指定温度,其中所述摄像头模组中包括光发射器和摄像头。The temperature control module 1002 is used to control the temperature of the camera module to reach at least two different specified temperatures, wherein the camera module includes a light emitter and a camera.

图像获取模块1004,用于控制所述摄像头采集所述光发射器在所述指定温度下照射参考平面时所形成的参考图像。The image acquisition module 1004 is used to control the camera to collect the reference image formed when the light emitter illuminates the reference plane at the specified temperature.

图像存储模块1006,用于将所述指定温度与参考图像对应地进行存储;其中,所述参考图像带有参考深度信息,所述参考深度信息用于计算物体的深度信息。The image storage module 1006 is used to store the designated temperature and the reference image in correspondence; wherein the reference image carries reference depth information, and the reference depth information is used to calculate the depth information of the object.

上述实施例提供的摄像头标定装置,可以控制摄像头模组的温度到达至少两个不同的指定温度,并控制摄像头模组采集在不同指定温度下所形成的参考图像,然后将参考图像与指定温度对应地进行存储。由于摄像头模组在不同的温度下会产生形变,同时温度本身也会对摄像头模组采集的图像产生影响,所以在摄像头标定的时候控制摄像头模组在不同的指定温度下采集图像。这样就可以根据摄像头模组的温度来获取对应的参考图像,并根据参考图像中的参考深度信息来计算物体的深度信息,避免摄像头模组的温度变化所带来的误差,提高了图像处理的准确性。The camera calibration device provided in the above embodiment can control the temperature of the camera module to reach at least two different specified temperatures, and control the camera module to collect reference images formed at different specified temperatures, and then store the reference images corresponding to the specified temperatures. Since the camera module will deform at different temperatures, and the temperature itself will also affect the image collected by the camera module, the camera module is controlled to collect images at different specified temperatures during camera calibration. In this way, the corresponding reference image can be obtained according to the temperature of the camera module, and the depth information of the object can be calculated according to the reference depth information in the reference image, thereby avoiding the error caused by the temperature change of the camera module and improving the accuracy of image processing.

图11为另一个实施例中摄像头标定装置的结构示意图。如图11所示,该摄像头标定装置1100包括温度控制模块1102、图像获取模块1104、图像存储模块1106和深度计算模块1108。其中:FIG11 is a schematic diagram of the structure of a camera calibration device in another embodiment. As shown in FIG11 , the camera calibration device 1100 includes a temperature control module 1102, an image acquisition module 1104, an image storage module 1106 and a depth calculation module 1108. Among them:

温度控制模块1102,用于控制摄像头模组的温度到达至少两个不同的指定温度,其中所述摄像头模组中包括光发射器和摄像头。The temperature control module 1102 is used to control the temperature of the camera module to reach at least two different specified temperatures, wherein the camera module includes a light emitter and a camera.

图像获取模块1104,用于控制所述摄像头采集所述光发射器在所述指定温度下照射参考平面时所形成的参考图像。The image acquisition module 1104 is used to control the camera to collect the reference image formed when the light emitter illuminates the reference plane at the specified temperature.

图像存储模块1106,用于将所述指定温度与参考图像对应地进行存储;其中,所述参考图像带有参考深度信息,所述参考深度信息用于计算物体的深度信息。The image storage module 1106 is used to store the designated temperature and the reference image in correspondence; wherein the reference image carries reference depth information, and the reference depth information is used to calculate the depth information of the object.

深度计算模块1108,用于当检测到摄像头模组被打开时,控制所述摄像头模组采集散斑图像;当检测到所述光发射器的温度变化超过温度阈值时,获取所述光发射器的当前温度;根据所述光发射器的当前温度获取对应的目标参考图像,并根据所述散斑图像和目标参考图像计算深度图像,所述深度图像用于表示物体的深度信息。The depth calculation module 1108 is used to control the camera module to collect a speckle image when it is detected that the camera module is turned on; obtain the current temperature of the light emitter when it is detected that the temperature change of the light emitter exceeds the temperature threshold; obtain the corresponding target reference image according to the current temperature of the light emitter, and calculate a depth image according to the speckle image and the target reference image, wherein the depth image is used to represent the depth information of the object.

上述实施例提供的摄像头标定装置,可以根据摄像头模组的温度来获取对应的参考图像,并根据参考图像中的参考深度信息来计算物体的深度信息,避免摄像头模组的温度变化所带来的误差,提高了图像处理的准确性。The camera calibration device provided in the above embodiment can obtain the corresponding reference image according to the temperature of the camera module, and calculate the depth information of the object according to the reference depth information in the reference image, thereby avoiding the error caused by the temperature change of the camera module and improving the accuracy of image processing.

在一个实施例中,温度控制模块1102还用于向光发射器输入至少两个不同频率的脉冲宽度调制PWM,通过所述脉冲宽度调制PWM控制所述光发射器的温度到达至少两个不同的指定温度。In one embodiment, the temperature control module 1102 is further configured to input at least two pulse width modulation PWMs of different frequencies to the light emitter, and control the temperature of the light emitter to reach at least two different specified temperatures through the pulse width modulation PWM.

在一个实施例中,图像存储模块1106还用于建立所述指定温度和参考图像的对应关系,将所述指定温度和参考图像写入到终端的安全运行环境中进行存储。In one embodiment, the image storage module 1106 is further used to establish a corresponding relationship between the specified temperature and the reference image, and write the specified temperature and the reference image into the secure operation environment of the terminal for storage.

在一个实施例中,图像存储模块1106还用于将所述指定温度和参考图像写入到终端的第一安全运行环境中进行存储;当检测到所述终端开机时,将所述指定温度和参考图像从所述第一安全运行环境中加载到第二安全运行环境中进行存储。In one embodiment, the image storage module 1106 is also used to write the specified temperature and reference image into the first safe operating environment of the terminal for storage; when it is detected that the terminal is turned on, the specified temperature and reference image are loaded from the first safe operating environment to the second safe operating environment for storage.

在一个实施例中,图像存储模块1106还用于获取所述摄像头模组的模组标识,并建立所述模组标识、指定温度与参考图像的对应关系;将所述模组标识、指定温度与参考图像存储到服务器中。In one embodiment, the image storage module 1106 is also used to obtain the module identification of the camera module, and establish a corresponding relationship between the module identification, the specified temperature and the reference image; and store the module identification, the specified temperature and the reference image in the server.

在一个实施例中,图像存储模块1106还用于当所述服务器接收到终端发送的参考图像获取请求时,根据所述参考图像获取请求中包含的模组标识获取对应的指定温度和参考图像;将所述指定温度和参考图像发送至所述终端。In one embodiment, the image storage module 1106 is also used to obtain the corresponding specified temperature and reference image according to the module identifier contained in the reference image acquisition request when the server receives the reference image acquisition request sent by the terminal; and send the specified temperature and reference image to the terminal.

上述摄像头标定装置中各个模块的划分仅用于举例说明,在其他实施例中,可将摄像头标定装置按照需要划分为不同的模块,以完成上述摄像头标定装置的全部或部分功能。The division of the various modules in the above-mentioned camera calibration device is only for illustration. In other embodiments, the camera calibration device can be divided into different modules as needed to complete all or part of the functions of the above-mentioned camera calibration device.

本申请实施例还提供了一种计算机可读存储介质。一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行上述实施例提供的摄像头标定方法。The embodiment of the present application further 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, the processors execute the camera calibration method provided in the above embodiment.

一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例提供的摄像头标定方法。A computer program product comprising instructions, when running on a computer, enables the computer to execute the camera calibration method provided in the above embodiment.

本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。合适的非易失性存储器可包括只读存储器(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 medium used in this application may include non-volatile and/or volatile memory. Suitable 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 is used as an external cache memory. As an illustration and not 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 methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims (18)

1. An image processing method applied to an electronic device with a camera module, wherein the camera module comprises a light emitter and a camera, and the method is characterized by comprising the following steps:
receiving an image acquisition instruction;
controlling the camera module to acquire speckle images; the speckle image is an image formed by the light emitter irradiating an object;
Detecting the temperature of the light emitter and judging whether the temperature change of the light emitter exceeds a temperature threshold value;
when detecting that the temperature change of the light emitter exceeds a temperature threshold, acquiring the current temperature of the light emitter;
And acquiring a corresponding target reference image according to the current temperature of the light emitter, and calculating a depth image according to the speckle image and the target reference image, wherein the depth image is used for representing the depth information of the object.
2. The method of claim 1, wherein the acquiring the corresponding target reference image based on the current temperature of the light emitter comprises:
acquiring a corresponding target reference image from a safe operation environment of the terminal according to the current temperature of the light emitter;
the safe operation environment of the terminal stores the designated temperature and the corresponding reference image.
3. The method of claim 2, wherein the acquiring the corresponding target reference image from the secure operating environment of the terminal according to the current temperature of the light emitter comprises:
when the terminal is detected to be started, loading the designated temperature and the reference image into a second safe operation environment from a first safe operation environment for storage, and acquiring a corresponding target reference image from the second safe operation environment of the terminal according to the current temperature of the light emitter, wherein the storage space in the first safe operation environment is larger than the storage space in the second safe operation environment.
4. The method of claim 3, wherein the step of,
The receiving the image acquisition instruction comprises:
Transmitting the image acquisition instruction to a second processing unit in a second safe operation environment through a first processing unit in the first safe operation environment;
the computing a depth image from the speckle image and a target reference image comprises:
A second processing unit in the second secure operating environment calculates a depth image from the speckle image and a target reference image.
5. The method according to claim 4, wherein the method further comprises:
Controlling the camera module to acquire an infrared image, and sending the infrared image to a second processing unit, wherein the second processing unit calculates an infrared parallax image according to the infrared image;
Obtaining a depth parallax image according to the depth image;
and transmitting the infrared parallax image and the depth parallax image to the first processing unit, and correcting the infrared parallax image by the first processing unit to obtain a corrected infrared image and correcting the depth parallax image to obtain a corrected depth image.
6. The method of claim 5, wherein the method further comprises:
detecting whether a human face exists in the corrected infrared image or not and whether the detected human face is matched with a stored human face or not;
detecting whether the human face is a living human face according to the corrected infrared image and the corrected depth image;
After the face recognition is passed and the detected face is a living face, the first processing unit sends one or more of the corrected infrared image, the corrected depth image and the face recognition result to a target application program.
7. The method of claim 1, wherein the acquiring the corresponding target reference image based on the current temperature of the light emitter comprises:
sending a reference image acquisition request to a server, and acquiring a corresponding target reference image from the server according to the current temperature of the light emitter;
the server stores a module identifier, a designated temperature and a reference image of the camera module, and the module identifier, the designated temperature and the reference image establish a corresponding relation.
8. The method according to claim 1, wherein the method further comprises:
A reference image acquisition request is sent to a server, wherein the reference image acquisition request comprises a module identifier, the server stores the module identifier of the camera module, the designated temperature and the reference image, and the corresponding relation is established between the module identifier, the designated temperature and the reference image;
and receiving and storing the designated temperature and the reference image sent by the server.
9. A method of camera calibration, the method comprising:
Controlling the temperature of the camera module to reach at least two different designated temperatures, wherein the camera module comprises a light emitter and a camera;
controlling the camera to acquire a reference image formed when the light emitter irradiates a reference plane at the specified temperature;
Establishing a corresponding relation between the specified temperature and the reference image, and writing the specified temperature and the reference image into a safe operation environment of the terminal for storage; wherein the reference image carries reference depth information, which is used to calculate depth information of the object.
10. The method of claim 9, wherein controlling the temperature of the camera module to reach at least two different specified temperatures comprises:
At least two Pulse Width Modulation (PWM) of different frequencies are input to the light emitter, and the temperature of the light emitter is controlled to reach at least two different designated temperatures through the PWM.
11. The method of claim 9, wherein writing the specified temperature and reference image into a secure operating environment of a terminal for storage comprises:
writing the designated temperature and the reference image into a first safe operation environment of the terminal for storage;
and when the terminal is detected to be started, loading the designated temperature and the reference image from the first safe operation environment into a second safe operation environment for storage.
12. The method of claim 9, wherein storing the specified temperature in correspondence with a reference image comprises:
acquiring a module identifier of the camera module, and establishing a corresponding relation between the module identifier, the designated temperature and a reference image;
and storing the module identification, the designated temperature and the reference image into a server.
13. The method of claim 12, wherein after storing the module identification, the specified temperature, and the reference image in a server, further comprising:
when the server receives a reference image acquisition request sent by a terminal, acquiring a corresponding designated temperature and a reference image according to a module identifier contained in the reference image acquisition request;
And sending the designated temperature and the reference image to the terminal.
14. An image processing apparatus for use in an electronic device having a camera module including a light emitter and a camera, the apparatus comprising:
The instruction receiving module is used for receiving an image acquisition instruction;
The temperature detection module is used for detecting the temperature of the light emitter and judging whether the temperature change of the light emitter exceeds a temperature threshold value or not;
The depth calculation module is used for controlling the camera module to acquire speckle images; the speckle image is an image formed by the light emitter irradiating an object;
When detecting that the temperature change of the light emitter exceeds a temperature threshold, acquiring the current temperature of the light emitter; and acquiring a corresponding target reference image according to the current temperature of the light emitter, and calculating a depth image according to the speckle image and the target reference image, wherein the depth image is used for representing the depth information of the object.
15. A camera calibration apparatus, the apparatus comprising:
the temperature control module is used for controlling the temperature of the camera module to reach at least two different specified temperatures, wherein the camera module comprises a light emitter and a camera;
the image acquisition module is used for controlling the camera to acquire a reference image formed when the light emitter irradiates a reference plane at the specified temperature;
The image storage module is used for establishing a corresponding relation between the specified temperature and the reference image, and writing the specified temperature and the reference image into a safe operation environment of the terminal for storage; wherein the reference image carries reference depth information, which is used to calculate depth information of the object.
16. A computer readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the method of any one of claims 1 to 13.
17. An electronic device comprising a memory and a processor, the memory having stored therein computer readable instructions that, when executed by the processor, cause the processor to perform the method of any of claims 1-13.
18. A computer program product comprising instructions which, when run on a computer, cause the computer to perform the steps of the method according to any one of claims 1 to 13.
CN202011602675.5A 2018-06-28 2018-06-28 Image processing method, camera calibration method, device, storage medium and electronic device Active CN112802116B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011602675.5A CN112802116B (en) 2018-06-28 2018-06-28 Image processing method, camera calibration method, device, storage medium and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810690949.7A CN108921903B (en) 2018-06-28 2018-06-28 Camera calibration method, apparatus, computer-readable storage medium and electronic device
CN202011602675.5A CN112802116B (en) 2018-06-28 2018-06-28 Image processing method, camera calibration method, device, storage medium and electronic device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201810690949.7A Division CN108921903B (en) 2018-04-28 2018-06-28 Camera calibration method, apparatus, computer-readable storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN112802116A CN112802116A (en) 2021-05-14
CN112802116B true CN112802116B (en) 2024-08-27

Family

ID=64423398

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202011602675.5A Active CN112802116B (en) 2018-06-28 2018-06-28 Image processing method, camera calibration method, device, storage medium and electronic device
CN201810690949.7A Expired - Fee Related CN108921903B (en) 2018-04-28 2018-06-28 Camera calibration method, apparatus, computer-readable storage medium and electronic device

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN201810690949.7A Expired - Fee Related CN108921903B (en) 2018-04-28 2018-06-28 Camera calibration method, apparatus, computer-readable storage medium and electronic device

Country Status (1)

Country Link
CN (2) CN112802116B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019205890A1 (en) * 2018-04-28 2019-10-31 Oppo广东移动通信有限公司 Image processing method, apparatus, computer-readable storage medium, and electronic device
CN111381222B (en) * 2018-12-27 2024-08-06 浙江舜宇智能光学技术有限公司 Temperature calibration equipment and method for TOF (time of flight) camera module
CN109903345B (en) * 2019-04-09 2023-04-25 歌尔光学科技有限公司 Depth module calibration method, calibration device and computer-readable storage medium
CN110136209B (en) * 2019-05-21 2021-04-20 Oppo广东移动通信有限公司 A camera calibration method, device and computer-readable storage medium
CN110599550A (en) * 2019-09-09 2019-12-20 香港光云科技有限公司 Calibration system of RGB-D module and equipment and method thereof
CN110827363A (en) * 2019-11-08 2020-02-21 深圳深岚视觉科技有限公司 Data processing method, data processing device, computer equipment and storage medium
CN115103047A (en) * 2022-06-20 2022-09-23 无锡英菲感知技术有限公司 Imaging module calibration system, method, control end and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107657635A (en) * 2017-10-17 2018-02-02 深圳奥比中光科技有限公司 The bearing calibration of depth camera temperature error and system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105141939B (en) * 2015-08-18 2017-05-17 宁波盈芯信息科技有限公司 Three-dimensional depth perception method and three-dimensional depth perception device based on adjustable working range
CN105120257B (en) * 2015-08-18 2017-12-15 宁波盈芯信息科技有限公司 A kind of vertical depth sensing device based on structure light coding
US10089738B2 (en) * 2016-08-30 2018-10-02 Microsoft Technology Licensing, Llc Temperature compensation for structured light depth imaging system
CN107659985B (en) * 2017-08-09 2021-03-09 Oppo广东移动通信有限公司 Method and device for reducing power consumption of mobile terminal, storage medium and mobile terminal
CN108073891A (en) * 2017-11-10 2018-05-25 广东日月潭电源科技有限公司 A kind of 3 D intelligent face identification system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107657635A (en) * 2017-10-17 2018-02-02 深圳奥比中光科技有限公司 The bearing calibration of depth camera temperature error and system

Also Published As

Publication number Publication date
CN112802116A (en) 2021-05-14
CN108921903A (en) 2018-11-30
CN108921903B (en) 2021-01-15

Similar Documents

Publication Publication Date Title
CN112802116B (en) Image processing method, camera calibration method, device, storage medium and electronic device
US11146735B2 (en) Image processing methods and apparatuses, computer readable storage media, and electronic devices
CN108668078B (en) Image processing method, image processing device, computer-readable storage medium and electronic equipment
CN108764052B (en) Image processing method, apparatus, computer-readable storage medium and electronic device
CN108805024B (en) Image processing method, apparatus, computer-readable storage medium and electronic device
CN108804895B (en) Image processing method, apparatus, computer-readable storage medium and electronic device
CN107368730B (en) Unlock verification method and device
US11256903B2 (en) Image processing method, image processing device, computer readable storage medium and electronic device
EP3624006B1 (en) Image processing method, apparatus, computer-readable storage medium, and electronic device
CN108711054B (en) Image processing method, image processing device, computer-readable storage medium and electronic equipment
WO2019196684A1 (en) Data transmission method and apparatus, computer readable storage medium, electronic device, and mobile terminal
CN108830141A (en) Image processing method, device, computer-readable storage medium, and electronic device
EP3621294B1 (en) Method and device for image capture, computer readable storage medium and electronic device
WO2019196669A1 (en) Laser-based security verification method and apparatus, and terminal device
WO2019205889A1 (en) Image processing method, apparatus, computer-readable storage medium, and electronic device
CN108881712B (en) Image processing method, image processing device, computer-readable storage medium and electronic equipment
HK40024501B (en) Image processing method, apparatus and computer-readable storage medium
HK40024501A (en) Image processing method, apparatus and computer-readable storage medium
HK40023770B (en) Image processing method, apparatus, computer-readable storage medium, and electronic device
HK40023770A (en) Image processing method, apparatus, computer-readable storage medium, and electronic device
HK40024589A (en) Method and device for image processing, computer-readable storage medium, and electronic device
HK40022801B (en) Image processing method, apparatus, computer-readable storage medium, and electronic device
HK40024500B (en) Method and device for image capture, computer readable storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant