Disclosure of Invention
Based on the above, the invention aims to provide an obstacle recognition method and system, which can monitor an obstacle in real time better in the movement process of a robot, so that the obstacle can be avoided better.
In order to achieve the above object, the present invention provides an obstacle recognition method, the method comprising:
s1, acquiring a first depth image of the surrounding environment in a driving route;
s2, cutting the first depth image to obtain a second depth image corresponding to the driving lane;
s3, converting the second depth image into point cloud information, performing ground projection according to the point cloud information to obtain target point cloud information and ground point cloud information, and deleting the ground point cloud information to obtain a projection image without a ground part;
and S4, carrying out cluster analysis on the projection image based on a growing algorithm of the adjacent area to obtain a plurality of obstacle cluster point sets, and determining the position information of each obstacle.
Preferably, the step S2 includes:
converting the first depth image into a point cloud image based on a calculation method of a depth image turning point cloud;
cutting the point cloud image in an x-axis driving lane range, cutting the point cloud image in a y-axis driving height range and cutting the point cloud image in a z-axis detection range respectively to obtain a cut point cloud image;
and acquiring a second depth image corresponding to the driving lane according to the cut point cloud image.
Preferably, the step S3 includes:
s301, performing point cloud coordinate conversion on the second depth image to obtain corresponding point cloud information;
s302, carrying out coordinate conversion on the point cloud information, and converting a (x, z) coordinate system plane in the point cloud information into a state parallel to the ground;
s303, setting a plurality of grids under the (x, z) coordinate system, and projecting all pixel points in the second depth image into each grid;
s304, counting the number of projected pixel points falling in each grid, wherein if the number of the projected pixel points is larger than a preset number threshold, the projected pixel points in the grid are the projected pixel points of the target, otherwise, the projected pixel points are the projected pixel points of the ground;
and S305, deleting the projected pixel points of the ground to obtain a projected image without the ground part.
Preferably, the step S302 specifically includes:
and (3) calibrating the installation angle of the depth camera, performing coordinate conversion on the point cloud information, and converting the (x, z) coordinate system plane in the point cloud information into a state parallel to the ground.
Preferably, the step S303 includes: the number of grids in the (x, z) coordinate system is determined by the length of the z-axis in the (x, z) coordinate system and the size of the grids.
Preferably, the step S303 includes:
the size of the grid is related to the pixel density of the second depth image, and the grid is smaller when the pixel density is larger;
the length of the z-axis in the (x, z) coordinate system is determined by the maximum distance of the pixels of the second depth image.
Preferably, the step S3 further includes:
and expanding and corroding the projection image, and performing median filtering treatment on the expanded and corroded projection image.
Preferably, the step S4 includes:
starting traversing by using the origin of the projection image, and traversing according to the sequence from top left to bottom right;
firstly, carrying out region growth on four adjacent points of the origin, namely, the upper, lower, left and right adjacent points of the origin, and if the targets cannot grow, carrying out region growth on the adjacent points of the four adjacent points of the origin;
and the like, starting the region growth by taking the points as seed points one by one until all the points finish the region growth operation.
Preferably, the method further comprises:
associating the pixel points of the projection image with the corresponding pixel points in the second depth image, determining a target pixel point and a ground pixel point in the second depth image, and deleting the ground pixel point to obtain a third depth image without ground;
and carrying out cluster analysis on the third depth image based on a region generation method, obtaining a plurality of obstacle cluster point sets, and determining the position information of each obstacle.
To achieve the above object, the present invention provides an obstacle recognition system, comprising:
the acquisition module is used for acquiring a first depth image of the surrounding environment in the driving route;
the cutting module is used for cutting the first depth image to obtain a second depth image corresponding to the driving lane;
the projection module is used for converting the second depth image into point cloud information, performing ground projection according to the point cloud information to obtain target point cloud information and ground point cloud information, and deleting the ground point cloud information to obtain a projection image without a ground part;
and the clustering module is used for carrying out cluster analysis on the projection image based on a neighboring area growing algorithm, acquiring a plurality of obstacle clustering point sets and determining the position information of each obstacle.
Compared with the prior art, the obstacle recognition method and system provided by the invention have the beneficial effects that: in the running process of the robot or the unmanned vehicle, the technical problem that the ground cannot be well segmented due to the fact that the ground is inclined in the left-right direction or the ground is hollow is solved, the technical scheme of obstacle recognition is optimized, the obstacle can be monitored in real time better, and therefore a more correct obstacle avoidance decision can be made for the robot and the unmanned vehicle; according to the technical scheme, an optimized large-range region growing algorithm is adopted, so that the technical problem of obstacle faults caused by incomplete depth image data is effectively solved, and the obstacles can be accurately identified.
Detailed Description
The present invention will be described in detail below with reference to the specific embodiments shown in the drawings, but these embodiments are not limited to the present invention, and structural, method, or functional modifications made by those skilled in the art based on these embodiments are included in the scope of the present invention.
In one embodiment of the present invention as shown in fig. 1, the present invention provides an obstacle identifying method, the method comprising:
s1, acquiring a first depth image of the surrounding environment in a driving route;
s2, cutting the first depth image to obtain a second depth image corresponding to the driving lane;
s3, converting the second depth image into point cloud information, performing ground projection according to the point cloud information to obtain target point cloud information and ground point cloud information, and deleting the ground point cloud information to obtain a projection image without a ground part;
and S4, carrying out cluster analysis on the projection image based on a growing algorithm of the adjacent area to obtain a plurality of obstacle cluster point sets, and determining the position information of each obstacle.
In step S1, a first depth image of the surroundings in the driving route is acquired. A depth map is an image or image channel containing information about the distance of the surface of the scene object from the viewpoint, each pixel value being the actual distance of the sensor from the object. In a specific embodiment of the present invention, the electronic device may acquire a first depth image of the surrounding environment in the path of travel of the robot or the unmanned vehicle. The electronic device can acquire a first depth image of the surrounding environment in the driving route by using the depth camera, and parameter calibration is carried out on the depth camera, wherein the parameter calibration comprises the focal length, the optical center and the like of the depth camera.
According to a specific embodiment of the present invention, the step S1 further includes a preprocessing step for the first depth image, where the preprocessing step includes: according to a bilateral filtering algorithm, filtering the first depth image to obtain a filtered first depth image, and ensuring the integrity of the edge of the obstacle in the first depth image through filtering; traversing from the pixel point at the upper left corner of the filtered first depth image to the lower right corner row by row, and taking each traversed pixel point as a central pixel point; comparing the depth value of each pixel point of a preset field area of the central pixel point with the depth value of the central pixel point, and recording the pixel point if the difference is larger than a preset difference threshold; counting the number of all pixel points with the difference value larger than the preset difference value threshold in the field area, and marking the number as the number of the pixel points corresponding to the central pixel point; and if the number of the pixel points corresponding to the central pixel point is greater than a preset number, the central pixel point is a flying pixel point, and the flying pixel point is removed. And filtering out the flying pixel points, so that each outlier pixel point in the first depth image can be screened out and removed. And (3) performing a processing mode of expanding and then corroding the first depth image after removing the flying pixel points, and filling the holes in the depth image.
According to a specific embodiment of the present invention, the preprocessing step further includes: and performing image interpolation processing on the first depth image to increase the resolution of the first depth image in the y-axis direction. And under the condition that the resolution ratio of the y-axis direction in the depth camera is smaller, performing image interpolation processing on the first depth image, increasing the resolution ratio of the y-axis direction, and facilitating the detection of obstacles in the subsequent depth image. This step may not be processed if the y-axis resolution given by the depth camera is sufficient.
In the step S2, the first depth image is cut, and a second depth image corresponding to the driving lane is obtained. Specifically, the first depth image is converted into a point cloud image based on a calculation method of a depth image point cloud; cutting the point cloud image in an x-axis driving lane range, cutting the point cloud image in a y-axis driving height range and cutting the point cloud image in a z-axis detection range respectively to obtain a cut point cloud image; and acquiring a second depth image corresponding to the driving lane according to the cut point cloud image. The cutting of the range of the x-axis driving lane specifically comprises: setting surplus width of a driving lane; the x-axis travel lane range is a sum of half of the vehicle width and the surplus width. The surplus width is used for ensuring that no obstacle suddenly appears in the driving lane. For example, the vehicle width is 1.2 meters, the surplus width of the driving lane refers to the surplus distance required by obstacle detection on two sides of the vehicle, the surplus width is set to be 1 meter, the depth camera is taken as the center, and the range of the x-axis driving lane is (1.2/2+1) ×2=3.2 meters. Based on the point cloud, the x coordinate of the depth camera in the point cloud is 0, and according to the calculation, the x coordinate is in the range of-1.6 to +1.6. And cutting the range of the X-axis driving lane on the point cloud picture. The cutting of the y-axis running height range is mainly set according to the height required by vehicle traffic. The cutting of the z-axis detection range is mainly set according to the running speed of the vehicle and the detection distance parameters of the depth camera. The x-axis driving lane range, the y-axis driving height range and the z-axis detection range can be changed as required. And cutting a corresponding range on the second depth image according to the cut point cloud image, and setting the pixel points which do not meet the range requirement to be 0 to obtain the second depth image corresponding to the driving lane.
In the step S3, the second depth image is converted into point cloud information, and ground projection is performed according to the point cloud information, so as to obtain target point cloud information and ground point cloud information, and the ground point cloud information is deleted, so as to obtain a projection image without a ground part. According to a specific embodiment of the present invention, the step S3 includes:
s301, performing point cloud coordinate conversion on the second depth image to obtain corresponding point cloud information;
the depth map is a coordinate in the image coordinate system (x, y) representing a pixel value of each pixel point in the image, the pixel value representing the euclidean distance of the target point from the camera. The point cloud is a massive point set expressing the target space distribution and the target surface characteristics under the same space reference system, and after the space coordinates of each sampling point of the object surface are obtained, the point set is obtained and is called as 'point cloud'. The point cloud is a 3D concept, and its coordinate system (x, y, z) is the distance of the target point from the camera in three coordinate axis directions. And according to the calculation method of the depth map conversion point cloud, carrying out point cloud coordinate conversion on the second depth image, and converting pixel points in the depth image into coordinate points under a corresponding point cloud coordinate system.
S302, carrying out coordinate conversion on the point cloud information, and converting a (x, z) coordinate system plane in the point cloud information into a state parallel to the ground;
and (3) calibrating the installation angle of the depth camera, performing coordinate conversion on the point cloud information, and converting the (x, z) coordinate system plane in the point cloud information into a state parallel to the ground.
S303, setting a plurality of grids under the (x, z) coordinate system, and projecting all pixel points in the second depth image into each grid;
the projection method is to set a series of grids in a 2D plane coordinate system with x and z axes, and the grids are to set a plurality of grids under the (x and z) coordinate system, and the length and the width of each grid are equal. And projecting all pixel points in the second depth image to the (x, z) coordinate system and projecting all pixel points to each grid under the coordinate system. According to a specific embodiment of the present invention, the number of grids in the (x, z) coordinate system is determined by the length of the z-axis in the (x, z) coordinate system and the size of the grids. The size of the grid is related to the pixel density of the second depth image, the grid being smaller as the pixel density is greater. The length of the z-axis in the (x, z) coordinate system is determined by the maximum distance of the pixels of the second depth image. The length of the z-axis and the size of the grid are determined by the maximum distance of the pixels and the pixel density of the second depth image. For example, in a depth image of 640×480, in the case of a farthest distance of 4 meters, the number of grids is generally set to 400×400 in the coordinate system, and the size of each grid is about 1cm×1cm in the world coordinate system.
S304, counting the number of projected pixel points falling in each grid, wherein if the number of the projected pixel points is larger than a preset number threshold, the projected pixel points in the grid are the projected pixel points of the target, otherwise, the projected pixel points are the projected pixel points of the ground;
and projecting all pixel points in the second depth image to the ground of each grid, wherein projected pixel points falling in the grid exist in the grid, and counting the number of the projected pixel points in the grid. Because the ground is a thin layer, the number of points in the grid projected by the ground is relatively small, and the number of projected pixels in the same grid of the target object is relatively large because of relatively large number of pixels at the same position, so that whether the points of the grid are the points of the target object or the points of the ground can be distinguished by the technical scheme. Setting a quantity threshold, if the quantity of the projected pixel points is larger than the quantity threshold, the projected pixel points in the grid are the projected pixel points of the target, otherwise, the projected pixel points or the impurity points of the ground are the projected pixel points.
And S305, deleting the projected pixel points of the ground to obtain a projected image without the ground part.
And deleting the projected pixels of the ground in the grid, wherein the rest pixels are projected pixels of the target, so that a projected image without a ground part can be obtained.
According to an embodiment of the present invention, the step S3 further includes: the projection image is inflated and eroded, and the kernel size of the inflation and erosion is determined by the depth data and adaptively adjusted. And carrying out median filtering treatment on the expanded and corroded projection image.
In the step S4, based on a neighboring area growing algorithm, a cluster analysis is performed on the projection image, a plurality of obstacle cluster point sets are obtained, and position information of each obstacle is determined. The growth field of the traditional region growing algorithm is generally four adjacent points of the traversing point. In the invention, compared with a first depth image obtained by shooting, the grid points subjected to projection processing have sparse pixel points and relatively poor continuity of target points, so that the target textures cannot be clustered normally due to the traditional region generation algorithm, and the invention adopts a neighboring region growing algorithm for cluster analysis. The extraction of the seed points of the growing algorithm of the neighboring regions is obtained by traversing the projection image from top left to bottom right, namely traversing from the original point of the projection image, starting the growth of the regions by taking the points as the seed points, and taking the grown regions as the seed points no longer when the regions are traversed later. Specifically, the origin of the projection image starts traversing, four adjacent points of the origin are firstly subjected to region growth according to the sequence from top left to bottom right, if the target cannot grow, the region growth search range is enlarged, the adjacent points of the four adjacent points of the origin are subjected to region growth, the same is pushed, and the region growth is started by taking one point as a seed point until all the points finish the region growth operation. And respectively calculating each obstacle clustering point set to obtain the minimum depth value of each obstacle in the projection image, and obtaining the nearest distance of each obstacle. And arranging all the obstacles in sequence from the near to the far according to the nearest distance of each obstacle.
According to one embodiment of the invention, the method further comprises: after the step S3, another technical scheme is adopted, and a method of associating the projection image with the depth image is adopted, so that the pixel point of the projection image is associated with the corresponding pixel point in the second depth image, the target pixel point and the ground pixel point in the second depth image are determined, and the ground pixel point is deleted, so that a third depth image without ground is obtained; and carrying out cluster analysis on the third depth image based on a region generation method, obtaining a plurality of obstacle cluster point sets, and determining the position information of each obstacle.
In one embodiment of the present invention as shown in fig. 2, the present invention provides an obstacle recognition system, the system comprising:
an acquisition module 20, configured to acquire a first depth image of a surrounding environment in a driving route;
the cutting module 21 is configured to perform cutting processing on the first depth image to obtain a second depth image corresponding to the driving lane;
the projection module 22 is configured to convert the second depth image into point cloud information, perform ground projection according to the point cloud information, obtain point cloud information of a target and point cloud information of the ground, and delete the point cloud information of the ground to obtain a projection image without a ground part;
and the clustering module 23 is used for carrying out cluster analysis on the projection images based on a neighboring area growing algorithm, obtaining a plurality of obstacle clustering point sets and determining the position information of each obstacle.
The acquisition module acquires a first depth image of the surrounding environment in the driving route, performs filtering processing on the first depth image according to a bilateral filtering algorithm to obtain a filtered first depth image, and can ensure the integrity of the edge of an obstacle in the first depth image and remove flying pixel points through filtering processing.
And the cutting module performs cutting processing on the first depth image to obtain a second depth image corresponding to the driving lane, and converts the first depth image into a point cloud image based on a calculation method of a depth image turning point cloud. Cutting the point cloud image in an x-axis driving lane range, cutting the point cloud image in a y-axis driving height range and cutting the point cloud image in a z-axis detection range respectively to obtain a cut point cloud image; and acquiring a second depth image corresponding to the driving lane according to the cut point cloud image. And cutting a corresponding range on the second depth image according to the cut point cloud image, and setting the pixel points which do not meet the range requirement to be 0 to obtain the second depth image corresponding to the driving lane.
The projection module converts the second depth image into point cloud information, performs ground projection according to the point cloud information to obtain target point cloud information and ground point cloud information, and deletes the ground point cloud information to obtain a projection image without a ground part. Converting the point cloud coordinates of the second depth image to obtain corresponding point cloud information; converting the coordinates of the point cloud information, and converting the (x, z) coordinate system plane in the point cloud information into a state parallel to the ground; setting a plurality of grids under the (x, z) coordinate system, and projecting all pixel points in the second depth image into each grid; counting the number of projected pixel points falling in each grid, wherein if the number of the projected pixel points is larger than a preset number threshold, the projected pixel points in the grid are the projected pixel points of the target, otherwise, the projected pixel points are the projected pixel points of the ground; and deleting the projected pixel points of the ground to obtain a projected image without a ground part.
And the clustering module performs cluster analysis on the projection image based on a neighboring region growing algorithm to acquire a plurality of obstacle clustering point sets and determines the position information of each obstacle. And clustering the projection images to obtain a plurality of obstacle clustering point sets, respectively calculating each obstacle clustering point set to obtain the minimum depth value of each obstacle in the projection images, and obtaining the nearest distance of each obstacle.
Although the preferred embodiments of the present invention have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the invention as disclosed in the accompanying claims.