An obstacle detection method, an image acquisition device, and a robot
By acquiring images with different focus distances and performing edge value processing, the problems of high costs and large detection blind spots in the prior art are solved, and low-cost and extensive obstacle detection is achieved.
Patent Information
- Application Number
- CN202111439619.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-11-30
AI Technical Summary
The existing distance sensors have problems such as high cost in obstacle detection and undetectable horizontal directions, and binocular cameras have defects such as large parallax and large blind spots.
Two cameras with different focus distances are used to obtain the same environmental image, and the distance of obstacles is determined by comparing the extreme points of the image edge value. The image edge value is processed using Sobel convolution factor and linear filtering to achieve low-cost obstacle detection.
It realizes low-cost obstacle detection, with a large perception range, accurate detection results, low cost and wide perception range.
Smart Images

Figure CN113962987B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent robots, and particularly relates to an obstacle detection method, an image acquisition device and a robot. Background Art
[0002] In essence, a robot perceives the external world through various sensors, among which distance sensors play an important role. The robot relies on distance sensors to detect and avoid obstacles. There are many distance sensors available on the market now, such as binocular cameras, structured light, 3D-TOF, etc. Among these distance sensors, the distance sensors that can directly detect planar shapes are relatively expensive. Although the cost of binocular cameras is relatively low, there is a problem that they cannot detect in the horizontal direction, and when the parallax is large, the blind area is also relatively large. Summary of the Invention
[0003] To solve the above problems, the present invention discloses an obstacle detection method, an image acquisition device and a robot. By adopting different focusing distances, the present application detects obstacles through clarity, with low cost and a large sensing range. The specific technical solutions are as follows:
[0004] An obstacle detection method, the method comprising the following steps: S1: enabling a first camera and a second camera to respectively acquire images of the same environment, wherein the first camera and the second camera have different focusing distances; S2: performing image processing on the images of the first camera and the second camera to obtain edge values in the images of the first camera and the second camera; S3: respectively dividing the images of the first camera and the second camera into several blocks, and then obtaining edge calculation values of each block through the edge values of each block; S4: comparing the edge calculation values of the same blocks in the images of the first camera and the second camera, and then determining the distance relationship between the robot and the obstacle according to the comparison result.
[0005] Further, in step S2, performing image processing on the images of the first camera and the second camera to obtain edge values in the images of the first camera and the second camera comprises the following steps: setting Sobel convolution factors, and then performing planar convolution on the image of the first camera or the second camera with the Sobel convolution factors to obtain horizontal and vertical image gray values of the image of the first camera or the second camera, and adding the horizontal and vertical edge values to obtain the total edge value of the image.
[0006] Further, in step S3, the images of the first camera and the second camera are respectively divided into a plurality of blocks, and then the edge calculation value of each block is obtained through the edge value of each block, including the following steps: dividing the image processing result of the first camera or the second camera into N*M blocks of the same size, and then taking the average value of the edge values of each block as the edge calculation value; where N and M are positive integers.
[0007] Further, in step S3, after obtaining the edge calculation value of each block through the edge value of each block, linear filtering is performed on the edge calculation values of the blocks of the images of the first camera and the second camera.
[0008] Further, the linear filtering performed on the edge calculation values of the blocks of the images of the first camera and the second camera is mean filtering, including the following steps: setting a calculation template of A*A, then taking each block as the center of the calculation template in turn, and then taking the average value of the edge calculation values in the calculation template as the edge calculation value of the block; where A is an odd number.
[0009] Further, the focusing distance of the first camera is the hyperfocal distance, the focusing distance of the second camera is the set distance, and the focusing distance of the first camera is greater than the focusing distance of the second camera.
[0010] Further, in step S4, comparing the edge calculation values of the same blocks in the images of the first camera and the second camera includes the following steps: comparing the edge calculation values of the same blocks in the images of the first camera and the second camera, if the edge calculation value in the image of the second camera is greater than the edge calculation value in the same block of the image of the first camera, then set the block of the image of the second camera as the near-point block; if the number of near-point blocks is greater than the number threshold, then determine that the distance relationship between the robot and the obstacle is a distance that requires obstacle avoidance.
[0011] Further, if the difference between the edge calculation values of the same blocks in the images of the first camera and the second camera is within the set range, then determine that the distance relationship between the robot and the obstacle is a distance that requires deceleration.
[0012] An image acquisition device, the image acquisition device includes a first camera and a second camera, the first camera and the second camera are arranged in parallel and attached, the focusing distance of the first camera is the hyperfocal distance, the focusing distance of the second camera is the set distance, and the focusing distance of the first camera is greater than the focusing distance of the second camera.
[0013] A robot, the robot is provided with the above-mentioned image acquisition device, and the robot executes the above-mentioned obstacle detection method based on image comparison through the image acquisition device.
[0014] Compared with the existing technologies, the technical solution of this application obtains images of the same environment through two cameras with different focusing distances, and then determines which camera obtains a clearer image by comparing the extreme points of the edge values in the images, so as to determine the distance between the robot and the obstacle. It has low cost and a large sensing range. Brief Description of the Drawings
[0015] Figure 1 It is a flowchart of the obstacle detection method described in an embodiment of the present invention. Detailed Embodiments
[0016] In order to make the objectives, technical solutions and advantages of this application clearer, the following describes and explains this application in combination with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit this application. Based on the embodiments provided in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope protected by this application.
[0017] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "including", "comprising", etc. used herein indicate the presence of the described features, operations and / or components, but do not exclude the presence or addition of one or more other features, operations or components. All terms (including technical and scientific terms) used herein have the meanings commonly understood by those of ordinary skill in the art, unless otherwise defined. It should be noted that the terms used here should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0018] As Figure 1 shown, an obstacle detection method based on image comparison mainly sets two cameras to different focusing distances, one for far and the other for near. The two cameras simultaneously obtain images of the same environment. When the object is relatively close, the camera focused on the near distance sees more clearly, and the camera focused on the far distance sees blurrily. By comparing the clarity, the distance of the object can be known. The method includes the following steps:
[0019] Step S1: The robot enables the first camera and the second camera to respectively acquire images of the same environment, where the focusing distances of the first camera and the second camera are different. The robot controls the first camera and the second camera to work simultaneously to acquire images of the same environment. When working simultaneously, it can minimize the difference between the images acquired by the first camera and the second camera during the movement of the robot, making the calculation results more accurate. The robot can also enable the first camera and the second camera to work successively according to time to acquire images of the same environment, which can also avoid the mutual influence between the cameras. The first camera and the second camera can use the VGA video transmission standard to transmit the acquired images, and the resolution of the acquired images is 640x480. The first camera and the second camera can also use other image transmission standards, formats and resolutions, which are not limited.
[0020] Step S2: The robot performs image processing on the images of the first camera and the second camera to obtain the edge values in the images of the first camera and the second camera. The edge is the mutation point of information such as grayscale or structure. The edge is the end of one block and the beginning of another block. Using this feature can segment the image. The edge value is a point in the image with coordinates [x, y] and located at a position with a significant change in intensity.
[0021] As one of the embodiments, in step S2, when the robot performs image processing on the images of the first camera and the second camera to obtain the edge values in the images of the first camera and the second camera, it includes the following steps: Set the Sobel convolution factor, and then perform planar convolution on the image of the first camera or the second camera with the Sobel convolution factor to obtain the horizontal and vertical image grayscale values of the image of the first camera or the second camera. Add the horizontal and vertical edge values to obtain the total edge value of the image; It is also possible to obtain the gradient value of each pixel point in the image according to the coordinates of the pixel points of the image and the horizontal and vertical image grayscale values of the image. When calculating the gradient value, the gradient value can be the square root of the sum of the square of the horizontal image grayscale value of the image and the square of the vertical image grayscale value of the image, and the gradient value can also be the sum of the absolute value of the horizontal image grayscale value of the image and the absolute value of the vertical image grayscale value of the image. Then set the pixel points with gradient values greater than the set threshold as the edge points of the image, and the gradient value of this edge point is the edge value of the edge point. This method uses the Sobel operator. Technically, it is a discrete difference operator used to calculate the approximate value of the grayscale of the image brightness function. Using this operator at any point in the image will generate the corresponding grayscale vector or its normal vector, mainly used for edge detection, and can be considered as the measurement of the change of the image in the vertical and horizontal directions. The method for obtaining the edge value is not unique, and other image processing methods can also be used to obtain the edge value of the image.
[0022] Step S3: The robot divides the images of the first camera and the second camera into several blocks respectively, and then obtains the edge calculation value of each block through the edge value of each block. In step S3, the images of the first camera and the second camera are divided into several blocks respectively, and then the edge calculation value of each block is obtained through the edge value of each block, including the following steps: dividing the image processing result of the first camera or the second camera into N*M blocks of the same size, and then taking the average value of the edge values of each block as the edge calculation value; where N and M are positive integers. For example, the image is divided into 16*12 blocks, and then the average value of the edge values in each block is obtained as the edge calculation value. If there is no edge value in a block, there is no need to find the edge calculation value in this block. It is also possible to use values such as the maximum value or the median value of the edge values in each block as the edge calculation value of each block.
[0023] As one of the embodiments, in step S3, after the robot obtains the edge calculation value of each block through the edge value of each block, linear filtering is performed on the edge calculation values of the blocks of the images of the first camera and the second camera. The linear filtering of the edge calculation values of the blocks of the images of the first camera and the second camera is mean filtering, including the following steps: setting a calculation template of A*A, then taking each block as the center of the calculation template in turn, and then taking the average value of the edge calculation values in the calculation template as the edge calculation value of the block; where A is an odd number. For example, a 5*5 calculation template is set. This calculation template includes 25 grids of the same size as the image block. Then, one of the blocks is used as the central grid of the calculation template. The calculation template is placed in the image, and the grids of the calculation template coincide partially or completely with the block part of the image. Then, the average value of the extreme points in the range of the calculation template is used to replace the extreme point of the central grid. The extreme points of the blocks of the images of the first camera and the second camera are replaced in turn to achieve the mean filtering of the extreme points of the image. After the edge values of both images are found, a comparison of the edge value intensities is required. Although the two cameras are relatively close, there is still a certain distance and they cannot completely correspond. At the same time, we do not need such high precision when calculating obstacle information. Therefore, filtering is performed on the extreme points. Other linear filtering methods such as box filtering or Gaussian filtering can also be used. Filtering the edge calculation values is mainly to make the calculation results more accurate.
[0024] Step S4: The robot compares the edge calculation values of the same blocks in the images of the first camera and the second camera, and then determines the distance relationship between the robot and the obstacle according to the comparison result. The focusing distance of the first camera is the hyperfocal distance, the focusing distance of the second camera is the set distance, and the focusing distance of the first camera is greater than that of the second camera. In step S4, comparing the edge calculation values of the same blocks in the images of the first camera and the second camera includes the following steps: comparing the edge calculation values of the same blocks in the images of the first camera and the second camera. If the extreme point in the image of the second camera is greater than the extreme point in the same block of the image of the first camera, then set the extreme point of the image of the second camera as the near point; if the number of near points is greater than the number threshold, then determine that the distance relationship between the robot and the obstacle is a distance that requires obstacle avoidance. If the difference between the extreme points of the same blocks in the images of the first camera and the second camera is within the set range, that is, the ratio of the extreme points of the same blocks of the two is close to 1, then determine that the distance relationship between the robot and the obstacle is a distance that requires deceleration. When the extreme point in the image of the second camera is less than or equal to the extreme point in the same block of the image of the first camera, it means that the robot is far from the obstacle and can be ignored. The two cameras are set with different focusing distances, one for the far distance and the other for the near distance. When the object is relatively close, the camera focused on the near distance can see more clearly, and the camera focused on the far distance will look blurry. By comparing the clarity, the distance of the object can be known.
[0025] An image acquisition device, the image acquisition device includes a first camera and a second camera, the first camera and the second camera are arranged in parallel and attached, that is, the two cameras are as close as possible, so that the images obtained by the two cameras are the same environmental image. The focusing distance of the first camera is the hyperfocal distance, the focusing distance of the second camera is the set distance, and the focusing distance of the first camera is greater than that of the second camera. The set distance is the optimal object distance expected to be detected, for example, 15 cm.
[0026] A robot, the robot is provided with the above-mentioned image acquisition device, and the robot executes the above-mentioned obstacle detection method based on image comparison through the image acquisition device.
[0027] Compared with the existing technology, the technical solution of the present application obtains the same environmental image through two cameras with different focusing distances, and then determines which camera obtains a clearer image by comparing the extreme points of the edge values in the image, so as to determine the distance between the robot and the obstacle. It has low cost and a large sensing range.
[0028] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0029] The above embodiments only represent several embodiments of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of this application, several modifications and improvements can still be made, and these all belong to the protection scope of this application.
Claims
1. An obstacle detection method, characterized in that The method includes the following steps: S1: Enable the first camera and the second camera to respectively obtain images of the same environment, wherein the focusing distances of the first camera and the second camera are different; S2: Perform image processing on the images of the first camera and the second camera to obtain the edge values in the images of the first camera and the second camera; S3: Divide the images of the first camera and the second camera into several blocks respectively, and then obtain the edge calculation value of each block through the edge value of each block; S4: Compare the edge calculation values of the same blocks in the images of the first camera and the second camera, and then determine the distance relationship between the robot and the obstacle according to the comparison result; Among them, in step S2, performing image processing on the images of the first camera and the second camera to obtain the edge values in the images of the first camera and the second camera includes the following steps: Set the Sobel convolution factor, and then perform planar convolution on the image of the first camera or the second camera with the Sobel convolution factor to obtain the horizontal and vertical image gray values of the image of the first camera or the second camera, and add the horizontal and vertical edge values to obtain the total edge value of the image; Among them, in step S3, dividing the images of the first camera and the second camera into several blocks respectively, and then obtaining the edge calculation value of each block through the edge value of each block includes the following steps: Divide the image processing result of the first camera or the second camera into N*M blocks of the same size, and then use the average value of the edge values of each block as the edge calculation value; where N and M are positive integers.
2. The obstacle detection method according to claim 1, wherein In step S3, after obtaining the edge calculation value of each block through the edge value of each block, perform linear filtering on the edge calculation values of the blocks of the images of the first camera and the second camera.
3. The obstacle detection method according to claim 2, characterized in that Performing linear filtering on the edge calculation values of the blocks of the images of the first camera and the second camera is mean filtering, including the following steps: Set an A*A calculation template, then use each block as the center of the calculation template in turn, and then use the average value of the edge calculation values in the calculation template as the edge calculation value of the block; Among them, A is an odd number.
4. The obstacle detection method according to claim 1, wherein, The focusing distance of the first camera is the hyperfocal distance, the focusing distance of the second camera is the set distance, and the focusing distance of the first camera is greater than the focusing distance of the second camera.
5. The obstacle detection method according to claim 4, wherein In step S4, comparing the edge calculation values of the same blocks in the images of the first camera and the second camera includes the following steps: Compare the edge calculation values of the same blocks in the images of the first camera and the second camera. If the edge calculation value in the image of the second camera is greater than the edge calculation value in the same block of the image of the first camera, then set the block of the image of the second camera as the near-point block; If the number of near-point blocks is greater than the number threshold, then determine that the distance relationship between the robot and the obstacle is the distance that requires obstacle avoidance.
6. The obstacle detection method according to claim 5, wherein If the difference between the edge calculation values of the same blocks in the images of the first camera and the second camera is within the set range, then determine that the distance relationship between the robot and the obstacle is the distance that requires deceleration.
7. An image acquisition device, characterized in that, The image acquisition device includes a first camera and a second camera, the first camera and the second camera are arranged in parallel and attached, the focusing distance of the first camera is the hyperfocal distance, the focusing distance of the second camera is a set distance, and the focusing distance of the first camera is greater than the focusing distance of the second camera.
8. A robot, characterized in that, The robot is provided with the image acquisition device according to claim 7, and the robot executes the obstacle detection method according to any one of claims 1 to 6 through the image acquisition device.
Citation Information
Patent Citations
Obstacle avoidance method and device, and drone
CN108323190A
Method and device for detecting imaging difference, and computer storage medium
WO2017206444A1