CN110866903A - Ping-pong ball identification method based on Hough circle transformation technology - Google Patents
Ping-pong ball identification method based on Hough circle transformation technology Download PDFInfo
- Publication number
- CN110866903A CN110866903A CN201911086761.2A CN201911086761A CN110866903A CN 110866903 A CN110866903 A CN 110866903A CN 201911086761 A CN201911086761 A CN 201911086761A CN 110866903 A CN110866903 A CN 110866903A
- Authority
- CN
- China
- Prior art keywords
- table tennis
- image
- ball
- circle
- robot
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 40
- 230000009466 transformation Effects 0.000 title claims description 8
- 238000012545 processing Methods 0.000 claims abstract description 25
- 238000001914 filtration Methods 0.000 claims abstract description 10
- 238000000605 extraction Methods 0.000 claims abstract description 9
- 238000004422 calculation algorithm Methods 0.000 claims description 8
- 230000000694 effects Effects 0.000 claims description 6
- 230000003628 erosive effect Effects 0.000 claims description 5
- 230000000007 visual effect Effects 0.000 claims description 4
- 238000004364 calculation method Methods 0.000 claims description 3
- 238000005260 corrosion Methods 0.000 claims description 3
- 230000007797 corrosion Effects 0.000 claims description 3
- 230000007613 environmental effect Effects 0.000 claims description 3
- 238000002474 experimental method Methods 0.000 claims description 3
- 238000005457 optimization Methods 0.000 claims description 3
- 238000003672 processing method Methods 0.000 claims description 3
- 238000009825 accumulation Methods 0.000 claims 3
- 239000000284 extract Substances 0.000 claims 1
- 238000009499 grossing Methods 0.000 claims 1
- 238000012216 screening Methods 0.000 claims 1
- 230000008961 swelling Effects 0.000 claims 1
- 238000011426 transformation method Methods 0.000 claims 1
- 238000001514 detection method Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 238000012360 testing method Methods 0.000 description 3
- 238000011897 real-time detection Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 239000003086 colorant Substances 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/44—Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20048—Transform domain processing
- G06T2207/20061—Hough transform
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Quality & Reliability (AREA)
- Image Processing (AREA)
- Image Analysis (AREA)
Abstract
本发明公开了一种基于霍夫圆变换技术的乒乓球识别方法,用梯度Hough变换的方法来提高识别速度。包括以下步骤,1)图像灰度化处理;2)滤波处理;3)边缘提取;4)乒乓球标记;5)乒乓球识别的特殊处理及关参数的设置。相比于现有技术,本发明对于摄像头中读入的图片,可以实现实时识别每帧图片中所包含的乒乓球,能在复杂情况下准确识别乒乓球。
The invention discloses a table tennis identification method based on the Hough circle transform technology, which uses the gradient Hough transform method to improve the identification speed. It includes the following steps: 1) image grayscale processing; 2) filtering processing; 3) edge extraction; 4) table tennis ball marking; Compared with the prior art, the present invention can realize real-time identification of the table tennis balls contained in each frame of pictures for the pictures read in the camera, and can accurately identify the table tennis balls in complex situations.
Description
技术领域technical field
本发明属于机器人技术领域,具体涉及一种通过霍夫圆变换技术的乒乓球识别方法。The invention belongs to the technical field of robots, and in particular relates to a method for identifying a table tennis ball through the Hough circle transformation technology.
背景技术Background technique
为了配合捡乒乓球机器人工作,实现捡乒乓球机器人自动识别乒乓球的功能,设计一种能够在连续图像中识别、跟踪乒乓球的方法是尤为重要。目前,识别乒乓球的算法大多数停留对于给定的一张图片,从中能标注出乒乓球。这种方法在背景复杂的乒乓球场内容易受到杂物干扰,在画面存在轻微撕裂、噪点的情况下无法保证识别乒乓球的准确率。In order to cooperate with the ping-pong ball picking robot and realize the function of automatic recognition of ping-pong balls by the ping-pong ball-picking robot, it is particularly important to design a method that can recognize and track table tennis balls in continuous images. Currently, most algorithms for identifying ping-pong balls are limited to a given image, from which ping-pong balls can be labeled. This method is easily disturbed by debris in the table tennis court with complex background, and cannot guarantee the accuracy of identifying table tennis balls when there is slight tearing and noise in the picture.
针对上述问题,本发明提出一种基于霍夫圆变换技术的乒乓球识别方法,能配合捡乒乓球机器人对视频实现实时识别乒乓球。这种算法可在背景复杂的乒乓球场内排除杂物干扰,在画面存在轻微撕裂、噪点的情况下依然保证识别乒乓球的准确率。In view of the above problems, the present invention proposes a table tennis ball recognition method based on the Hough circle transform technology, which can cooperate with a table tennis ball picking robot to realize real-time recognition of table tennis balls on video. This algorithm can eliminate the interference of debris in the table tennis court with complex background, and still ensure the accuracy of identifying table tennis balls in the case of slight tearing and noise in the picture.
Hough变换的方法识别圆的原理如下:The principle of Hough transform method to identify circles is as follows:
设通过分辨率为M*N的视觉传感器采集到的图像为f(x,y),则圆的一般方程可以用公式Assuming that the image collected by the vision sensor with a resolution of M*N is f(x,y), the general equation of the circle can be expressed by the formula
(x-a)2+(y-b)2=r2 (xa) 2 +(yb) 2 =r 2
来表示,其中(a,b)为圆心,r为圆的半径。经典Hough变换把X-Y平面上的圆转换到a-b-r参数空间,则图像空间中同一圆上的点所对应于参数空间中所有三维锥面必然交于一点,然后通过对该点的投票可以得判断结果是否为圆。to represent, where (a, b) is the center of the circle and r is the radius of the circle. The classic Hough transform converts the circle on the X-Y plane to the a-b-r parameter space, then all the three-dimensional cones in the parameter space corresponding to the points on the same circle in the image space must intersect at a point, and then the judgment result can be obtained by voting on this point. Whether it is a circle.
这种方法可靠性高,受噪声、变形、曲线间断的影响较小,但也存在明显的缺陷:内存占用大、计算量大,因此难以满足实时对圆的检测。同时由于本发明是应用于移动机器人平台上,受硬件条件限制,以及对实时检测要求较高,所以本实例采用了梯度Hough变换的方法来提高识别速度。This method has high reliability and is less affected by noise, deformation and curve discontinuity, but it also has obvious defects: large memory usage and large amount of calculation, so it is difficult to meet the real-time detection of circles. At the same time, because the present invention is applied to the mobile robot platform, limited by hardware conditions, and has high requirements for real-time detection, the gradient Hough transform method is adopted in this example to improve the recognition speed.
发明内容SUMMARY OF THE INVENTION
为了实现捡乒乓球机器人自动识别摄像头检测到的乒乓球的功能,本发明专利提出了一种基于霍夫圆变换技术的乒乓球识别方法,对于在摄像头视野内且符合约束条件的乒乓球,可以在画面上对其进行标记,实现识别乒乓球的功能。In order to realize the function of automatically recognizing the ping-pong ball detected by the camera by the ping-pong ball picking robot, the patent of the present invention proposes a table-tennis ball recognition method based on the Hough circle transform technology. Mark it on the screen to realize the function of identifying table tennis.
基于霍夫圆变换技术的乒乓球识别方法,采用梯度Hough变换的方法来提高识别速度。以极坐标方程The table tennis recognition method based on Hough circle transform technology adopts the gradient Hough transform method to improve the recognition speed. in polar coordinates
A=x-r cosθ,B=y-r sinθ (1)A=x-r cosθ, B=y-r sinθ (1)
来表示圆,其中,x和y为当前像素点的坐标,r为半径,θ为梯度方向角,A和B为计算得到的可能的圆心坐标。to represent a circle, where x and y are the coordinates of the current pixel point, r is the radius, θ is the gradient direction angle, and A and B are the calculated possible circle center coordinates.
基于Hough变换技术的乒乓球识别方法,包括以下步骤:The table tennis identification method based on Hough transform technology includes the following steps:
步骤1.图像灰度化处理Step 1. Image grayscale processing
机器人的处理器可以持续不断地通过视觉传感器获得前方的图像,然后对读入的图片进行预处理。采用平均值法对图像进行灰度化处理。设彩色图像三分量分别为R(x,y),G(x,y),B(x,y)则灰度化处理后,图像的灰度值Gray(x,y)可以表示为:The robot's processor can continuously obtain images of the front through the vision sensor, and then preprocess the read images. The image is grayed by the average method. Assuming that the three components of the color image are R(x,y), G(x,y), and B(x,y) respectively, after the grayscale processing, the grayscale value of the image Gray(x,y) can be expressed as:
步骤2.滤波处理Step 2. Filter processing
灰度化处理之后,对图像进行滤波处理以抑制噪声、减少环境干扰,提高目标乒乓球的边缘清晰度。本发明采用了中值滤波的方式,对模板中的数据由小到大排序,取排在中间位置上的数据作为最终的处理结果。经过中值滤波后的输出为:After the grayscale processing, the image is filtered to suppress noise, reduce environmental interference, and improve the edge definition of the target table tennis ball. The present invention adopts the mode of median filtering, sorts the data in the template from small to large, and takes the data in the middle position as the final processing result. The output after median filtering is:
g(x,y)=Med{f(x-k,y-l),(k,l)∈W} (3)g(x,y)=Med{f(x-k,y-l),(k,l)∈W} (3)
其中,f(x,y)、g(x,y)分别为原图像和处理后的图像,W为二维滑动窗口,一般从3*3、5*5中选择。Among them, f(x,y) and g(x,y) are the original image and the processed image respectively, and W is a two-dimensional sliding window, which is generally selected from 3*3 and 5*5.
步骤3.边缘提取Step 3. Edge Extraction
本发明采用基于梯度Hough变换的方法找到圆心,再通过Canny算法实现对乒乓球边缘的提取。梯度Hough变换寻找圆心坐标的步骤为:The invention adopts the method based on the gradient Hough transform to find the center of the circle, and then realizes the extraction of the edge of the table tennis ball through the Canny algorithm. The steps of gradient Hough transform to find the coordinates of the circle center are:
3.1利用梯度公式计算原图像的梯度值,并将图像进行二值化。3.1 Using the gradient formula Calculate the gradient value of the original image and binarize the image.
3.2求图像中梯度值不为0的像素点的梯度方向角θ,然后利用式(1)求可能为圆心的像素点的坐标。3.2 Find the gradient direction angle θ of the pixels whose gradient value is not 0 in the image, and then use the formula (1) to find the coordinates of the pixels that may be the center of the circle.
步骤3.3遍历图像中所有梯度值不为0的像素点,按照步骤3.2的方式求所有可能为圆心的点,并对每个点进行投票。Step 3.3 traverse all the pixels in the image whose gradient value is not 0, find all the points that may be the center of the circle according to the method of step 3.2, and vote for each point.
3.4对整幅图像扫描完毕后,得票最高的点就是待检测圆的圆心。3.4 After scanning the entire image, the point with the highest votes is the center of the circle to be detected.
步骤4.乒乓球标记Step 4. Ping Pong Ball Markers
对于检测到乒乓球的某一帧图像,以图像左上角为原点、每个像素为一个单位长度,将图像中每一个圆的坐标、半径标记在图像上。依据近大远小的物理规则,筛选出距离机器人最近的乒乓球,将这个球的x、y坐标和半径传递给处理器,进行收集操作。For a certain frame of image in which a ping-pong ball is detected, take the upper left corner of the image as the origin and each pixel as a unit length, and mark the coordinates and radius of each circle in the image on the image. According to the physical rules of near big and far small, the table tennis ball closest to the robot is screened out, and the x, y coordinates and radius of the ball are passed to the processor for collection operation.
步骤5.乒乓球识别的特殊处理及关参数的设置Step 5. Special processing of table tennis identification and setting of relevant parameters
5.1乒乓球遮挡情况处理方法5.1 Processing method of table tennis occlusion
在实际情况下,可能会发生多个乒乓球互相遮挡、距离机器人过远或过近等情况。所以在进行Hough变换后,需要对两个圆心之间的最小距离、累加平面对是否是圆的判定阈值、检测到的圆的半径的最大值和最小值等参数进行设置。In practical situations, it may happen that multiple ping pong balls block each other, or are too far or too close to the robot. Therefore, after Hough transform is performed, it is necessary to set parameters such as the minimum distance between the centers of the two circles, the threshold for determining whether the accumulated plane pair is a circle, and the maximum and minimum radius of the detected circles.
本发明在调整参数时,选用2m*2m的黑色橡胶场地;捡球装置入口宽15cm,视觉传感器的最大分辨率为640*480,照射广度为70°,照射长度50cm,可识别乒乓球的距离范围为机器人前方20cm-70cm.在此范围内,可识别出的乒乓球最大半径为80像素、最小半径为15像素。由于乒乓球距离机器人过远时收集成功率不高,所以本实例中,将检测到的圆的半径的最大像素值和最小像素值设置为80和30。因本实例测试时使用的场地为黑色纯色橡胶垫,反光情况不严重,非乒乓球物体对于检测效率的影响并不大,所以累加平面对是否是圆的判定阈值分别设置为1,处于一个较为常规的适中状态。如果两个乒乓球重叠过多,可能会出现摄像头无法识别捕捉到的乒乓球的情况,且在此条件下,乒乓球的半径通常为80像素,所以两个圆心之间的最小距离设置为120像素,不影响识别效果,且能很好的限制乒乓球重叠情况。When adjusting the parameters, the present invention selects a black rubber field of 2m*2m; the entrance of the ball picking device is 15cm wide, the maximum resolution of the visual sensor is 640*480, the irradiation width is 70°, and the irradiation length is 50cm, which can identify the distance of the table tennis ball. The range is 20cm-70cm in front of the robot. Within this range, the maximum radius of the ping-pong ball that can be recognized is 80 pixels, and the minimum radius is 15 pixels. Since the collection success rate is not high when the table tennis ball is too far away from the robot, in this example, the maximum pixel value and the minimum pixel value of the radius of the detected circle are set to 80 and 30. Because the field used in the test in this example is a black solid-color rubber pad, the reflection is not serious, and the non-ping-pong object has little influence on the detection efficiency, so the judgment thresholds of whether the accumulated plane is a circle are set to 1, which is in a relatively low level. Normal moderate state. If the two ping-pong balls overlap too much, the camera may not recognize the captured ping-pong ball, and under this condition, the radius of the ping-pong ball is usually 80 pixels, so the minimum distance between the two circle centers is set to 120 pixels, does not affect the recognition effect, and can well limit the overlap of table tennis balls.
5.2配合捡乒乓球机器人工作时的参数设置5.2 Parameter setting when working with the table tennis robot
为了更好地配合捡球装置完成捡球动作、提高捡球效率,在此基础上要求乒乓球进入捡球器的位置尽可能居中,以避免因乒乓球触碰到捡球器左、右边缘而被推离机器人,导致无法捡球的状况。在本实例中,因捡球装置入口为15cm,摄像头像素为640*480,照射广度为70°,可照射范围大于捡球装置入口范围;捡球范围为机器人前20cm到70cm,现实中的直线在摄像头中照射到的画面为梯形,为了能使最远处70cm的乒乓球也能被成功收集,经过多次实验,最终确定当乒乓球圆心位于x轴上160像素到480像素之间才进行收集。若在可收集范围外识别到乒乓球,则驱动机器人进行相应的姿态调整,使得乒乓球圆心进入可收集范围内并进行收集。In order to better cooperate with the ball pick-up device to complete the pick-up action and improve the pick-up efficiency, on this basis, it is required that the position where the table tennis ball enters the pick-up device is as centered as possible to avoid the table tennis ball touching the left and right edges of the pick-up device. And was pushed away from the robot, resulting in a situation where the ball could not be picked up. In this example, because the entrance of the ball picking device is 15cm, the pixels of the camera are 640*480, and the irradiation width is 70°, the irradiable range is larger than the entrance range of the ball picking device; the ball picking range is 20cm to 70cm in front of the robot, and the real straight line The picture illuminated by the camera is a trapezoid. In order to enable the table tennis balls with the farthest distance of 70cm to be successfully collected, after many experiments, it is finally determined that the table tennis ball center is located between 160 pixels and 480 pixels on the x-axis. collect. If the table tennis ball is recognized outside the collectible range, the robot is driven to adjust the posture accordingly, so that the center of the table tennis ball enters the collectible range and is collected.
5.3乒乓球识别优化处理5.3 Optimization Processing of Table Tennis Recognition
实际的乒乓球场地中干扰因素较少,但为了在较为复杂的环境中也能保证检测乒乓球的准确率,可以选择性地对图片进行进一步的处理来消除背景所带来的影响,例如腐蚀、膨胀等。There are few interference factors in the actual table tennis field, but in order to ensure the accuracy of table tennis detection in a more complex environment, the picture can be selectively further processed to eliminate the influence of the background, such as corrosion , expansion, etc.
对灰度图进行腐蚀、膨胀操作可以分别用公式(4)、(5)来表示:Erosion and expansion of grayscale images can be expressed by formulas (4) and (5) respectively:
fob=min{fx-b(x),x∈D(b)} (4)fob=min{f x -b(x),x∈D(b)} (4)
fgb=max{fx+b(x),x∈D(b)} (5)fgb=max{f x +b(x),x∈D(b)} (5)
其中,D(b)结构元素b的模板区域。where D(b) is the template region of structural element b.
使用开、闭操作来实现提高识别乒乓球准确率的目的。开运算是对图像先腐蚀后膨胀的过程,可以用来消除小黑点、在纤细点处分离物体、平滑较大物体的边界,同时并不明显改变其面积;闭运算对图像先膨胀后腐蚀的过程,可以用来排除小黑洞。Open and close operations are used to achieve the purpose of improving the accuracy of identifying table tennis balls. The open operation is a process of first eroding and then expanding the image. It can be used to eliminate small black spots, separate objects at thin points, and smooth the boundaries of larger objects without significantly changing their area. The closed operation first expands and then erodes the image. process that can be used to exclude small black holes.
附图说明Description of drawings
图1为本发明的方法流程图Fig. 1 is the method flow chart of the present invention
图2为乒乓球灰度图Figure 2 is a grayscale image of a table tennis ball
图3为中值滤波处理乒乓球后的中值滤波图Figure 3 is the median filter diagram after the table tennis ball is processed by the median filter
图4为Canny算法边缘提取结果图Figure 4 shows the edge extraction result of the Canny algorithm
图5为修改双阈值后的效果图Figure 5 is the effect diagram after modifying the double threshold
图6为乒乓球标记示例图Figure 6 is an example diagram of table tennis marking
图7为未使用开闭操作的检测结果Figure 7 shows the detection results without using the opening and closing operation
图8为使用开闭操作后的检测结果Figure 8 shows the detection results after using the opening and closing operation
具体实施方式Detailed ways
基于Hough变换技术的乒乓球识别方法,具体实现方法的流程图如图1所示。包括以下步骤:The table tennis identification method based on the Hough transform technology, the flow chart of the specific implementation method is shown in Figure 1. Include the following steps:
步骤1.图像灰度化处理Step 1. Image grayscale processing
在本发明的实例中,视觉传感器的分辨率为640*480像素。通过视觉传感器,机器人的处理器可以持续不断地获得视觉传感器前方的图像,然后对读入的图片进行预处理。首先对图片进行灰度化处理,本发明采用了平均值法灰度化。设彩色图像三分量分别为R(x,y),G(x,y),B(x,y)则灰度化处理后,图像的灰度值Gray(x,y)可以表示为:In the example of the present invention, the resolution of the vision sensor is 640*480 pixels. Through the vision sensor, the robot's processor can continuously obtain the image in front of the vision sensor, and then preprocess the read image. First, grayscale processing is performed on the picture, and the present invention adopts the grayscale method of the average value. Assuming that the three components of the color image are R(x,y), G(x,y), and B(x,y) respectively, after the grayscale processing, the grayscale value of the image Gray(x,y) can be expressed as:
其原理是将彩色图像中的三分量亮度求平均从而得到灰度值,即在RGB模型中,计算一个像素点的R、G、B三种颜色的值的平均值,用这个值来表示这该像素点的灰度值,这样使得彩色图像转变为灰色图像,减少了一定的计算量。The principle is to average the brightness of the three components in the color image to obtain the gray value, that is, in the RGB model, calculate the average value of the three colors of R, G, and B of a pixel, and use this value to represent this value. The gray value of the pixel point, so that the color image is converted into a gray image, which reduces a certain amount of calculation.
读取一张乒乓球RGB三色分量的原图,此时每一个像素点的颜色均由R(x,y),G(x,y),B(x,y)三个值来表示。对此图进行灰度化处理得到图2,此时每个像素点的颜色只由一个值Gray(x,y)来表示,可以降低图像处理的运算量。Read the original image of the RGB three-color components of a table tennis ball. At this time, the color of each pixel is represented by three values of R(x,y), G(x,y), and B(x,y). Grayscale processing is performed on this image to obtain Figure 2. At this time, the color of each pixel is represented by only one value, Gray(x, y), which can reduce the computational complexity of image processing.
步骤2.滤波处理Step 2. Filter processing
灰度化处理后,考虑到在实际场景中存在光线干扰,且视觉传感器拍摄、压缩图像、传输过程中带来了噪声,因此需要对图像进行滤波处理,目的是为了抑制噪声、减少环境干扰,提高目标乒乓球的边缘清晰度。在本发明采用了中值滤波的方式,对模板中的数据由小到大排序,取排在中间位置上的数据作为最终的处理结果。经过中值滤波后的输出为:After grayscale processing, considering that there is light interference in the actual scene, and the visual sensor captures, compresses the image, and brings noise during the transmission process, it is necessary to filter the image. The purpose is to suppress noise and reduce environmental interference. Improves the edge definition of the target ping pong ball. In the present invention, the method of median filtering is adopted, the data in the template is sorted from small to large, and the data in the middle position is taken as the final processing result. The output after median filtering is:
g(x,y)=Med{f(x-k,y-l),(k,l)∈W} (3)g(x,y)=Med{f(x-k,y-l),(k,l)∈W} (3)
其中,f(x,y)、g(x,y)分别为原图像和处理后的图像,W为二维滑动窗口,一般从3*3、5*5中选择,本实例选择以3*3的滑动窗口进行滤波。由图3可以看出,经过中值滤波处理后,图像上的噪点少了很多,图像也平滑了许多,便于下一步的处理。Among them, f(x,y), g(x,y) are the original image and the processed image respectively, W is a two-dimensional sliding window, generally selected from 3*3, 5*5, in this example, 3* 3 sliding windows for filtering. It can be seen from Figure 3 that after the median filtering process, the noise on the image is much less, and the image is also much smoother, which is convenient for the next processing.
步骤3.边缘提取Step 3. Edge Extraction
接下来就可以对图中的乒乓球进行边缘提取。本发明的实例中采用了基于梯度Hough变换的方法找到圆心,再通过Canny算法实现对乒乓球边缘的提取。梯度Hough变换寻找圆心坐标的思路为:Next, edge extraction can be performed on the ping-pong ball in the figure. In the example of the present invention, the method based on the gradient Hough transform is used to find the center of the circle, and then the edge of the table tennis ball is extracted by the Canny algorithm. The idea of gradient Hough transform to find the coordinates of the center of the circle is:
3.1利用梯度公式计算原图像的梯度值,并将图像进行二值化。3.1 Using the gradient formula Calculate the gradient value of the original image and binarize the image.
3.2求图像中梯度值不为0的像素点的梯度方向角θ,然后利用式(1)求可能为圆心的像素点的坐标。3.2 Find the gradient direction angle θ of the pixels whose gradient value is not 0 in the image, and then use the formula (1) to find the coordinates of the pixels that may be the center of the circle.
3.3遍历图像中所有梯度值不为0的像素点,按照步骤3.2的方式求所有可能为圆心的点,并对每个点进行投票。3.3 Traverse all the pixels whose gradient value is not 0 in the image, find all the points that may be the center of the circle according to the method of step 3.2, and vote for each point.
3.4对整幅图像扫描完毕后,得票最高的点就是待检测圆的圆心。3.4 After scanning the entire image, the point with the highest votes is the center of the circle to be detected.
由图4可以看出,通过梯度Hough变换的方法以及经过Canny算法进行边缘提取处理后,乒乓球的大致轮廓已经被提取了出来,但同时也存在边界模糊、间断的问题。在本实例中,经过多次测试,最终将Canny算法中的高低双阈值分别整定为100、30后,边缘提取效果会如图5所示改善很多。It can be seen from Figure 4 that the rough outline of the ping pong ball has been extracted by the gradient Hough transform method and the edge extraction process by the Canny algorithm, but there are also blurred and discontinuous boundaries. In this example, after many tests, the high and low thresholds in the Canny algorithm are finally set to 100 and 30, respectively, and the edge extraction effect will be much improved as shown in Figure 5.
步骤4.乒乓球标记Step 4. Ping Pong Ball Markers
检测到乒乓球的某一帧图像,则以图像左上角为原点、每个像素为一个单位长度,将图像中每一个圆的坐标、半径标记在图像上。最后,依据近大远小的物理规则,筛选出距离机器人最近的乒乓球,将这个球的x、y坐标和半径传递给处理器,进行收集操作。When a certain frame of ping-pong ball is detected, take the upper left corner of the image as the origin and each pixel as a unit length, and mark the coordinates and radius of each circle in the image on the image. Finally, according to the physical rules of near big and far small, the table tennis ball closest to the robot is screened out, and the x, y coordinates and radius of the ball are passed to the processor for collection operation.
图6给出了标记乒乓球的示例。在图中乒乓球用圆形圈出,乒乓球上的数字代表乒乓球的半径大小。左上方的乒乓球距离摄像头较远,所以半径数值小于右下方的乒乓球,在实际情况中,右下方乒乓球距离摄像头近,机器人会判定优先收集这个乒乓球。Figure 6 shows an example of marking a ping pong ball. In the figure, the ping pong ball is circled with a circle, and the number on the ping pong ball represents the radius of the ping pong ball. The ping pong ball in the upper left is far from the camera, so the radius value is smaller than the ping pong ball in the lower right. In the actual situation, the ping pong ball in the lower right is close to the camera, and the robot will decide to collect this ping pong ball first.
步骤5.乒乓球识别的特殊处理及关参数的设置Step 5. Special processing of table tennis identification and setting of relevant parameters
5.1乒乓球遮挡情况处理方法5.1 Processing method of table tennis occlusion
在实际情况下,可能会发生多个乒乓球互相遮挡、距离机器人过远或过近等情况。所以在进行Hough变换后,需要对两个圆心之间的最小距离、累加平面对是否是圆的判定阈值、检测到的圆的半径的最大值和最小值等参数进行设置。In practical situations, it may happen that multiple ping pong balls block each other, or are too far or too close to the robot. Therefore, after Hough transform is performed, it is necessary to set parameters such as the minimum distance between the centers of the two circles, the threshold for determining whether the accumulated plane pair is a circle, and the maximum and minimum radius of the detected circles.
本发明在调整参数时,选用2m*2m的黑色橡胶场地;捡球装置入口宽15cm,视觉传感器的最大分辨率为640*480,照射广度为70°,照射长度50cm,可识别乒乓球的距离范围为机器人前方20cm-70cm.在此范围内,可识别出的乒乓球最大半径为80像素、最小半径为15像素。由于乒乓球距离机器人过远时收集成功率不高,所以本实例中,将检测到的圆的半径的最大像素值和最小像素值设置为80和30。因本实例测试时使用的场地为黑色纯色橡胶垫,反光情况不严重,非乒乓球物体对于检测效率的影响并不大,所以累加平面对是否是圆的判定阈值分别设置为1,处于一个较为常规的适中状态。如果两个乒乓球重叠过多,可能会出现摄像头无法识别捕捉到的乒乓球的情况,且在此条件下,乒乓球的半径通常为80像素,所以两个圆心之间的最小距离设置为120像素,不影响识别效果,且能很好的限制乒乓球重叠情况。When adjusting the parameters, the present invention selects a black rubber field of 2m*2m; the entrance of the ball picking device is 15cm wide, the maximum resolution of the visual sensor is 640*480, the irradiation width is 70°, and the irradiation length is 50cm, which can identify the distance of the table tennis ball. The range is 20cm-70cm in front of the robot. Within this range, the maximum radius of the ping-pong ball that can be recognized is 80 pixels, and the minimum radius is 15 pixels. Since the collection success rate is not high when the table tennis ball is too far away from the robot, in this example, the maximum pixel value and the minimum pixel value of the radius of the detected circle are set to 80 and 30. Because the field used in the test in this example is a black solid-color rubber pad, the reflection is not serious, and the non-ping-pong object has little influence on the detection efficiency, so the judgment thresholds of whether the accumulated plane is a circle are set to 1, which is in a relatively low level. Normal moderate state. If the two ping-pong balls overlap too much, the camera may not recognize the captured ping-pong ball, and under this condition, the radius of the ping-pong ball is usually 80 pixels, so the minimum distance between the two circle centers is set to 120 pixels, does not affect the recognition effect, and can well limit the overlap of table tennis balls.
5.2配合捡乒乓球机器人工作时的参数设置5.2 Parameter setting when working with the table tennis robot
为了更好地配合捡球装置完成捡球动作、提高捡球效率,在此基础上要求乒乓球进入捡球器的位置尽可能居中,以避免因乒乓球触碰到捡球器左、右边缘而被推离机器人,导致无法捡球的状况。在本实例中,因捡球装置入口为15cm,摄像头像素为640*480,照射广度为70°,可照射范围大于捡球装置入口范围;捡球范围为机器人前20cm到70cm,现实中的直线在摄像头中照射到的画面为梯形,为了能使最远处70cm的乒乓球也能被成功收集,经过多次实验,最终确定当乒乓球圆心位于x轴上160像素到480像素之间才进行收集。若在可收集范围外识别到乒乓球,则驱动机器人进行相应的姿态调整,使得乒乓球圆心进入可收集范围内并进行收集。In order to better cooperate with the ball pick-up device to complete the pick-up action and improve the pick-up efficiency, on this basis, it is required that the position where the table tennis ball enters the pick-up device is as centered as possible to avoid the table tennis ball touching the left and right edges of the pick-up device. And was pushed away from the robot, resulting in a situation where the ball could not be picked up. In this example, because the entrance of the ball picking device is 15cm, the pixels of the camera are 640*480, and the irradiation width is 70°, the irradiable range is larger than the entrance range of the ball picking device; the ball picking range is 20cm to 70cm in front of the robot, and the real straight line The picture illuminated by the camera is a trapezoid. In order to enable the table tennis balls with the farthest distance of 70cm to be successfully collected, after many experiments, it is finally determined that the table tennis ball center is located between 160 pixels and 480 pixels on the x-axis. collect. If the table tennis ball is recognized outside the collectible range, the robot is driven to adjust the posture accordingly, so that the center of the table tennis ball enters the collectible range and is collected.
5.3乒乓球识别优化处理5.3 Optimization Processing of Table Tennis Recognition
实际的乒乓球场地中干扰因素较少,但为了在较为复杂的环境中也能保证检测乒乓球的准确率,可以选择性地对图片进行进一步的处理来消除背景所带来的影响,例如腐蚀、膨胀等。There are few interference factors in the actual table tennis field, but in order to ensure the accuracy of table tennis detection in a more complex environment, the picture can be selectively further processed to eliminate the influence of the background, such as corrosion , expansion, etc.
对灰度图进行腐蚀、膨胀操作可以分别用公式(4)、(5)来表示:Erosion and expansion of grayscale images can be expressed by formulas (4) and (5) respectively:
fob=min{fx-b(x),x∈D(b)} (4)fob=min{f x -b(x),x∈D(b)} (4)
fgb=max{fx+b(x),x∈D(b)} (5)fgb=max{f x +b(x),x∈D(b)} (5)
其中,D(b)结构元素b的模板区域。where D(b) is the template region of structural element b.
本实例中,笔者使用开、闭操作来实现提高识别乒乓球准确率的目的。开运算是对图像先腐蚀后膨胀的过程,可以用来消除小黑点、在纤细点处分离物体、平滑较大物体的边界,同时并不明显改变其面积;闭运算对图像先膨胀后腐蚀的过程,可以用来排除小黑洞。In this example, the author uses the open and close operations to achieve the purpose of improving the accuracy of identifying table tennis. The open operation is a process of first eroding and then expanding the image. It can be used to eliminate small black spots, separate objects at thin points, and smooth the boundaries of larger objects without significantly changing their area. The closed operation first expands and then erodes the image. process that can be used to exclude small black holes.
图7展示了未使用开、闭运算的识别情况。可以看到虽然通过Hough变换的方法能够在复杂环境中识别出乒乓球,但同时也出现了很多误判。Figure 7 shows the recognition without using open and close operations. It can be seen that although the method of Hough transform can identify ping pong balls in complex environments, there are also many misjudgments.
图8展示了使用开、闭运算后的识别效果。可以看出,相比于图8,所有的误判均被消除,并且依然可以稳定识别乒乓球。所以在机器人工作环境较为复杂时,本实例通过加入开、闭运算来消除复杂背景对识别乒乓球的影响。Figure 8 shows the recognition effect after using open and close operations. It can be seen that, compared with Fig. 8, all misjudgments are eliminated, and table tennis can still be stably recognized. Therefore, when the working environment of the robot is complex, this example eliminates the influence of complex background on the recognition of table tennis by adding open and close operations.
Claims (3)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911086761.2A CN110866903B (en) | 2019-11-08 | 2019-11-08 | Ping-pong ball identification method based on Hough circle transformation technology |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911086761.2A CN110866903B (en) | 2019-11-08 | 2019-11-08 | Ping-pong ball identification method based on Hough circle transformation technology |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110866903A true CN110866903A (en) | 2020-03-06 |
CN110866903B CN110866903B (en) | 2022-02-08 |
Family
ID=69653281
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911086761.2A Active CN110866903B (en) | 2019-11-08 | 2019-11-08 | Ping-pong ball identification method based on Hough circle transformation technology |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110866903B (en) |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111257296A (en) * | 2020-03-20 | 2020-06-09 | 京东方科技集团股份有限公司 | Method, device and storage medium for detecting biochip sample |
CN111840938A (en) * | 2020-07-23 | 2020-10-30 | 合肥工业大学 | A fully automatic table tennis pickup |
CN112329576A (en) * | 2020-10-27 | 2021-02-05 | 南京大学 | A method for identifying the position of the coil spring of an automobile seat belt |
CN112652010A (en) * | 2020-12-25 | 2021-04-13 | 安徽工业大学 | Pellet particle size detection method based on image enhancement and Hough transform |
CN112767304A (en) * | 2020-12-04 | 2021-05-07 | 浙江大学山东工业技术研究院 | Vision-based sunflower module position and direction detection method |
CN114550566A (en) * | 2021-12-23 | 2022-05-27 | 合肥磐石自动化科技有限公司 | Visual recognition-based control method and system for ping-pong device |
CN114681878A (en) * | 2022-04-27 | 2022-07-01 | 南京科技职业学院 | A kind of table tennis collection equipment for sports training |
CN115278223A (en) * | 2022-09-29 | 2022-11-01 | 天津华来科技股份有限公司 | Camera product connection performance test method and system, storage device and processing terminal |
CN115330751A (en) * | 2022-08-31 | 2022-11-11 | 安徽大学 | A bolt detection and positioning method based on YOLOv5 and Realsense |
CN116402784A (en) * | 2023-03-29 | 2023-07-07 | 湖北工业大学 | Auxiliary centering method, system, equipment and storage medium based on machine vision |
CN117812275A (en) * | 2024-02-28 | 2024-04-02 | 哈尔滨学院 | Image optimization communication method for volleyball auxiliary training |
CN117994347A (en) * | 2024-04-07 | 2024-05-07 | 宝鸡市鹏盛鑫有色金属有限责任公司 | High-precision positioning method for flange machining drilling |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102568007A (en) * | 2011-03-22 | 2012-07-11 | 黄海清 | Image processing method performing quasi-circular detection by improving Hough transformation |
CN105931252A (en) * | 2016-05-16 | 2016-09-07 | 大连理工大学 | Ellipse rapid detection method based on geometric constraint |
CN106600580A (en) * | 2016-11-30 | 2017-04-26 | 浙江大学 | Hough transform-based abnormal recognition method and system of power line |
US20170278266A1 (en) * | 2016-03-22 | 2017-09-28 | Tata Consultancy Services Limited | Systems and methods for detecting and tracking a marker |
CN108921176A (en) * | 2018-06-22 | 2018-11-30 | 河海大学常州校区 | A kind of pointer instrument positioning and recognition methods based on machine vision |
CN109035258A (en) * | 2018-07-20 | 2018-12-18 | 北京工业大学 | A kind of image partition method based on oriented intersection genetic algorithm and Two-dimensional maximum-entropy Threshold Segmentation Algorithm |
-
2019
- 2019-11-08 CN CN201911086761.2A patent/CN110866903B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102568007A (en) * | 2011-03-22 | 2012-07-11 | 黄海清 | Image processing method performing quasi-circular detection by improving Hough transformation |
US20170278266A1 (en) * | 2016-03-22 | 2017-09-28 | Tata Consultancy Services Limited | Systems and methods for detecting and tracking a marker |
CN105931252A (en) * | 2016-05-16 | 2016-09-07 | 大连理工大学 | Ellipse rapid detection method based on geometric constraint |
CN106600580A (en) * | 2016-11-30 | 2017-04-26 | 浙江大学 | Hough transform-based abnormal recognition method and system of power line |
CN108921176A (en) * | 2018-06-22 | 2018-11-30 | 河海大学常州校区 | A kind of pointer instrument positioning and recognition methods based on machine vision |
CN109035258A (en) * | 2018-07-20 | 2018-12-18 | 北京工业大学 | A kind of image partition method based on oriented intersection genetic algorithm and Two-dimensional maximum-entropy Threshold Segmentation Algorithm |
Non-Patent Citations (2)
Title |
---|
ANE CORNELIA: "Ball detection algorithm for robot soccer based on contour and gradient hough circle transform", 《 2017 4TH INTERNATIONAL CONFERENCE ON INFORMATION TECHNOLOGY, COMPUTER, AND ELECTRICAL ENGINEERING (ICITACEE)》 * |
王晓龙 等: "基于OpenCV的嵌入式自动捡乒乓球系统设计", 《计算机测量与控制》 * |
Cited By (19)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111257296B (en) * | 2020-03-20 | 2023-04-11 | 京东方科技集团股份有限公司 | Method, device and storage medium for detecting biochip sample |
CN111257296A (en) * | 2020-03-20 | 2020-06-09 | 京东方科技集团股份有限公司 | Method, device and storage medium for detecting biochip sample |
CN111840938A (en) * | 2020-07-23 | 2020-10-30 | 合肥工业大学 | A fully automatic table tennis pickup |
CN111840938B (en) * | 2020-07-23 | 2021-07-13 | 合肥工业大学 | A fully automatic table tennis pickup |
CN112329576A (en) * | 2020-10-27 | 2021-02-05 | 南京大学 | A method for identifying the position of the coil spring of an automobile seat belt |
CN112329576B (en) * | 2020-10-27 | 2023-11-28 | 南京大学 | Method for identifying position of coil spring of automobile safety belt |
CN112767304A (en) * | 2020-12-04 | 2021-05-07 | 浙江大学山东工业技术研究院 | Vision-based sunflower module position and direction detection method |
CN112767304B (en) * | 2020-12-04 | 2023-02-28 | 浙江大学山东工业技术研究院 | A Vision-Based Detection Method for the Position and Orientation of Sunflower Modules |
CN112652010A (en) * | 2020-12-25 | 2021-04-13 | 安徽工业大学 | Pellet particle size detection method based on image enhancement and Hough transform |
CN114550566A (en) * | 2021-12-23 | 2022-05-27 | 合肥磐石自动化科技有限公司 | Visual recognition-based control method and system for ping-pong device |
CN114681878A (en) * | 2022-04-27 | 2022-07-01 | 南京科技职业学院 | A kind of table tennis collection equipment for sports training |
CN115330751A (en) * | 2022-08-31 | 2022-11-11 | 安徽大学 | A bolt detection and positioning method based on YOLOv5 and Realsense |
CN115278223A (en) * | 2022-09-29 | 2022-11-01 | 天津华来科技股份有限公司 | Camera product connection performance test method and system, storage device and processing terminal |
CN115278223B (en) * | 2022-09-29 | 2022-12-13 | 天津华来科技股份有限公司 | Camera product connection performance test method and system, storage device and processing terminal |
CN116402784A (en) * | 2023-03-29 | 2023-07-07 | 湖北工业大学 | Auxiliary centering method, system, equipment and storage medium based on machine vision |
CN117812275A (en) * | 2024-02-28 | 2024-04-02 | 哈尔滨学院 | Image optimization communication method for volleyball auxiliary training |
CN117812275B (en) * | 2024-02-28 | 2024-05-28 | 哈尔滨学院 | Image optimization communication method for volleyball auxiliary training |
CN117994347A (en) * | 2024-04-07 | 2024-05-07 | 宝鸡市鹏盛鑫有色金属有限责任公司 | High-precision positioning method for flange machining drilling |
CN117994347B (en) * | 2024-04-07 | 2024-06-11 | 宝鸡市鹏盛鑫有色金属有限责任公司 | High-precision positioning method for flange machining drilling |
Also Published As
Publication number | Publication date |
---|---|
CN110866903B (en) | 2022-02-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110866903B (en) | Ping-pong ball identification method based on Hough circle transformation technology | |
CN111951237B (en) | Visual appearance detection method | |
CN106093066B (en) | A kind of magnetic tile surface defect detection method based on improved machine vision attention mechanism | |
CN106934803B (en) | method and device for detecting surface defects of electronic device | |
CN105893946B (en) | A detection method for frontal face images | |
CN111507390A (en) | Storage box body identification and positioning method based on contour features | |
CN111667475B (en) | Machine vision-based Chinese date grading detection method | |
CN108985170A (en) | Transmission line of electricity hanger recognition methods based on Three image difference and deep learning | |
CN109360179B (en) | Image fusion method and device and readable storage medium | |
CN109145708A (en) | A kind of people flow rate statistical method based on the fusion of RGB and D information | |
CN109359577B (en) | A system for detecting people in complex backgrounds based on machine learning | |
CN113283439A (en) | Intelligent counting method, device and system based on image recognition | |
CN110033431A (en) | Non-contact detection device and detection method for detecting corrosion area on surface of steel bridge | |
CN112702481B (en) | Table tennis track tracking device and method based on deep learning | |
CN109583435A (en) | A kind of adaptive ballot method for detecting lane lines | |
CN108647593A (en) | Unmanned plane road surface breakage classification and Detection method based on image procossing and SVM | |
CN115049689A (en) | Table tennis identification method based on contour detection technology | |
CN111476804A (en) | Method, device and equipment for efficiently segmenting carrier roller image and storage medium | |
CN109492647A (en) | A kind of power grid robot barrier object recognition methods | |
CN106067031A (en) | Cooperate with the degree of depth learning network Machine Vision Recognition system based on artificial mechanism for correcting errors | |
CN114418935A (en) | Detection and identification method and screw locking device for screw holes of mobile phone TP frame | |
CN114881945A (en) | Method and system for automatically searching and extracting workpiece weld joint feature points under complex background | |
CN113689365A (en) | Target tracking and positioning method based on Azure Kinect | |
CN111583193A (en) | Pistachio nut framework extraction device based on geometric contour template matching and algorithm thereof | |
CN111950409A (en) | A method and system for intelligent identification of road marking lines |
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 |