CN114882343A - Slope detection method, robot and storage medium - Google Patents

Slope detection method, robot and storage medium Download PDF

Info

Publication number
CN114882343A
CN114882343A CN202210600378.XA CN202210600378A CN114882343A CN 114882343 A CN114882343 A CN 114882343A CN 202210600378 A CN202210600378 A CN 202210600378A CN 114882343 A CN114882343 A CN 114882343A
Authority
CN
China
Prior art keywords
slope
pixel
pixel point
value
point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210600378.XA
Other languages
Chinese (zh)
Other versions
CN114882343B (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.)
Shenzhen Ubtech Technology Co ltd
Original Assignee
Shenzhen Ubtech Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Ubtech Technology Co ltd filed Critical Shenzhen Ubtech Technology Co ltd
Priority to CN202210600378.XA priority Critical patent/CN114882343B/en
Publication of CN114882343A publication Critical patent/CN114882343A/en
Application granted granted Critical
Publication of CN114882343B publication Critical patent/CN114882343B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/10Image acquisition
    • G06V10/12Details of acquisition arrangements; Constructional details thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Multimedia (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Molecular Biology (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Databases & Information Systems (AREA)
  • Medical Informatics (AREA)
  • Image Analysis (AREA)

Abstract

本申请适用于数据处理技术领域,提供了一种斜坡检测方法、机器人及存储介质,该方法包括:通过深度相机采集深度图像,将深度图像转换成点云数据,根据点云数据得到深度图像对应的第一灰度图像,利用第一灰度图像中第一像素点的灰度值,得到第一像素点的梯度值,然后使用第一像素点的梯度值得到关键像素点,利用关键像素点进行漫水填充,确定地面的斜坡区域。本申请使用深度相机采集的深度图像确定斜坡区域,深度相机采集的区域面积大,且深度相机的分辨率高,相对于现有技术中使用激光雷达确定地面的斜坡区域,本申请可以更快速、更准确的确定地面的斜坡区域。

Figure 202210600378

The present application is applicable to the technical field of data processing, and provides a slope detection method, a robot and a storage medium. The method includes: collecting a depth image through a depth camera, converting the depth image into point cloud data, and obtaining a corresponding depth image according to the point cloud data. The first grayscale image of the first grayscale image is obtained by using the grayscale value of the first pixel in the first grayscale image to obtain the gradient value of the first pixel. Flood fill is done to determine the sloped area of the ground. The present application uses the depth image collected by the depth camera to determine the slope area. The area collected by the depth camera is large, and the resolution of the depth camera is high. Compared with the use of laser radar to determine the slope area on the ground in the prior art, the present application can be faster and more efficient. More accurate determination of sloped areas of the ground.

Figure 202210600378

Description

一种斜坡检测方法、机器人及存储介质A slope detection method, robot and storage medium

技术领域technical field

本申请属于数据处理技术领域,尤其涉及一种斜坡检测方法、机器人及存储介质。The present application belongs to the technical field of data processing, and in particular, relates to a slope detection method, a robot and a storage medium.

背景技术Background technique

随着机器人的发展,机器人已经能够自主的运动和导航。机器人自主导航的关键在于对地面的检测,通过对地面的检测识别地面中的不可行区域,例如障碍物、悬崖等,根据不可行区域规划机器人的运动路线。With the development of robots, robots have been able to move and navigate autonomously. The key to autonomous navigation of robots lies in the detection of the ground. Through the detection of the ground, infeasible areas on the ground, such as obstacles, cliffs, etc., are identified, and the movement route of the robot is planned according to the infeasible areas.

目前,对地面检测多停留确定地面是否存在障碍物或悬崖,缺少对地面斜坡区域的检测,机器人对外界环境的感知能力不足。At present, the detection of the ground is mostly stopped to determine whether there are obstacles or cliffs on the ground, and the detection of the slope area on the ground is lacking, and the robot's ability to perceive the external environment is insufficient.

发明内容SUMMARY OF THE INVENTION

本申请实施例提供了一种斜坡检测方法、机器人及存储介质,可以解决由于无法检测地面的斜坡区域,导致机器人对外界环境的感知能力不足的问题。The embodiments of the present application provide a slope detection method, a robot, and a storage medium, which can solve the problem that the robot cannot perceive the external environment due to the inability to detect the slope area on the ground.

第一方面,本申请实施例提供了一种斜坡检测方法,包括:In a first aspect, an embodiment of the present application provides a slope detection method, including:

获取深度相机采集的深度图像的第一灰度图像,所述深度图像中包括地面;acquiring a first grayscale image of a depth image collected by a depth camera, where the depth image includes the ground;

基于所述第一灰度图像中第一像素点的灰度值,计算所述第一像素点的梯度值,所述第一像素点的数量为多个;Calculate the gradient value of the first pixel point based on the grayscale value of the first pixel point in the first grayscale image, and the number of the first pixel point is multiple;

基于所述第一像素点的梯度值,从所述第一像素点中确定关键像素点;determining a key pixel point from the first pixel point based on the gradient value of the first pixel point;

基于所述关键像素点的灰度值和第二像素点的灰度值,确定所述第一灰度图像中的斜坡区域,其中,所述第二像素点为所述第一灰度图像中除所述关键像素点之外的第一像素点,所述第一灰度图像中的斜坡区域用于确定所述地面的斜坡区域。Determine the slope area in the first grayscale image based on the grayscale value of the key pixel point and the grayscale value of the second pixel point, wherein the second pixel point is in the first grayscale image For the first pixel points other than the key pixel points, the slope area in the first grayscale image is used to determine the slope area of the ground.

第二方面,本申请实施例提供了一种斜坡检测装置,包括:In a second aspect, an embodiment of the present application provides a slope detection device, including:

图像获取模块,用于获取深度相机采集的深度图像的第一灰度图像,所述深度图像中包括地面;an image acquisition module, configured to acquire a first grayscale image of a depth image collected by a depth camera, where the depth image includes the ground;

梯度计算模块,用于基于所述第一灰度图像中第一像素点的灰度值,计算所述第一像素点的梯度值,所述第一像素点的数量为多个;a gradient calculation module, configured to calculate the gradient value of the first pixel point based on the grayscale value of the first pixel point in the first grayscale image, and the number of the first pixel point is multiple;

关键点确定模块,用于基于所述第一像素点的梯度值,从所述第一像素点中确定关键像素点;a key point determination module, configured to determine a key pixel point from the first pixel point based on the gradient value of the first pixel point;

斜坡检测模块,用于基于所述关键像素点的灰度值和第二像素点的灰度值,确定所述第一灰度图像中的斜坡区域,其中,所述第二像素点为所述第一灰度图像中除所述关键像素点之外的第一像素点,所述第一灰度图像中的斜坡区域用于确定所述地面的斜坡区域。a slope detection module, configured to determine a slope area in the first grayscale image based on the grayscale value of the key pixel point and the grayscale value of the second pixel point, wherein the second pixel point is the The first pixel points other than the key pixel points in the first grayscale image, and the slope area in the first grayscale image is used to determine the slope area of the ground.

第三方面,本申请实施例提供了一种终端设备,包括:存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述第一方面中任一项所述的斜坡检测方法。In a third aspect, an embodiment of the present application provides a terminal device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program When implementing the slope detection method according to any one of the first aspect above.

第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述第一方面中任一项所述的斜坡检测方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, implements any one of the above-mentioned first aspect the slope detection method.

第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在终端设备上运行时,使得终端设备执行上述第一方面中任一项所述的斜坡检测方法。In a fifth aspect, an embodiment of the present application provides a computer program product that, when the computer program product runs on a terminal device, enables the terminal device to execute the slope detection method described in any one of the first aspects above.

本申请第一方面实施例与现有技术相比存在的有益效果是:本申请使用深度相机采集的深度图像的第一灰度图像中第一像素点的灰度值,得到第一像素点的梯度值,然后使用第一像素点的梯度值得到关键像素点,利用关键像素点的灰度值和其他像素点的灰度值确定第一灰度图像中的斜坡区域,进而确定地面的斜坡区域。相对于现有技术不能检测地面的斜坡区域,本申请使用深度相机采集的深度图像确定斜坡区域,深度相机采集的区域面积大,且深度相机的分辨率高,本申请可以更快速、更准确的确定地面的斜坡区域,提高机器人对外界环境的感知能力。Compared with the prior art, the embodiment of the first aspect of the present application has the following beneficial effects: the present application uses the gray value of the first pixel in the first gray image of the depth image collected by the depth camera to obtain the gray value of the first pixel. Gradient value, and then use the gradient value of the first pixel point to obtain the key pixel point, use the gray value of the key pixel point and the gray value of other pixel points to determine the slope area in the first grayscale image, and then determine the slope area of the ground . Compared with the prior art that cannot detect the slope area on the ground, the present application uses the depth image collected by the depth camera to determine the slope area. The area collected by the depth camera is large, and the resolution of the depth camera is high. Determine the slope area of the ground to improve the robot's ability to perceive the external environment.

可以理解的是,上述第二方面至第五方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。It can be understood that, for the beneficial effects of the second aspect to the fifth aspect, reference may be made to the relevant description in the first aspect, which is not repeated here.

附图说明Description of drawings

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

图1是本申请一实施例提供的斜坡检测方法的应用场景示意图;1 is a schematic diagram of an application scenario of a slope detection method provided by an embodiment of the present application;

图2是本申请一实施例提供的斜坡检测方法的流程示意图;2 is a schematic flowchart of a slope detection method provided by an embodiment of the present application;

图3是本申请一实施例提供的第一灰度图像的确定方法的流程示意图;3 is a schematic flowchart of a method for determining a first grayscale image provided by an embodiment of the present application;

图4是本申请一实施例提供的关键像素点的确定方法的流程示意图;4 is a schematic flowchart of a method for determining a key pixel point provided by an embodiment of the present application;

图5是本申请一实施例提供的像素点的斜坡角度的确定方法的流程示意图;5 is a schematic flowchart of a method for determining a slope angle of a pixel point provided by an embodiment of the present application;

图6是本申请一实施例提供的斜坡检测装置的结构示意图;6 is a schematic structural diagram of a slope detection device provided by an embodiment of the present application;

图7是本申请一实施例提供的终端设备的结构示意图。FIG. 7 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.

具体实施方式Detailed ways

应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It is to be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described feature, integer, step, operation, element and/or component, but does not exclude one or more other The presence or addition of features, integers, steps, operations, elements, components and/or sets thereof.

还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It will also be understood that, as used in this specification and the appended claims, the term "and/or" refers to and including any and all possible combinations of one or more of the associated listed items.

另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, in the description of the specification of the present application and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and should not be construed as indicating or implying relative importance.

在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。References in this specification to "one embodiment" or "some embodiments" and the like mean that a particular feature, structure or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in other embodiments," etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean "one or more but not all embodiments" unless specifically emphasized otherwise.

目前,利用激光雷达或RGB相机进行地面检测时,可以达到地面检测的效果。本申请提供的斜坡检测方法,利用深度相机采集的深度图像确定地面的斜坡区域,由于深度图像中包括距离和空间信息,因此,使用深度相机检测地面的斜坡时,不仅可以确定地面上的斜坡区域,还可以确定斜坡的角度、斜坡类型等。另外,深度相机相对于激光雷达价格便宜,因此,使用深度相机进行路面检测,相对于使用激光雷达进行路面检测可以节约成本。At present, when using lidar or RGB camera for ground detection, the effect of ground detection can be achieved. The slope detection method provided by the present application uses the depth image collected by the depth camera to determine the slope area on the ground. Since the depth image includes distance and spatial information, when using the depth camera to detect the slope on the ground, not only can the slope area on the ground be determined , you can also determine the angle of the slope, the type of slope, etc. In addition, depth cameras are cheaper than lidars. Therefore, using depth cameras for road detection can save costs compared to using lidars for road detection.

图1为本申请实施例提供的斜坡检测方法的应用场景示意图,上述斜坡检测方法可以用于检测地面的斜坡区域。其中,深度相机10用于采集地面的深度图像。数据处理设备20用于获取深度相机10采集的深度图像,并根据深度图像输出深度图像中的斜坡区域。FIG. 1 is a schematic diagram of an application scenario of a slope detection method provided by an embodiment of the present application, and the above slope detection method can be used to detect a slope area on the ground. Among them, the depth camera 10 is used to collect depth images of the ground. The data processing device 20 is used for acquiring the depth image collected by the depth camera 10, and outputting the slope area in the depth image according to the depth image.

图2示出了本申请提供的斜坡检测方法的示意性流程图,参照图2,对该方法的详述如下:FIG. 2 shows a schematic flowchart of the slope detection method provided by the present application. Referring to FIG. 2 , the method is described in detail as follows:

S101,获取深度相机采集的深度图像的第一灰度图像,所述深度图像中包括地面。S101: Acquire a first grayscale image of a depth image collected by a depth camera, where the depth image includes the ground.

在本实施例中,深度相机为可以进行深度测量的相机。深度相机可以为安装在机器人上的深度相机;深度相机还可以为安装在固定区域内的深度相机。深度相机的安装角度以采集到地面的图像为依据。例如,机器人上的深度相机可以采集到机器人前方地面的信息,机器人前方为机器人的移动方向。In this embodiment, the depth camera is a camera that can perform depth measurement. The depth camera may be a depth camera installed on the robot; the depth camera may also be a depth camera installed in a fixed area. The installation angle of the depth camera is based on the images collected on the ground. For example, the depth camera on the robot can collect information on the ground in front of the robot, and the front of the robot is the moving direction of the robot.

深度图像也被称为距离影像,是指将深度相机采集到的场景中各点的距离(深度)值作为像素值的图像,它直接反映了景物可见表面的几何形状。A depth image, also known as a range image, refers to an image that uses the distance (depth) values of each point in the scene captured by the depth camera as the pixel value, which directly reflects the geometry of the visible surface of the scene.

灰度图像又称灰阶图,把白色与黑色之间按对数关系分为若干等级,称为灰度。Grayscale image, also known as grayscale image, divides white and black into several levels according to the logarithmic relationship, which is called grayscale.

在本实施例中,第一灰度图像中像素点的灰度值基于深度图像中像素点的像素值(深度)确定。In this embodiment, the grayscale value of the pixel point in the first grayscale image is determined based on the pixel value (depth) of the pixel point in the depth image.

S102,基于所述第一灰度图像中第一像素点的灰度值,计算所述第一像素点的梯度值,所述第一像素点的数量为多个。S102: Calculate the gradient value of the first pixel point based on the grayscale value of the first pixel point in the first grayscale image, where the number of the first pixel point is multiple.

在本实施例中,第一灰度图像中每个像素点可以对应一个灰度值。第一像素点可以包括第一灰度图像中各个像素点,还可以将第一灰度图像中一区域内的像素点记为第一像素点,该区域包括地面,例如,若第一灰度图中包括椅子,将除椅子区域以外的区域中的像素点记为第一像素点。In this embodiment, each pixel in the first grayscale image may correspond to one grayscale value. The first pixel point may include each pixel point in the first grayscale image, and a pixel point in an area in the first grayscale image may be recorded as the first pixel point, and the area includes the ground. For example, if the first grayscale image The figure includes a chair, and the pixels in the area other than the chair area are recorded as the first pixel.

在本实施例中,第一像素点的梯度值可以包括一阶梯度值和二阶梯度值。In this embodiment, the gradient value of the first pixel point may include a first-order gradient value and a second-order gradient value.

计算第一灰度图像的一阶导数,得到第一像素点的一阶梯度值。对一阶梯度值计算导数,得到第一像素点的二阶梯度值。Calculate the first-order derivative of the first grayscale image to obtain the first-order gradient value of the first pixel. Calculate the derivative of the first-order gradient value to obtain the second-order gradient value of the first pixel point.

具体的,建立第一灰度图像所在的坐标系,例如,以第一灰度图的左下角为原点、第一灰度图像穿过原点的两条边为x轴和y轴建立坐标系。计算第一像素点在x轴方向上的一阶梯度、在y轴上的一阶梯度,得到第一像素点的一阶梯度值,进而得到第一灰度图像的一阶梯度图。对一阶梯度图计算梯度,得到第一灰度图像的二阶梯度图。Specifically, the coordinate system where the first grayscale image is located is established, for example, the coordinate system is established with the lower left corner of the first grayscale image as the origin and the two sides of the first grayscale image passing through the origin as the x-axis and the y-axis. Calculate the first-order gradient of the first pixel in the x-axis direction and the first-order gradient on the y-axis to obtain the first-order gradient value of the first pixel, and then obtain the first-order gradient map of the first grayscale image. The gradient is calculated for the first-order gradient map to obtain the second-order gradient map of the first grayscale image.

具体的,将一阶梯度图中大于或等于第一阈值的第一像素点的值设为第一值(例如,255),其他第一像素点的值设为第二值(例如,0),得到第一二值图。第一阈值可以根据需要进行设置。Specifically, the value of the first pixel in the first-order gradient graph that is greater than or equal to the first threshold is set to the first value (for example, 255), and the values of other first pixels are set to the second value (for example, 0). , to get the first binary image. The first threshold can be set as required.

将二阶梯度图中小于或等于第二阈值的第一像素点的值设为第一值,其他第一像素点的值设为第二值,得到第二二值图。第二阈值可以根据需要进行设置。The value of the first pixel point in the second-order gradient graph that is less than or equal to the second threshold is set as the first value, and the values of other first pixel points are set as the second value to obtain a second binary image. The second threshold can be set as required.

在第一灰度图像中,将在第一二值图中为第一值、且在第二二值图中也是第一值的第一像素点记为第三像素点,将第三像素点的值设为第一值,其他第一像素点的值设为第二值,得到第三二值图。In the first grayscale image, the first pixel that has the first value in the first binary image and is also the first value in the second binary image is denoted as the third pixel, and the third pixel is denoted as the third pixel. The value of is set to the first value, and the values of the other first pixels are set to the second value to obtain the third binary image.

S103,基于所述第一像素点的梯度值,从所述第一像素点中确定关键像素点。S103: Determine a key pixel point from the first pixel point based on the gradient value of the first pixel point.

在本实施例中,将标注有第一像素点的梯度值的图像输入至关键点提取模型中,得到第一像素点中的关键像素点。关键点提取模型可以为卷积神经网络模型、全连接神经网络等。In this embodiment, the image marked with the gradient value of the first pixel is input into the key point extraction model to obtain the key pixel in the first pixel. The key point extraction model can be a convolutional neural network model, a fully connected neural network, or the like.

关键像素点的个数为一个或多个。The number of key pixel points is one or more.

S104,基于所述关键像素点的灰度值和第二像素点的灰度值,确定所述第一灰度图像中的斜坡区域,其中,所述第二像素点为所述第一灰度图像中除所述关键像素点之外的第一像素点。S104: Determine a slope area in the first grayscale image based on the grayscale value of the key pixel and the grayscale value of a second pixel, where the second pixel is the first grayscale The first pixel in the image other than the key pixel.

在本实施例中,第一灰度图像中的斜坡区域用于确定所述地面的斜坡区域。In this embodiment, the slope area in the first grayscale image is used to determine the slope area of the ground.

在本实施例中,每个关键像素点为一个种子点,利用漫水填充方法,计算每个关键像素点对应的斜坡区域。In this embodiment, each key pixel point is a seed point, and the slope area corresponding to each key pixel point is calculated by using the flood filling method.

本申请实施例中,使用深度相机采集的深度图像的第一灰度图像中第一像素点的灰度值,得到第一像素点的梯度值,然后使用第一像素点的梯度值得到关键像素点,利用关键像素点的灰度值和其他像素点的灰度值确定第一灰度图像中的斜坡区域,进而确定地面的斜坡区域。本申请使用深度相机采集的深度图像确定斜坡区域,深度相机采集的区域面积大,例如,深度相机可以达到480线,且深度相机的分辨率高,相对于现有技术中使用激光雷达(64线)确定地面的斜坡区域,本申请可以更快速、更准确的确定地面的斜坡区域,本申请使用深度相机检测地面的斜坡区域,相对于使用激光雷达检测斜坡区域减少了使用成本。另外,利用深度相机检测地面,对硬件要求不高,例如,对中央处理器(centralprocessing unit,CPU)和内存占用都不高,可以选择低算力的硬件,减少了资源消耗。深度相机对安装角度、位置和高度等没有严格的限制,安装简单。在机器人上使用深度相机确定地面的斜坡区域,提高机器人对环境的感知能力,可以保证机器人的运动安全。In the embodiment of the present application, the gray value of the first pixel in the first gray image of the depth image collected by the depth camera is used to obtain the gradient value of the first pixel, and then the gradient value of the first pixel is used to obtain the key pixel point, and use the gray value of the key pixel point and the gray value of other pixel points to determine the slope area in the first grayscale image, and then determine the slope area of the ground. In this application, the depth image collected by the depth camera is used to determine the slope area. The area collected by the depth camera is large, for example, the depth camera can reach 480 lines, and the resolution of the depth camera is high. ) to determine the slope area of the ground, the present application can determine the slope area of the ground more quickly and accurately, and the application uses a depth camera to detect the slope area of the ground, which reduces the use cost compared to the use of lidar to detect the slope area. In addition, using the depth camera to detect the ground does not require high hardware. For example, the central processing unit (CPU) and memory usage are not high, and hardware with low computing power can be selected to reduce resource consumption. The depth camera has no strict restrictions on the installation angle, position and height, and the installation is simple. Using the depth camera on the robot to determine the slope area of the ground can improve the robot's ability to perceive the environment and ensure the safety of the robot's movement.

如图3所示,在一种可能的实现方式中,步骤S101的实现过程可以包括:As shown in FIG. 3, in a possible implementation manner, the implementation process of step S101 may include:

S1011,将所述深度图像转换为相机坐标系下的第一点云数据,所述相机坐标系为基于所述深度相机的位姿确定的坐标系。S1011. Convert the depth image into first point cloud data in a camera coordinate system, where the camera coordinate system is a coordinate system determined based on the pose of the depth camera.

在本实施例中,对深度图像中的数据进行降维处理,得到相机坐标系下的第一点云数据。相机坐标系包括x轴、y轴和z轴,x轴和y轴表征像素点的坐标,z轴为像素点的像素值(深度)。将深度图像转换为相机坐标系下的点云数据是为了将深度图像转换为标准坐标系下的点云数据做准备。In this embodiment, dimensionality reduction processing is performed on the data in the depth image to obtain the first point cloud data in the camera coordinate system. The camera coordinate system includes an x-axis, a y-axis and a z-axis. The x-axis and the y-axis represent the coordinates of the pixel point, and the z-axis is the pixel value (depth) of the pixel point. Converting the depth image to point cloud data in the camera coordinate system is to prepare for converting the depth image to point cloud data in the standard coordinate system.

S1012,将所述第一点云数据转换为标准坐标系下的第二点云数据,所述标准坐标系为基于水平面确定的世界坐标系。S1012: Convert the first point cloud data into second point cloud data in a standard coordinate system, where the standard coordinate system is a world coordinate system determined based on a horizontal plane.

在本实施例中,将第一点云数据进行坐标转换,得到第二点云数据。标准坐标系的x轴和y轴平行于水平面、且相互垂直;标准坐标系中的z轴垂直于x轴和y轴。第二点云数据包括x轴数据、y轴数据和z轴数据。In this embodiment, coordinate transformation is performed on the first point cloud data to obtain the second point cloud data. The x-axis and the y-axis of the standard coordinate system are parallel to the horizontal plane and perpendicular to each other; the z-axis in the standard coordinate system is perpendicular to the x-axis and the y-axis. The second point cloud data includes x-axis data, y-axis data, and z-axis data.

S1013,对所述第二点云数据中的高度值进行归一化处理,得到归一化处理后的高度值,所述高度值用于表征所述地面高出所述标准坐标系的原点的程度。S1013, normalize the height value in the second point cloud data to obtain a normalized height value, where the height value is used to indicate that the ground is higher than the origin of the standard coordinate system degree.

在本实施例中,对第二点云数据中的高度值(z轴数据)进行归一化处理,例如,归一化到[-0.42m,0.22m]区间内,得到归一化处理后的高度值,以使得数据处理简单、快速。In this embodiment, the height value (z-axis data) in the second point cloud data is normalized, for example, normalized to the interval [-0.42m, 0.22m], and the normalized value is obtained. The height value to make data processing simple and fast.

S1014,基于所述归一化处理后的高度值,得到所述深度图像的第一灰度图像。S1014, obtaining a first grayscale image of the depth image based on the normalized height value.

在本实施例中,将归一化处理后的高度值转化到灰度图数据(0-255)之间,得到第二灰度图像。对第二灰度图像进行中值滤波处理和降维处理,得到第一灰度图像。In this embodiment, the normalized height value is converted into grayscale image data (0-255) to obtain a second grayscale image. Perform median filter processing and dimension reduction processing on the second grayscale image to obtain a first grayscale image.

可选的,将第一灰度图像进行反向归一化处理,得到滤波后的z轴数据,第二点云数据中的x轴数据、y轴数据和滤波后的z轴数据,组成滤波后的点云数据。Optionally, perform reverse normalization on the first grayscale image to obtain filtered z-axis data, and the x-axis data, y-axis data, and filtered z-axis data in the second point cloud data to form a filter. post point cloud data.

本申请实施例中,将深度图像转换成第一灰度图像,以便于根据第一灰度图像确定斜坡区域。将点云数据转换成图像,对图像进行处理速度快,可以达到毫秒级别,因此,使用第一灰度图像可以更容易、更快速的确定斜坡区域。In this embodiment of the present application, the depth image is converted into the first grayscale image, so as to determine the slope area according to the first grayscale image. Converting the point cloud data into an image, the processing speed of the image can reach the millisecond level, so it is easier and faster to determine the slope area using the first grayscale image.

如图4所示,在一种可能的实现方式中,步骤S103的实现过程可以包括:As shown in FIG. 4 , in a possible implementation manner, the implementation process of step S103 may include:

S1031,确定所述第一像素点中满足预设要求的第三像素点,所述预设要求包括一阶梯度值的绝对值大于或等于第一阈值、且二阶梯度值的绝对值小于或等于第二阈值。S1031: Determine a third pixel point in the first pixel point that meets a preset requirement, where the preset requirement includes that the absolute value of the first-order gradient value is greater than or equal to the first threshold, and the absolute value of the second-order gradient value is less than or equal to the second threshold.

在本实施例中,第三二值图中为第一值的第一像素点为第三像素点。In this embodiment, the first pixel with the first value in the third binary image is the third pixel.

S1032,基于所述第三像素点在所述第一灰度图像中的位置,确定所述第一灰度图像中的第一候选区域。S1032: Determine a first candidate region in the first grayscale image based on the position of the third pixel in the first grayscale image.

在本实施例中,在第三二值图中确定第一候选区域,第一灰度图像中与第三二值图对应的区域为第一候选区域。In this embodiment, the first candidate area is determined in the third binary image, and the area corresponding to the third binary image in the first grayscale image is the first candidate area.

具体的,将相邻的第三像素点归为一个区域中,相邻的第三像素点为位置相邻,得到第一候选区域。相邻可以包括在x轴方向上相邻,或在y轴方向上相邻。例如,第三像素点A为第一灰度图像中第i行第j列的像素点,第三像素点B为第一灰度图像中第i行第j+1列的像素点,第三像素点C为第一灰度图像中第i+1行第j列的像素点,第三像素点D为第一灰度图像中第i+1行第j+1列的像素点,第三像素点A、第三像素点B、第三像素点C、第三像素点D组成一个第一候选区域。Specifically, the adjacent third pixels are grouped into one area, and the adjacent third pixels are located adjacent to each other to obtain the first candidate area. Adjacent may include being adjacent in the x-axis direction, or adjacent in the y-axis direction. For example, the third pixel point A is the pixel point in the ith row and the jth column in the first grayscale image, the third pixel point B is the pixel point in the ith row and the j+1th column in the first grayscale image, and the third pixel point The pixel point C is the pixel point in the i+1th row and the jth column in the first grayscale image, the third pixel point D is the pixel point in the i+1th row and j+1th column in the first grayscale image, and the third pixel point D is the pixel point in the i+1th row and j+1th column in the first grayscale image. The pixel point A, the third pixel point B, the third pixel point C, and the third pixel point D form a first candidate area.

S1033,基于所述第一候选区域的面积,确定第二候选区域,其中,所述第二候选区域为所述第一候选区域中面积大于或等于预设面积的第一候选区域。S1033: Determine a second candidate region based on the area of the first candidate region, where the second candidate region is a first candidate region whose area is greater than or equal to a preset area in the first candidate region.

在本实施例中,对第一候选区域进行腐蚀和膨胀处理,确定每个第一候选区域的轮廓,进而根据每个第一候选区域的轮廓,计算每个第一候选区域的面积。In this embodiment, the first candidate regions are eroded and expanded to determine the contour of each first candidate region, and then the area of each first candidate region is calculated according to the contour of each first candidate region.

S1034,确定所述第二候选区域的重心点。S1034: Determine the center of gravity of the second candidate region.

在本实施例中,第二候选区域的重心点可能在第二候选区域内,也有可能在第二区域外。每个第二候选区域对应一个重心点。In this embodiment, the center of gravity of the second candidate area may be within the second candidate area, or may be outside the second area. Each second candidate region corresponds to a centroid point.

S1035,基于所述第二候选区域和所述第二候选区域的重心点的位置关系,从所述第二候选区域包括的第一像素点中确定关键像素点。S1035: Determine a key pixel point from the first pixel points included in the second candidate area based on the positional relationship between the second candidate area and the center of gravity of the second candidate area.

在本实施例中,根据重心点在第二候选区域内或外,选择不同的策略确定关键像素点。一个重心点可以确定一个关键像素点,因此,一个第二候选区域对应一个关键像素点。In this embodiment, different strategies are selected to determine the key pixel points according to whether the center of gravity is inside or outside the second candidate region. A centroid point can determine a key pixel point, therefore, a second candidate region corresponds to a key pixel point.

本申请实施例中,先根据第一像素点的梯度值确定第一候选区域,然后根据第一候选区域的面积进行筛选,得到第二候选区域,第二候选区域为比第一候选区域更准确的斜坡区域,最后根据第二候选区域的重心点确定第二候选区域的关键像素点,以便于后续根据关键像素点确定斜坡区域时,得到的斜坡区域更准确。In the embodiment of the present application, the first candidate area is first determined according to the gradient value of the first pixel point, and then the area of the first candidate area is screened to obtain the second candidate area. The second candidate area is more accurate than the first candidate area. Finally, the key pixel points of the second candidate area are determined according to the center of gravity of the second candidate area, so that when the slope area is determined according to the key pixel points, the obtained slope area is more accurate.

在一种可能的实现方式中,步骤S1035的实现过程可以包括:In a possible implementation manner, the implementation process of step S1035 may include:

S10351,在所述第二候选区域内的第一重心点,所述关键像素点包括在所述第一重心点对应的第一像素点。S10351. The first centroid point in the second candidate region, and the key pixel point includes a first pixel point corresponding to the first centroid point.

在本实施例中,若第二候选区域的重心点在该第二候选区域内,将该重心点记为第一重心点。第一重心点对应的第一像素点为该第二候选区域的关键像素点。第一灰度图像的关键像素点包括第一重心点。In this embodiment, if the center of gravity of the second candidate region is within the second candidate region, the center of gravity is recorded as the first center of gravity. The first pixel point corresponding to the first centroid point is the key pixel point of the second candidate area. The key pixel points of the first grayscale image include the first centroid point.

S10352,不在所述第二候选区域内的第二重心点,基于所述第二重心点在所述第一灰度图像中的位置,确定第四像素点。S10352: For a second centroid point that is not in the second candidate region, determine a fourth pixel point based on the position of the second centroid point in the first grayscale image.

在本实施例中,第四像素点为与所述第二重心点在同一行、且在所述第二重心点对应的所述第二候选区域内的第一像素点,以及与所述第二重心点在同一列、且在所述第二重心点对应的所述第二候选区域内的第一像素点。In this embodiment, the fourth pixel is a first pixel in the second candidate region that is on the same row as the second center of gravity and corresponding to the second center of gravity, and is the same as the first pixel in the second candidate region. The double centroid points are in the same column and are the first pixel points in the second candidate region corresponding to the second centroid point.

在本实施例中,若第二候选区域的重心点不在第二候选区域内,将该重心点记为第二重心点。在第一灰度图像中查找与第二重心点为同行和同列的第一像素点,并将在第二候选区域内、且与第二重心点为同行和同列的第一像素点记为第四像素点。In this embodiment, if the centroid point of the second candidate area is not within the second candidate area, the centroid point is recorded as the second centroid point. Find the first pixel in the same line and column as the second center of gravity in the first grayscale image, and record the first pixel in the second candidate area and in the same row and column as the second center of gravity as the first pixel Four pixels.

S10353,确定所述第四像素点中与所述第二重心点的距离最小的第五像素点,所述关键像素点包括所述第五像素点。S10353: Determine a fifth pixel with the smallest distance from the second center of gravity among the fourth pixels, where the key pixel includes the fifth pixel.

在本实施例中,计算各个第四像素点与第二重心点的距离,得到各个距离值。将所有距离值中的最小值对应的第四像素点记为第五像素点,第二候选区域的关键像素点为第五像素点。第一灰度图像的关键像素点包括第五像素点。In this embodiment, the distance between each fourth pixel point and the second center of gravity point is calculated to obtain each distance value. The fourth pixel point corresponding to the minimum value of all the distance values is recorded as the fifth pixel point, and the key pixel point of the second candidate area is the fifth pixel point. The key pixel points of the first grayscale image include the fifth pixel point.

在一种可能的实现方式中,步骤S104的实现过程可以包括:In a possible implementation manner, the implementation process of step S104 may include:

计算所述关键像素点的灰度值与所述第二像素点的灰度值的第一差值。Calculate the first difference between the gray value of the key pixel point and the gray value of the second pixel point.

若所述第一差值在预设区间内,基于在所述预设区间内的第一差值对应的所述第二像素点在所述第一灰度图像中的位置,得到所述关键像素点对应的斜坡区域,所述第一灰度图像中的斜坡区域包括所有关键像素点对应的斜坡区域。If the first difference is within a preset interval, the key is obtained based on the position of the second pixel corresponding to the first difference within the preset interval in the first grayscale image The slope area corresponding to the pixel point, the slope area in the first grayscale image includes the slope area corresponding to all key pixel points.

在本实施例中,根据关键像素点,利用漫水填充方法确定斜坡区域。In this embodiment, the slope area is determined by the flood filling method according to the key pixel points.

具体的,分别以每个关键像素点为中心向外逐步计算和扩散。具体的,以关键像素点为中心,在距离关键像素点从近到远的方向上,依次计算关键像素点与第二像素点之间的灰度差值,将灰度差值记为第一差值。在第一差值在预设区间内时,继续扩散,并将在预设区间内的第一差值对应的第二像素点与对应的关键像素点组成斜坡区域。直到第一差值不在预设区间内时,停止扩散,得到最终的斜坡区域。Specifically, it is calculated and diffused gradually outward with each key pixel as the center. Specifically, with the key pixel as the center, in the direction from near to far away from the key pixel, calculate the grayscale difference between the key pixel and the second pixel in turn, and record the grayscale difference as the first difference. When the first difference value is within the preset interval, the diffusion is continued, and the second pixel point corresponding to the first difference value within the preset interval and the corresponding key pixel point form a slope area. Until the first difference is not within the preset interval, the diffusion is stopped to obtain the final slope area.

预设区间可以根据需要进行设置。一个关键像素点对应一个斜坡区域,不同的斜坡区域之间可能存在交叉。斜坡区域的第一像素点的点云数据根据第二点云数据确定。The preset interval can be set as required. A key pixel corresponds to a slope area, and there may be intersections between different slope areas. The point cloud data of the first pixel point of the slope area is determined according to the second point cloud data.

若所述第一差值不在预设区间内,不在预设区间内的第一差值对应的第二像素点与对应的关键像素点不能组成斜坡区域。If the first difference value is not within the preset interval, the second pixel point corresponding to the first difference value not within the preset interval and the corresponding key pixel point cannot form a slope area.

如图5所示,在一种可能的实现方式中,在步骤S104之后,上述方法还可以包括:As shown in FIG. 5, in a possible implementation manner, after step S104, the above method may further include:

S201,对所述斜坡区域进行平面拟合处理,得到所述斜坡区域的拟合平面。S201 , performing a plane fitting process on the slope area to obtain a fitting plane of the slope area.

在本实施例中,对每个斜坡区域进行平面拟合处理,得到每个斜坡区域的拟合平面。In this embodiment, a plane fitting process is performed on each slope area to obtain the fitting plane of each slope area.

S202,计算所述拟合平面与水平面之间的斜坡角度,所述拟合平面与所述水平面之间的斜坡角度为所述斜坡区域的斜坡角度。S202: Calculate the slope angle between the fitting plane and the horizontal plane, where the slope angle between the fitting plane and the horizontal plane is the slope angle of the slope area.

S203,针对第六像素点,所述第六像素点为所述第一像素点中存在于一个斜坡区域内的第一像素点,所述第六像素点所在斜坡区域的斜坡角度为所述第六像素点的斜坡角度。S203, for the sixth pixel point, the sixth pixel point is a first pixel point existing in a slope area among the first pixel points, and the slope angle of the slope area where the sixth pixel point is located is the first pixel point in the slope area. The slope angle of the six-pixel point.

在本实施例中,若第一像素点存在于一个斜坡区域内,将该第一像素点记为第六像素点。第六像素点的斜坡角度为第六像素点所在的斜坡区域的斜坡角度。In this embodiment, if the first pixel exists in a slope area, the first pixel is recorded as the sixth pixel. The slope angle of the sixth pixel is the slope angle of the slope region where the sixth pixel is located.

S204,针对第七像素点,所述第七像素点为所述第一像素点中存在于至少两个斜坡区域内的第一像素点,将包括所述第七像素点的斜坡区域中斜坡角度的最大值作为所述第七像素点的斜坡角度。S204, for a seventh pixel point, the seventh pixel point is a first pixel point existing in at least two slope areas in the first pixel point, and the slope angle in the slope area of the seventh pixel point is to be included The maximum value is taken as the slope angle of the seventh pixel point.

在本实施例中,若第一像素点存在于至少两个斜坡区域内,将该第一像素点记为第七像素点。确定至少两个斜坡区域的斜坡角度中的最大值,将至少两个斜坡区域的斜坡角度中的最大值作为第七像素点的斜坡角度。In this embodiment, if the first pixel exists in at least two slope regions, the first pixel is recorded as the seventh pixel. The maximum value of the slope angles of the at least two slope regions is determined, and the maximum value of the slope angles of the at least two slope regions is used as the slope angle of the seventh pixel point.

作为举例,若第七像素点在斜坡区域A和斜坡区域B中,斜坡区域A的斜坡角度为20度,斜坡区域B的斜坡角度为24度,第七像素点的斜坡角度为24度。As an example, if the seventh pixel is in the slope area A and the slope area B, the slope angle of the slope area A is 20 degrees, the slope angle of the slope area B is 24 degrees, and the slope angle of the seventh pixel point is 24 degrees.

在本实施例中,通过平面拟合方法可以确定斜坡区域的斜坡角度,进而根据斜坡角度确定斜坡区域中各个第一像素点的斜坡角度,以便于输出斜坡区域中各个第一像素点的斜坡角度,得到更丰富的斜坡数据。In this embodiment, the slope angle of the slope area can be determined by the plane fitting method, and then the slope angle of each first pixel point in the slope area is determined according to the slope angle, so as to output the slope angle of each first pixel point in the slope area , to get richer slope data.

在一种可能的实现方式中,在步骤S103之后,上述方法还可以包括:In a possible implementation manner, after step S103, the above method may further include:

计算所述第一灰度图像中第i-1行第j列的第一像素点的灰度值减去第i行第j列的第一像素点的灰度值的第二差值,所述第i行第j列的第一像素点为所述斜坡区域中的第一像素点。Calculate the second difference value of the gray value of the first pixel point in the i-1th row and the jth column of the first grayscale image minus the gray value of the first pixel point in the i-th row and the jth column, so The first pixel in the i-th row and the j-th column is the first pixel in the slope area.

若所述第二差值大于预设值,确定所述第i行第j列的第一像素点相对于所述第i-1行第j列的第一像素点的斜坡类型为下坡。第i-1行第j列的第一像素点相对于第i行第j列的第一像素点的斜坡类型为上坡。预设值可以为0。If the second difference value is greater than a preset value, it is determined that the slope type of the first pixel point in the i-th row and the j-th column relative to the first pixel point in the i-1-th row and the j-th column is a downward slope. The slope type of the first pixel point in the i-1th row and the jth column relative to the first pixel point in the i-th row and the jth column is an uphill slope. The default value can be 0.

若所述第二差值小于所述预设值,确定所述第i行第j列的第一像素点相对于所述第i-1行第j列的第一像素点的斜坡类型为上坡。第i-1行第j列的第一像素点相对于第i行第j列的第一像素点的斜坡类型为下坡。If the second difference is smaller than the preset value, determine that the slope type of the first pixel in the i-th row and the j-th column relative to the first pixel in the i-1-th row and the j-th column is up. slope. The slope type of the first pixel point in the i-1th row and the jth column relative to the first pixel point in the i-th row and the jth column is downslope.

若所述第二差值等于所述预设值,确定所述第i行第j列的第一像素点相对于所述第i-1行第j列的第一像素点的斜坡类型为平行。If the second difference is equal to the preset value, determine that the slope type of the first pixel in the i-th row and the j-th column relative to the first pixel in the i-1-th row and the j-th column is parallel. .

在本实施例中,还可以计算第i行第j列的第一像素点的灰度值减去第i行第j-1列的第一像素点的灰度值的第三差值,若第三差值大于预设值,则第i行第j列的第一像素点相对于第i行第j-1列的第一像素点的斜坡类型为上坡。若第三差值小于预设值,则第i行第j列的第一像素点相对于第i行第j-1列的第一像素点的斜坡类型为下坡。若第三差值等于预设值,则第i行第j列的第一像素点相对于第i行第j-1列的第一像素点的斜坡类型为平行。In this embodiment, the gray value of the first pixel in the i-th row and the j-th column minus the gray value of the first pixel in the i-th row and the j-1 column can also be calculated. If If the third difference is greater than the preset value, the slope type of the first pixel in the i-th row and the j-th column relative to the first pixel in the i-th row and the j-1 column is an uphill slope. If the third difference is smaller than the preset value, the slope type of the first pixel in the i-th row and the j-th column relative to the first pixel in the i-th row and the j-1 column is a downslope. If the third difference is equal to the preset value, the slope type of the first pixel in the i-th row and the j-th column relative to the first pixel in the i-th row and the j-1-th column is parallel.

在本实施例中,若深度相机安装在机器人上,深度图像为机器人向前移动或需要向前移动时拍摄的前方地面的图像。第i行的第一像素点相对于第i-1行的第一像素点距离深度相机更近。若第i行第j列的第一像素点为斜坡区域内的点,计算第i-1行第j列的第一像素点的灰度值减去第i行第j列的第一像素点的灰度值,得到第四差值。若第四差值大于预设值,第i行第j列的第一像素点斜坡类型为上坡,也就是在机器人运动到第i行第j列的第一像素点时,若继续运动则需要上坡。若第四差值小于预设值,第i行第j列的第一像素点斜坡类型为下坡,也就是在机器人运动到第i行第j列的第一像素点时,若继续运动则需要下坡。In this embodiment, if the depth camera is installed on the robot, the depth image is an image of the ground ahead captured when the robot moves forward or needs to move forward. The first pixel in row i is closer to the depth camera than the first pixel in row i-1. If the first pixel at the i-th row and the j-th column is a point in the slope area, calculate the gray value of the first pixel at the i-1-th row and the j-th column minus the first pixel at the i-th row and the j-th column. The gray value of , obtains the fourth difference value. If the fourth difference is greater than the preset value, the slope type of the first pixel point in the i-th row and the j-th column is uphill, that is, when the robot moves to the first pixel point in the i-th row and the j-th column, if it continues to move Need to go uphill. If the fourth difference is less than the preset value, the slope type of the first pixel point in the i-th row and the j-th column is downhill, that is, when the robot moves to the first pixel point in the i-th row and the j-th column, if it continues to move Need to go downhill.

本申请实施例中,根据像素点的灰度值可以确定斜坡区域中各个第一像素点的斜坡类型,进而输出斜坡区域中第一像素点的斜坡类型,得到更丰富的斜坡数据。In the embodiment of the present application, the slope type of each first pixel in the slope area can be determined according to the gray value of the pixel point, and then the slope type of the first pixel in the slope area is output to obtain more abundant slope data.

应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the size of the sequence numbers of the steps in the above embodiments does not mean the sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

对应于上文实施例所述的斜坡检测方法,图6示出了本申请实施例提供的斜坡检测装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。Corresponding to the slope detection method described in the above embodiment, FIG. 6 shows a structural block diagram of the slope detection apparatus provided by the embodiment of the present application. For convenience of description, only the part related to the embodiment of the present application is shown.

参照图6,该装置300可以包括:图像获取模块310、梯度计算模块320、关键点确定模块330和斜坡检测模块340。Referring to FIG. 6 , the apparatus 300 may include: an image acquisition module 310 , a gradient calculation module 320 , a key point determination module 330 and a slope detection module 340 .

其中,图像获取模块310,用于获取深度相机采集的深度图像的第一灰度图像,所述深度图像中包括地面;Wherein, the image acquisition module 310 is configured to acquire the first grayscale image of the depth image collected by the depth camera, and the depth image includes the ground;

梯度计算模块320,用于基于所述第一灰度图像中第一像素点的灰度值,计算所述第一像素点的梯度值,所述第一像素点的数量为多个;a gradient calculation module 320, configured to calculate the gradient value of the first pixel point based on the grayscale value of the first pixel point in the first grayscale image, and the number of the first pixel point is multiple;

关键点确定模块330,用于基于所述第一像素点的梯度值,从所述第一像素点中确定关键像素点;a key point determination module 330, configured to determine a key pixel point from the first pixel point based on the gradient value of the first pixel point;

斜坡检测模块340,用于基于所述关键像素点的灰度值和第二像素点的灰度值,确定所述第一灰度图像中的斜坡区域,其中,所述第二像素点为所述第一灰度图像中除所述关键像素点之外的第一像素点,所述第一灰度图像中的斜坡区域用于确定所述地面的斜坡区域。The slope detection module 340 is configured to determine the slope area in the first grayscale image based on the grayscale value of the key pixel point and the grayscale value of the second pixel point, wherein the second pixel point is the The first pixel points other than the key pixel points in the first grayscale image, and the slope area in the first grayscale image is used to determine the slope area of the ground.

在一种可能的实现方式中,所述第一像素点的梯度值包括一阶梯度值和二阶梯度值;In a possible implementation manner, the gradient value of the first pixel point includes a first-order gradient value and a second-order gradient value;

关键点确定模块330具体可以用于:The key point determination module 330 can be specifically used for:

确定所述第一像素点中满足预设要求的第三像素点,所述预设要求包括一阶梯度值的绝对值大于或等于第一阈值、且二阶梯度值的绝对值小于或等于第二阈值;Determine the third pixel point in the first pixel point that meets the preset requirements, the preset requirements include that the absolute value of the first-order gradient value is greater than or equal to the first threshold value, and the absolute value of the second-order gradient value is less than or equal to the first threshold value. two thresholds;

基于所述第三像素点在所述第一灰度图像中的位置,确定所述第一灰度图像中的第一候选区域;determining a first candidate region in the first grayscale image based on the position of the third pixel in the first grayscale image;

基于所述第一候选区域的面积,确定第二候选区域,其中,所述第二候选区域为所述第一候选区域中面积大于或等于预设面积的第一候选区域;determining a second candidate area based on the area of the first candidate area, wherein the second candidate area is a first candidate area in the first candidate area whose area is greater than or equal to a preset area;

确定所述第二候选区域的重心点;determining the center of gravity of the second candidate region;

基于所述第二候选区域和所述第二候选区域的重心点的位置关系,从所述第二候选区域包括的第一像素点中确定关键像素点。Based on the positional relationship between the second candidate area and the center of gravity of the second candidate area, key pixels are determined from the first pixels included in the second candidate area.

在一种可能的实现方式中,关键点确定模块330具体可以用于:In a possible implementation manner, the key point determination module 330 may specifically be used for:

在所述第二候选区域内的第一重心点,所述关键像素点包括所述第一重心点对应的第一像素点;The first centroid point in the second candidate region, the key pixel point includes the first pixel point corresponding to the first centroid point;

不在所述第二候选区域内的第二重心点,基于所述第二重心点在所述第一灰度图像中的位置,确定第四像素点,其中,所述第四像素点为与所述第二重心点在同一行、且在所述第二重心点对应的所述第二候选区域内的第一像素点,以及与所述第二重心点在同一列、且在所述第二重心点对应的所述第二候选区域内的第一像素点;For the second centroid point that is not in the second candidate area, a fourth pixel is determined based on the position of the second centroid in the first grayscale image, wherein the fourth pixel is the same as the The second centroid point is in the same row and the first pixel point in the second candidate region corresponding to the second centroid point, and the second centroid point is in the same column and in the second the first pixel in the second candidate region corresponding to the center of gravity;

确定所述第四像素点中与所述第二重心点的距离最小的第五像素点,所述关键像素点包括所述第五像素点。A fifth pixel point with the smallest distance from the second center of gravity point among the fourth pixel points is determined, and the key pixel point includes the fifth pixel point.

在一种可能的实现方式中,斜坡检测模块340具体可以用于:In a possible implementation manner, the slope detection module 340 may be specifically used for:

计算所述关键像素点的灰度值与所述第二像素点的灰度值的第一差值;Calculate the first difference between the gray value of the key pixel point and the gray value of the second pixel point;

若所述第一差值在预设区间内,基于在所述预设区间内的第一差值对应的所述第二像素点在所述第一灰度图像中的位置,得到所述关键像素点对应的斜坡区域,所述第一灰度图像中的斜坡区域包括所有关键像素点对应的斜坡区域。If the first difference is within a preset interval, the key is obtained based on the position of the second pixel corresponding to the first difference within the preset interval in the first grayscale image The slope area corresponding to the pixel point, the slope area in the first grayscale image includes the slope area corresponding to all key pixel points.

在一种可能的实现方式中,图像获取模块310具体可以用于:In a possible implementation manner, the image acquisition module 310 may be specifically used for:

将所述深度图像转换为相机坐标系下的第一点云数据,所述相机坐标系为基于所述深度相机的位姿确定的坐标系;converting the depth image into first point cloud data in a camera coordinate system, where the camera coordinate system is a coordinate system determined based on the pose of the depth camera;

将所述第一点云数据转换为标准坐标系下的第二点云数据,所述标准坐标系为基于水平面确定的世界坐标系;Converting the first point cloud data into second point cloud data under a standard coordinate system, where the standard coordinate system is a world coordinate system determined based on a horizontal plane;

对所述第二点云数据中的高度值进行归一化处理,得到归一化处理后的高度值,所述高度值用于表征所述地面高出所述标准坐标系的原点的程度;Normalizing the height value in the second point cloud data to obtain a normalized height value, where the height value is used to represent the degree to which the ground is higher than the origin of the standard coordinate system;

基于所述归一化处理后的高度值,得到所述深度图像的第一灰度图像。Based on the normalized height value, a first grayscale image of the depth image is obtained.

在一种可能的实现方式中,与斜坡检测模块340相连的还包括:In a possible implementation manner, connected to the slope detection module 340 further includes:

平面拟合模块,用于对所述斜坡区域进行平面拟合处理,得到所述斜坡区域的拟合平面;a plane fitting module, configured to perform a plane fitting process on the slope area to obtain a fitting plane of the slope area;

角度计算模块,用于计算所述拟合平面与水平面之间的斜坡角度,所述拟合平面与所述水平面之间的斜坡角度为所述斜坡区域的斜坡角度。The angle calculation module is configured to calculate the slope angle between the fitting plane and the horizontal plane, and the slope angle between the fitting plane and the horizontal plane is the slope angle of the slope area.

在一种可能的实现方式中,与角度计算模块相连的还包括:In a possible implementation manner, connected to the angle calculation module further includes:

第一角度确定模块,用于针对第六像素点,所述第六像素点为所述第一像素点中存在于一个斜坡区域内的第一像素点,所述第六像素点所在斜坡区域的斜坡角度为所述第六像素点的斜坡角度;The first angle determination module is used for the sixth pixel point, the sixth pixel point is the first pixel point in the first pixel point that exists in a slope area, and the sixth pixel point is located in the slope area. The slope angle is the slope angle of the sixth pixel point;

第二角度确定模块,用于针对第七像素点,所述第七像素点为所述第一像素点中存在于至少两个斜坡区域内的第一像素点,将包括所述第七像素点的斜坡区域中斜坡角度的最大值作为所述第七像素点的斜坡角度。The second angle determination module is configured to target the seventh pixel point, the seventh pixel point is the first pixel point existing in at least two slope regions in the first pixel point, and will include the seventh pixel point The maximum value of the slope angle in the slope region of , is taken as the slope angle of the seventh pixel point.

在一种可能的实现方式中,与斜坡检测模块340相连的还包括:In a possible implementation manner, connected to the slope detection module 340 further includes:

差值计算模块,用于计算所述第一灰度图像中第i-1行第j列的第一像素点的灰度值减去第i行第j列的第一像素点的灰度值的第一差值,所述第i行第j列的第一像素点为所述斜坡区域中的像素点;A difference value calculation module, configured to calculate the gray value of the first pixel in the i-1th row and the jth column of the first grayscale image minus the gray value of the first pixel in the i-th row and the jth column. The first difference value of , the first pixel point of the i-th row and the j-th column is the pixel point in the slope area;

第一判断模块,用于若所述第一差值大于预设值,确定所述第i行第j列的第一像素点相对于所述第i-1行第j列的第一像素点的斜坡类型为下坡;A first judgment module, configured to determine the first pixel point of the i-th row and the j-th column relative to the first pixel point of the i-1-th row and the j-th column if the first difference value is greater than a preset value The slope type is downhill;

第二判断模块,用于若所述第一差值小于所述预设值,确定所述第i行第j列的第一像素点相对于所述第i-1行第j列的第一像素点的斜坡类型为上坡;The second judgment module is configured to determine, if the first difference is smaller than the preset value, the first pixel in the i-th row and the j-th column relative to the first pixel in the i-1-th row and the j-th column. The slope type of the pixel point is uphill;

第三判断模块,用于若所述第一差值等于所述预设值,确定所述第i行第j列的第一像素点相对于所述第i-1行第j列的第一像素点的斜坡类型为平行。A third judging module, configured to determine, if the first difference is equal to the preset value, the first pixel in the i-th row and the j-th column relative to the first pixel in the i-1-th row and the j-th column. The slope type of the pixel is parallel.

需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。It should be noted that the information exchange, execution process and other contents between the above-mentioned devices/units are based on the same concept as the method embodiments of the present application. For specific functions and technical effects, please refer to the method embodiments section. It is not repeated here.

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. Module completion, that is, dividing the internal structure of the device into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated in one processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit, and the above-mentioned integrated units may adopt hardware. It can also be realized in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing from each other, and are not used to limit the protection scope of the present application. For the specific working processes of the units and modules in the above-mentioned system, reference may be made to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

本申请实施例还提供了一种终端设备,参见图7,该终端设备400可以包括:至少一个处理器410、存储器420以及存储在所述存储器420中并可在所述至少一个处理器410上运行的计算机程序,所述处理器410执行所述计算机程序时实现上述任意各个方法实施例中的步骤,例如图2所示实施例中的步骤S101至步骤S104。或者,处理器410执行所述计算机程序时实现上述各装置实施例中各模块/单元的功能,例如图6所示模块310至模块340的功能。An embodiment of the present application further provides a terminal device. Referring to FIG. 7 , the terminal device 400 may include: at least one processor 410 , a memory 420 , and a terminal device stored in the memory 420 and available on the at least one processor 410 The running computer program, when the processor 410 executes the computer program, implements the steps in any of the foregoing method embodiments, for example, steps S101 to S104 in the embodiment shown in FIG. 2 . Alternatively, when the processor 410 executes the computer program, the functions of the modules/units in the above device embodiments, such as the functions of the modules 310 to 340 shown in FIG. 6 , are implemented.

示例性的,计算机程序可以被分割成一个或多个模块/单元,一个或者多个模块/单元被存储在存储器420中,并由处理器410执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序段,该程序段用于描述计算机程序在终端设备400中的执行过程。Exemplarily, the computer program may be divided into one or more modules/units, and the one or more modules/units are stored in the memory 420 and executed by the processor 410 to complete the present application. The one or more modules/units may be a series of computer program segments capable of accomplishing specific functions, and the program segments are used to describe the execution process of the computer program in the terminal device 400 .

本领域技术人员可以理解,图7仅仅是终端设备的示例,并不构成对终端设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如输入输出设备、网络接入设备、总线等。Those skilled in the art can understand that FIG. 7 is only an example of a terminal device, and does not constitute a limitation on the terminal device. It may include more or less components than the one shown in the figure, or combine some components, or different components, such as Input and output devices, network access devices, buses, etc.

处理器410可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 410 may be a central processing unit (Central Processing Unit, CPU), or other general-purpose processors, digital signal processors (Digital Signal Processors, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf processors Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.

存储器420可以是终端设备的内部存储单元,也可以是终端设备的外部存储设备,例如插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。所述存储器420用于存储所述计算机程序以及终端设备所需的其他程序和数据。所述存储器420还可以用于暂时地存储已经输出或者将要输出的数据。The memory 420 may be an internal storage unit of the terminal device, or may be an external storage device of the terminal device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card (Flash Card) etc. The memory 420 is used to store the computer program and other programs and data required by the terminal device. The memory 420 may also be used to temporarily store data that has been output or will be output.

总线可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互连(Peripheral Component,PCI)总线或扩展工业标准体系结构(ExtendedIndustry Standard Architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,本申请附图中的总线并不限定仅有一根总线或一种类型的总线。The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, a Peripheral Component (Peripheral Component, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, or the like. The bus can be divided into address bus, data bus, control bus and so on. For convenience of representation, the buses in the drawings of the present application are not limited to only one bus or one type of bus.

本申请实施例提供的斜坡检测方法可以应用于计算机、平板电脑、笔记本电脑、上网本、个人数字助理(personal digital assistant,PDA)等终端设备上,本申请实施例对终端设备的具体类型不作任何限制。The slope detection method provided by the embodiments of the present application can be applied to terminal devices such as computers, tablet computers, notebook computers, netbooks, and personal digital assistants (PDAs), and the embodiments of the present application do not impose any restrictions on the specific types of the terminal devices. .

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the foregoing embodiments, the description of each embodiment has its own emphasis. For parts that are not described or described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.

在本申请所提供的实施例中,应该理解到,所揭露的终端设备、装置和方法,可以通过其它的方式实现。例如,以上所描述的终端设备实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed terminal device, apparatus and method may be implemented in other manners. For example, the terminal device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components. May be combined or may be integrated into another system, or some features may be omitted, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被一个或多个处理器执行时,可实现上述各个方法实施例的步骤。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the present application can implement all or part of the processes in the methods of the above embodiments, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer When the program is executed by one or more processors, the steps of the foregoing method embodiments can be implemented.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被一个或多个处理器执行时,可实现上述各个方法实施例的步骤。The integrated unit, if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a computer-readable storage medium. Based on this understanding, the present application can implement all or part of the processes in the methods of the above embodiments, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer When the program is executed by one or more processors, the steps of the foregoing method embodiments can be implemented.

同样,作为一种计算机程序产品,当计算机程序产品在终端设备上运行时,使得终端设备执行时实现可实现上述各个方法实施例中的步骤。Likewise, as a computer program product, when the computer program product runs on a terminal device, the steps in the foregoing method embodiments can be implemented when the terminal device is executed.

其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random AccessMemory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括是电载波信号和电信信号。Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form, and the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable media may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer-readable media Excluded are electrical carrier signals and telecommunication signals.

以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the above-mentioned embodiments, those of ordinary skill in the art should understand that: it can still be used for the above-mentioned implementations. The technical solutions described in the examples are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions in the embodiments of the application, and should be included in the within the scope of protection of this application.

Claims (10)

1. A method of slope detection, comprising:
acquiring a first gray image of a depth image acquired by a depth camera, wherein the depth image comprises the ground;
calculating gradient values of first pixel points in the first gray image based on gray values of the first pixel points, wherein the number of the first pixel points is multiple;
determining key pixel points from the first pixel points based on the gradient values of the first pixel points;
determining a slope region in the first gray image based on the gray value of the key pixel point and the gray value of a second pixel point, wherein the second pixel point is a first pixel point in the first gray image except the key pixel point, and the slope region in the first gray image is used for determining the slope region of the ground.
2. The slope detection method according to claim 1, wherein the gradient values of the first pixel point include a gradient value and a second gradient value;
determining a key pixel point from the first pixel points based on the gradient value of the first pixel point, including:
determining a third pixel point which meets preset requirements in the first pixel points, wherein the preset requirements comprise that the absolute value of a gradient value is greater than or equal to a first threshold value, and the absolute value of a second gradient value is less than or equal to a second threshold value;
determining a first candidate region in the first gray image based on the position of the third pixel point in the first gray image;
determining a second candidate region based on the area of the first candidate region, wherein the second candidate region is a first candidate region of the first candidate region, and the area of the second candidate region is larger than or equal to a preset area;
determining a center of gravity point of the second candidate region;
and determining key pixel points from first pixel points included in the second candidate region based on the position relation between the second candidate region and the gravity center points of the second candidate region.
3. The slope detection method according to claim 2, wherein the determining a key pixel point from first pixel points included in the second candidate region based on the second candidate region and a positional relationship of the gravity center points of the second candidate region includes:
a first center of gravity point in the second candidate region, wherein the key pixel points comprise first pixel points corresponding to the first center of gravity point;
determining a fourth pixel point based on the position of the second gravity center point in the first gray-scale image, wherein the fourth pixel point is a first pixel point which is in the same row with the second gravity center point and is in the second candidate area corresponding to the second gravity center point, and a first pixel point which is in the same column with the second gravity center point and is in the second candidate area corresponding to the second gravity center point;
and determining a fifth pixel point with the minimum distance from the second center of gravity point in the fourth pixel points, wherein the key pixel points comprise the fifth pixel point.
4. The slope detection method of claim 1, wherein the determining the slope region in the first grayscale image based on the grayscale value of the key pixel and the grayscale value of the second pixel comprises:
calculating a first difference value between the gray value of the key pixel point and the gray value of the second pixel point;
if the first difference value is within a preset interval, obtaining a slope area corresponding to the key pixel point based on the position of the second pixel point corresponding to the first difference value within the preset interval in the first gray-scale image, wherein the slope area in the first gray-scale image comprises slope areas corresponding to all key pixel points.
5. The slope detection method according to any one of claims 1 to 4, wherein the acquiring a first grayscale image of the depth image acquired by the depth camera comprises:
converting the depth image into first point cloud data in a camera coordinate system, wherein the camera coordinate system is a coordinate system determined based on the pose of the depth camera;
converting the first point cloud data into second point cloud data under a standard coordinate system, wherein the standard coordinate system is a world coordinate system determined based on a horizontal plane;
normalizing the height value in the second point cloud data to obtain a normalized height value, wherein the height value is used for representing the degree that the ground is higher than the origin of the standard coordinate system;
and obtaining a first gray image of the depth image based on the height value after the normalization processing.
6. The slope detection method according to any one of claims 1 to 4, wherein after determining the slope region in the first grayscale image based on the grayscale value of the key pixel and the grayscale value of the second pixel, the method further comprises:
performing plane fitting processing on the slope area to obtain a fitting plane of the slope area;
and calculating the slope angle between the fitting plane and the horizontal plane, wherein the slope angle between the fitting plane and the horizontal plane is the slope angle of the slope area.
7. The slope detection method of claim 6, wherein after the calculating a slope angle between the fitted plane and a horizontal plane, the method further comprises:
aiming at a sixth pixel point, the sixth pixel point is a first pixel point existing in a slope region in the first pixel points, and the slope angle of the slope region where the sixth pixel point is located is the slope angle of the sixth pixel point;
and aiming at a seventh pixel point, the seventh pixel point is a first pixel point existing in at least two slope regions in the first pixel point, and the maximum value of the slope angle in the slope region comprising the seventh pixel point is used as the slope angle of the seventh pixel point.
8. The slope detection method according to any one of claims 1 to 4, wherein after determining the slope region in the first grayscale image based on the grayscale value of the key pixel and the grayscale value of the second pixel, the method further comprises:
calculating a second difference value of the gray value of the first pixel point in the ith-1 th row and the jth column in the first gray image minus the gray value of the first pixel point in the ith row and the jth column, wherein the first pixel point in the ith row and the jth column is the first pixel point in the slope region;
if the second difference value is larger than a preset value, determining that the slope type of the first pixel point in the ith row and the jth column relative to the first pixel point in the ith-1 row and the jth column is downhill;
if the second difference is smaller than the preset value, determining that the slope type of the first pixel point of the ith row and the jth column relative to the first pixel point of the ith-1 row and the jth column is an ascending slope;
and if the second difference is equal to the preset value, determining that the slope type of the first pixel point of the ith row and the jth column is parallel to that of the first pixel point of the ith-1 row and the jth column.
9. A robot comprising a depth camera, a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements a hill detection method as recited in any one of claims 1 to 8.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out a hill detection method according to any one of claims 1 to 8.
CN202210600378.XA 2022-05-30 2022-05-30 Slope detection method, robot and storage medium Active CN114882343B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210600378.XA CN114882343B (en) 2022-05-30 2022-05-30 Slope detection method, robot and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210600378.XA CN114882343B (en) 2022-05-30 2022-05-30 Slope detection method, robot and storage medium

Publications (2)

Publication Number Publication Date
CN114882343A true CN114882343A (en) 2022-08-09
CN114882343B CN114882343B (en) 2025-01-14

Family

ID=82679544

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210600378.XA Active CN114882343B (en) 2022-05-30 2022-05-30 Slope detection method, robot and storage medium

Country Status (1)

Country Link
CN (1) CN114882343B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160140769A1 (en) * 2014-11-17 2016-05-19 Qualcomm Incorporated Edge-aware volumetric depth map fusion
CN107220964A (en) * 2017-05-03 2017-09-29 长安大学 A kind of linear feature extraction is used for geology Taking stability appraisal procedure
CN110136193A (en) * 2019-05-08 2019-08-16 广东嘉腾机器人自动化有限公司 Cubold cabinet three-dimensional dimension measurement method and storage medium based on depth image

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160140769A1 (en) * 2014-11-17 2016-05-19 Qualcomm Incorporated Edge-aware volumetric depth map fusion
CN107220964A (en) * 2017-05-03 2017-09-29 长安大学 A kind of linear feature extraction is used for geology Taking stability appraisal procedure
CN110136193A (en) * 2019-05-08 2019-08-16 广东嘉腾机器人自动化有限公司 Cubold cabinet three-dimensional dimension measurement method and storage medium based on depth image

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
KUANQI CAI 等: "A Vision-Based Road Surface Slope Estimation Algorithm for Mobile Service Robots in Indoor Environments", 《PROCEEDING OF THE IEEE INTERNATIONAL CONFERENCE ON INFORMATION AND AUTOMATION》, 26 August 2019 (2019-08-26), pages 621 - 626 *
辛菁 等: "基于迁移学习的移动机器人单帧图像坡度检测算法", 《智能系统学报》, vol. 16, no. 1, 3 February 2021 (2021-02-03), pages 81 - 91 *

Also Published As

Publication number Publication date
CN114882343B (en) 2025-01-14

Similar Documents

Publication Publication Date Title
JP6842520B2 (en) Object detection methods, devices, equipment, storage media and vehicles
CN113486796B (en) Unmanned vehicle position detection method, unmanned vehicle position detection device, unmanned vehicle position detection equipment, storage medium and vehicle
CN112528831B (en) Multi-target attitude estimation method, multi-target attitude estimation device and terminal equipment
CN107636680B (en) Obstacle detection method and device
CN110389341B (en) Charging pile identification method and device, robot and computer readable storage medium
CN113838125B (en) Target position determining method, device, electronic equipment and storage medium
CN111860072A (en) Parking control method, device, computer device, and computer-readable storage medium
CN115115655A (en) Object segmentation method, device, electronic device, storage medium and program product
CN116337072A (en) Construction method, construction equipment and readable storage medium for engineering machinery
CN112198878B (en) Instant map construction method and device, robot and storage medium
CN114859938A (en) Robot, dynamic obstacle state estimation method and device and computer equipment
CN114219770A (en) Ground detection method, device, electronic device and storage medium
CN114170596A (en) Posture recognition method and device, electronic equipment, engineering machinery and storage medium
CN112132015A (en) Detection method, device, medium and electronic equipment for illegal driving posture
CN114882343A (en) Slope detection method, robot and storage medium
US12154349B2 (en) Method for detecting three-dimensional objects in roadway and electronic device
CN115861626A (en) Target detection method and device, terminal equipment and computer readable storage medium
WO2023000528A1 (en) Map positioning method and apparatus, computer-readable storage medium and terminal device
CN115240150A (en) Lane departure warning method, system, device and medium based on monocular camera
CN117152240A (en) Object detection method, device, equipment and storage medium based on monocular camera
CN115236643A (en) Sensor calibration method, system, device, electronic equipment and medium
CN113608207A (en) Blast furnace burden surface shape measuring method, terminal equipment and storage medium
CN114744721A (en) Charging control method of robot, terminal device and storage medium
CN117774963B (en) Forward collision early warning method and device, electronic equipment and intelligent driving vehicle
CN112614181B (en) Robot positioning method and device based on highlight target

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