CN116188571A - A regular polygonal prism detection method for manipulator - Google Patents
A regular polygonal prism detection method for manipulator Download PDFInfo
- Publication number
- CN116188571A CN116188571A CN202310009829.7A CN202310009829A CN116188571A CN 116188571 A CN116188571 A CN 116188571A CN 202310009829 A CN202310009829 A CN 202310009829A CN 116188571 A CN116188571 A CN 116188571A
- Authority
- CN
- China
- Prior art keywords
- edge
- straight line
- mask
- circle
- straight lines
- 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.)
- Pending
Links
- 238000001514 detection method Methods 0.000 title claims abstract description 59
- 238000003708 edge detection Methods 0.000 claims abstract description 31
- 230000011218 segmentation Effects 0.000 claims description 23
- 238000000034 method Methods 0.000 claims description 17
- 230000008569 process Effects 0.000 claims description 14
- 238000005516 engineering process Methods 0.000 claims description 8
- 230000003044 adaptive effect Effects 0.000 claims description 7
- 239000003086 colorant Substances 0.000 claims description 7
- 238000012546 transfer Methods 0.000 claims description 7
- 230000003628 erosive effect Effects 0.000 claims description 6
- 238000004458 analytical method Methods 0.000 claims description 2
- 230000000877 morphologic effect Effects 0.000 claims description 2
- 238000004904 shortening Methods 0.000 abstract 1
- 238000010586 diagram Methods 0.000 description 31
- 230000008859 change Effects 0.000 description 4
- 230000000694 effects Effects 0.000 description 4
- 230000006870 function Effects 0.000 description 3
- 230000008447 perception Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 230000008901 benefit Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 230000010339 dilation Effects 0.000 description 2
- 230000005484 gravity Effects 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000004927 fusion Effects 0.000 description 1
- 238000003709 image segmentation Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003252 repetitive effect Effects 0.000 description 1
- 230000009466 transformation Effects 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/70—Determining position or orientation of objects or cameras
- G06T7/73—Determining position or orientation of objects or cameras using feature-based methods
-
- B—PERFORMING OPERATIONS; TRANSPORTING
- B25—HAND TOOLS; PORTABLE POWER-DRIVEN TOOLS; MANIPULATORS
- B25J—MANIPULATORS; CHAMBERS PROVIDED WITH MANIPULATION DEVICES
- B25J11/00—Manipulators not otherwise provided for
-
- B—PERFORMING OPERATIONS; TRANSPORTING
- B25—HAND TOOLS; PORTABLE POWER-DRIVEN TOOLS; MANIPULATORS
- B25J—MANIPULATORS; CHAMBERS PROVIDED WITH MANIPULATION DEVICES
- B25J9/00—Programme-controlled manipulators
- B25J9/16—Programme controls
- B25J9/1656—Programme controls characterised by programming, planning systems for manipulators
- B25J9/1661—Programme controls characterised by programming, planning systems for manipulators characterised by task planning, object-oriented languages
-
- B—PERFORMING OPERATIONS; TRANSPORTING
- B25—HAND TOOLS; PORTABLE POWER-DRIVEN TOOLS; MANIPULATORS
- B25J—MANIPULATORS; CHAMBERS PROVIDED WITH MANIPULATION DEVICES
- B25J9/00—Programme-controlled manipulators
- B25J9/16—Programme controls
- B25J9/1679—Programme controls characterised by the tasks executed
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/20—Image enhancement or restoration using local operators
- G06T5/30—Erosion or dilatation, e.g. thinning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/70—Denoising; Smoothing
-
- 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
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/60—Analysis of geometric attributes
- G06T7/62—Analysis of geometric attributes of area, perimeter, diameter or volume
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Robotics (AREA)
- Mechanical Engineering (AREA)
- Geometry (AREA)
- Quality & Reliability (AREA)
- Image Analysis (AREA)
- Length Measuring Devices By Optical Means (AREA)
Abstract
Description
技术领域technical field
本发明属于机械臂的技术领域,特别涉及一种用于机械臂的正多棱柱检测方法,以准确检测正多棱柱上表面边缘、形状、形心和角度。The invention belongs to the technical field of mechanical arms, and in particular relates to a regular polygonal prism detection method for a mechanical arm to accurately detect the edge, shape, centroid and angle of the upper surface of the regular polygonal prism.
背景技术Background technique
机械臂通常是指高精度,多输入多输出、高度非线性、强耦合的复杂系统。因其独特的操作灵活性,已在工业装配、安全防爆等领域得到广泛应用。当操作目标物体总是在固定位置时,可以使用固定、重复的位置控制,使机械臂执行固定位置的取放步骤。而当待装配的目标物体位置发生变化时,机械臂需要拥有感知能力,自动定位物体,并完成装配任务。A robotic arm usually refers to a complex system with high precision, multiple input and multiple output, highly nonlinear, and strong coupling. Because of its unique operational flexibility, it has been widely used in industrial assembly, safety explosion-proof and other fields. When the manipulation target object is always at a fixed position, fixed, repetitive position control can be used to make the robotic arm perform a pick-and-place step at a fixed position. When the position of the target object to be assembled changes, the robotic arm needs to have the ability to sense, automatically locate the object, and complete the assembly task.
为机械臂增加感知能力,在硬件上利用传感器获取外界信息,并根据其所得数据,计算出所需信息。如专利申请202120538755.2公开了一种配网带电作业机器人系统,包括:操作台装置、支撑装置和控制柜;操作台装置包括操作台、机械臂组件和传感器组件;机械臂组件和传感器组件安装在操作台上;机械臂组件包括第一数量个机械臂和机械臂底座;机械臂底座固定在操作台上,机械臂固定在机械臂底座上;支撑装置包括绝缘斗和支撑框架;支撑框架环绕卡设在绝缘斗上;操作台滑设在支撑框架上;绝缘斗上开设有腔室,控制柜安装在腔室内;控制柜内安装有处理器和通讯模块;机械臂和传感器组件与处理器连接,处理器与通讯模块连接。Add perception capabilities to the robotic arm, use sensors on the hardware to obtain external information, and calculate the required information based on the obtained data. For example, patent application 202120538755.2 discloses a distribution network live working robot system, including: an operation table device, a support device and a control cabinet; the operation table device includes an operation table, a mechanical arm assembly and a sensor assembly; on the platform; the mechanical arm assembly includes a first number of mechanical arms and a mechanical arm base; the mechanical arm base is fixed on the operating table, and the mechanical arm is fixed on the mechanical arm base; the supporting device includes an insulating bucket and a supporting frame; On the insulating bucket; the operating table is slidingly set on the supporting frame; a chamber is opened on the insulating bucket, and the control cabinet is installed in the chamber; a processor and a communication module are installed in the control cabinet; the mechanical arm and the sensor assembly are connected to the processor, The processor is connected with the communication module.
在装配任务中,为机械臂提供感知能力,可用RGB摄像头作为传感器,获取当前待装配物体的图像,并分析取放物体所需信息,比如目标物体的位置、角度和形状等,最后使机械臂执行摆放动作。装配任务是否能成功完成,取决于位置、角度的准确性,In the assembly task, to provide perception capabilities for the robotic arm, the RGB camera can be used as a sensor to obtain the image of the current object to be assembled, and analyze the information required for picking and placing the object, such as the position, angle and shape of the target object, and finally make the robotic arm Perform a placement action. Whether the assembly task can be successfully completed depends on the accuracy of the position, angle,
分析目标物体位置、角度和形状的过程,在实现上,可使用目标检测或者实例分割模型。但这两类模型都各自存在缺点,目标检测模型输出的检测框大多是水平方向或竖直方向,没有倾斜角度,无法很好地反映物体角度,难以满足装配需求;实例分割模型的分割结果常常不能精确贴合物体实际边缘,物体顶点也不够明确,导致无法准确得到物体重心,影响机械臂装配成功率。另外当物体存在一定高度时,输入图像中存在物体侧表面,两类模型均会受此影响。当前技术无法准确地滤出待装配物体的上表面边缘,导致难以获得物体准确角度和重心,影响装配任务的成功率。因此,亟需改进。The process of analyzing the position, angle and shape of the target object. In terms of implementation, target detection or instance segmentation models can be used. However, these two types of models have their own shortcomings. Most of the detection frames output by the target detection model are horizontal or vertical, and there is no tilt angle, which cannot reflect the object angle well, and it is difficult to meet the assembly requirements; the segmentation results of the instance segmentation model are often The actual edge of the object cannot be precisely fitted, and the vertex of the object is not clear enough, resulting in the inability to accurately obtain the center of gravity of the object, which affects the success rate of the robotic arm assembly. In addition, when the object has a certain height, there is an object side surface in the input image, and both types of models will be affected by this. The current technology cannot accurately filter out the upper surface edge of the object to be assembled, making it difficult to obtain the accurate angle and center of gravity of the object, which affects the success rate of the assembly task. Therefore, improvement is badly needed.
发明内容Contents of the invention
基于此,本发明的首要目地是提供一种用于机械臂的正多棱柱检测方法,该方法能为机械臂提供感知能力,并克服当前目标检测模型和实例分割模型的缺点,得到摆放任务需要的吸取位置、物体形状和物体角度,帮助摆放任务顺利完成。Based on this, the primary purpose of the present invention is to provide a regular polygonal prism detection method for a robotic arm, which can provide perception capabilities for the robotic arm, overcome the shortcomings of the current target detection model and instance segmentation model, and obtain the placement task The required suction position, object shape and object angle can help the placement task to be completed smoothly.
本发明的另一个目地在于提供一种用于机械臂的正多棱柱检测方法,该方法能得到物体上表面的边缘,而消除侧表面的影响。利用HSV颜色空间的饱和度S通道做自适应阈值分割,得到物体掩膜;再在Lab和YCrCb颜色空间中进一步做grabcut分割,尽可能地得到物体上表面掩膜;同时,融合Lab颜色空间中的L分量和HSV颜色空间中的V分量的边缘检测,尽可能获得更完整的上表面边缘,以保证检测的准确性。Another object of the present invention is to provide a regular polygonal prism detection method for a robot arm, which can obtain the edge of the upper surface of the object and eliminate the influence of the side surface. Use the saturation S channel of the HSV color space to do adaptive threshold segmentation to obtain the object mask; then further perform grabcut segmentation in the Lab and YCrCb color spaces to obtain the upper surface mask of the object as much as possible; at the same time, integrate the Lab color space The edge detection of the L component and the V component in the HSV color space can obtain a more complete upper surface edge as much as possible to ensure the accuracy of detection.
为实现上述目的,本发明的技术方案为:To achieve the above object, the technical solution of the present invention is:
一种用于机械臂的正多棱柱检测方法,其特征在于包括如下步骤:A regular polygonal prism detection method for a mechanical arm, characterized in that it comprises the following steps:
步骤一:获得操作台俯视图像,使用RGB摄像头,以俯视视角拍摄台面以及台面上的待装配物体,获取操作台图片;Step 1: Obtain the top view image of the console, use the RGB camera to take pictures of the table top and the objects to be assembled on the table from a top view angle, and obtain the picture of the console;
为了对操作台及待装配物体进行区分,以不同颜色对它们进行标识;操作台设计成白色,待装配物体为其它颜色。In order to distinguish the operating table and the objects to be assembled, they are marked with different colors; the operating table is designed in white, and the objects to be assembled are in other colors.
步骤二:获得物体掩膜,Step 2: Obtain the object mask,
其中,获得物体掩膜是指至少获得物体上表面的掩膜。Wherein, obtaining the mask of the object refers to obtaining at least a mask of the upper surface of the object.
具体包括如下步骤:Specifically include the following steps:
S21、把图像转到HSV颜色空间,并使用其中的饱和度S通道做自适应阈值分割,由于待装配物体的饱和度比白色台面更高,将会得到物体掩膜;S21. Transfer the image to the HSV color space, and use the saturation S channel therein to perform adaptive threshold segmentation. Since the saturation of the object to be assembled is higher than that of the white table, an object mask will be obtained;
S22、去噪,使用膨胀、腐蚀、去除面积过大的连通域等运算去掉部分噪声;S22. Denoising, using operations such as expansion, erosion, and removal of overly large connected domains to remove part of the noise;
S23、接着把去噪后的掩膜以及转到Lab颜色空间的台面图片一起输入到grabcut中,使得模块检测流程全自动化,图片转到Lab颜色空间比RGB颜色空间能得到更良好的上表面分割效果;S23, then input the mask after denoising and the countertop picture transferred to Lab color space into grabcut together, so that the module detection process is fully automated, and the image transferred to Lab color space can obtain better upper surface segmentation than RGB color space Effect;
S24、接下来检测分割掩膜中的连通域面积是否过大,如果过大,怀疑出现多个物体的掩膜粘连情况,把图片转到YCrCb空间中再做一次grabcut并作为物体上表面掩膜,否则直接使用当前Lab颜色空间中的分割结果作为物体上表面掩膜。S24. Next, check whether the area of the connected domain in the segmentation mask is too large. If it is too large, it is suspected that there is mask adhesion of multiple objects. Transfer the image to the YCrCb space and do a grabcut again and use it as the upper surface mask of the object. , otherwise directly use the segmentation result in the current Lab color space as the upper surface mask of the object.
步骤三:检测图像中物体边缘。Step 3: Detect the edge of the object in the image.
利用Canny边缘检测,得到边缘二值图像。由于部分物体侧面和侧边缘其两边颜色变化小,导致这条边缘难以被检出,为了解决这个问题,利用上表面和侧表面主要是在亮度上变化较大的规律,分别在Lab颜色空间中的L分量和HSV颜色空间中的V分量上做边缘检测,然后把两个分量得到的检测结果求并集。Using Canny edge detection, the edge binary image is obtained. Due to the small change in color on both sides of the side and side edges of some objects, it is difficult to detect this edge. In order to solve this problem, the law that the upper surface and side surface mainly change in brightness is relatively large, respectively in the Lab color space Edge detection is performed on the L component of the HSV color space and the V component in the HSV color space, and then the detection results obtained by the two components are combined.
步骤四:检测图像中物体边缘并利用步骤二获得的掩膜去噪,此步骤希望获得噪声尽量少的边缘检测结果。去掉的噪声包括物体边缘内部和外部两种噪声。对掩膜做膨胀操作,并与边缘检测结果求交集,用于去除外部边缘噪声;再对掩膜做腐蚀操作,并求与边缘检测结果的差集,用于去除内部噪声。Step 4: Detect the edge of the object in the image and use the mask obtained in step 2 to denoise. In this step, it is hoped to obtain an edge detection result with as little noise as possible. The removed noise includes two kinds of noise inside and outside the edge of the object. Dilation operation is performed on the mask, and the intersection with the edge detection result is used to remove external edge noise; then the mask is etched, and the difference with the edge detection result is used to remove internal noise.
进一步,掩膜噪声,是把掩膜做膨胀操作,并与边缘检测结果求交集,得到去除物体外部噪声的边缘检测结果;再对掩膜做腐蚀操作,并求与边缘检测结果的差集,得到去除物体内部噪声的边缘检测结果。Further, the mask noise is to expand the mask and intersect with the edge detection result to obtain the edge detection result that removes the external noise of the object; then perform an erosion operation on the mask and calculate the difference with the edge detection result, The edge detection result of removing the internal noise of the object is obtained.
步骤五:判断是否存在圆。Step five: judge whether there is a circle.
判断当前目标物体的边缘图像中是否含有圆,若有,进入步骤八,否则进入步骤六。具体地说,利用霍夫圆检测,检测由物体掩膜作用于Lab颜色空间所得交集结果中,是否存在圆形,若是,得到最合适的上表面圆并进入步骤九,否则进入步骤六。其中,得到上表面圆的流程为,分别在HSV和Lab颜色空间的图像中使用霍夫圆检测,自适应地找到该颜色空间中param2最大的圆,再以圆心靠外的圆作为上表面圆。其中param2是霍夫圆检测方法的输入参数,表示圆的规则程度,只有大于param2的形状,能被当做圆检出。选择靠外的圆作为上表面圆,依据是在俯视视角下,上表面总是相对靠近图片外围。Determine whether the edge image of the current target object contains a circle, if so, go to step 8, otherwise go to step 6. Specifically, use Hough circle detection to detect whether there is a circle in the intersection result obtained by applying the object mask to the Lab color space. If so, obtain the most suitable upper surface circle and enter step nine, otherwise enter step six. Among them, the process of obtaining the upper surface circle is to use Hough circle detection in the images of HSV and Lab color spaces respectively, adaptively find the circle with the largest param2 in the color space, and then use the circle with the outer center as the upper surface circle . Among them, param2 is the input parameter of the Hough circle detection method, which indicates the regularity of the circle. Only shapes larger than param2 can be detected as circles. The outer circle is selected as the upper surface circle, based on the fact that the upper surface is always relatively close to the periphery of the picture in the top view.
步骤六:从边缘检测结果获得边缘所在直线的信息。Step 6: Obtain the information of the straight line where the edge is located from the edge detection result.
边缘检测结果使用霍夫直线检测技术,自适应地获得当前边缘检测图像中长度大于th1的线段所在的直线解析式。The edge detection result uses the Hough line detection technology to adaptively obtain the line analysis formula of the line segment whose length is greater than th1 in the current edge detection image.
具体流程如下:The specific process is as follows:
S41、获得th=th1的线段;S41. Obtain the line segment of th=th1;
S42、检测长度大于th的线段;S42, detecting a line segment whose length is greater than th;
S43、判断是否检测到直线;如果未检测到直线则继续下一步;如果有,则令th+=4,并返回S42;S43, judging whether a straight line is detected; if no straight line is detected, continue to the next step; if yes, make th+=4, and return to S42;
S44、令th-=1;S44, let th-=1;
S45、进一步判断th>th1,是则继续下一步,否则结束;S45. Further judge that th>th1, if yes, continue to the next step, otherwise end;
S46、检测长度大于th的线段;S46, detecting a line segment whose length is greater than th;
S47、判断是否上检测到直线;如果检测到直线则记录直线信息和th,并在原图中删除本次检测到的直线;如果无,则返回S44步骤,令th-=1。S47. Determine whether a straight line is detected; if a straight line is detected, record the straight line information and th, and delete the detected straight line in the original image; if not, return to step S44, and set th-=1.
删除检测到的直线后,循环执行上述步骤,直至所有检测完成。After deleting the detected straight lines, execute the above steps in a loop until all detections are completed.
通过这个流程,会根据线段长度的倒序,记录所有长度大于th1的线段所在的直线信息,信息包括倾斜角、直线到图片原点的距离和检出时的长度阈值th。Through this process, the straight line information of all line segments with a length greater than th1 will be recorded according to the reverse order of the length of the line segment. The information includes the inclination angle, the distance from the straight line to the origin of the image, and the length threshold th at the time of detection.
步骤七:筛出物体上表面边缘直线,本步骤是排除物体侧表面边缘、底面边缘和其他噪声的干扰,且选出最贴合物体上表面实际边缘的直线。Step 7: Screen out the straight line on the edge of the upper surface of the object. This step is to eliminate the interference of the edge of the side surface of the object, the edge of the bottom surface and other noises, and select the straight line that best fits the actual edge of the upper surface of the object.
依次进行直线分组、直线去噪和选择直线三个操作。Carry out three operations of line grouping, line denoising and line selection in sequence.
直线分组:把检测出来的所有直线根据角度分组,角度差距在th2内的所有直线分为一组,每组包含至少一条直线;Straight line grouping: group all detected straight lines according to angle, and group all straight lines whose angle difference is within th2, and each group contains at least one straight line;
进一步,距离差距大于th3且几乎平行的直线被分为不同组,th3需要调试,使得能把物体上表面平行的边缘分成两组,而把平行的上下表面边缘合在同一组。其中判断直线几乎平行的规则是,两条直线在画面范围内没有交点。Further, almost parallel straight lines with a distance greater than th3 are divided into different groups, and th3 needs to be adjusted so that the parallel edges on the upper surface of the object can be divided into two groups, and the parallel upper and lower surface edges can be combined into the same group. The rule for judging that straight lines are almost parallel is that there is no intersection point between two straight lines within the scope of the screen.
直线去噪:主要去掉侧边缘直线和其他噪声,根据在俯视视角下侧边缘长度较短和噪声直线较短,去掉该直线,直线的判断规则为,这一组只有一条直线且当时识别线段的长度低于th4。Straight line denoising: Mainly remove the side edge line and other noises. According to the short side edge length and the short noise line in the top view, remove the straight line. The judgment rule of the straight line is that there is only one straight line in this group and the line segment is recognized at that time. The length is lower than th4.
选择直线:从剩余的上表面和下表面边缘直线的集合中,选出上表面直线;利用上表面直线相比下表面直线,分别比较每条直线框出的物体与掩膜的差异,为每组选出差异最小的直线,认为是上表面边缘。Select a straight line: Select the upper surface straight line from the set of remaining upper and lower surface edge straight lines; use the upper surface straight line to compare the lower surface straight line, and compare the difference between the object framed by each straight line and the mask, for each The group selects the straight line with the smallest difference, which is considered to be the edge of the upper surface.
进一步,选择直线时,需要先为每条直线构建封闭框,接着比较封闭范围与掩膜的差异;构建封闭框时,为每条直线搭配其他直线组内距离掩膜中心最近的直线,组成封闭框;比较封闭框A中的所有像素与grabcut的掩膜B中的所有像素,为每条直线记录在A却不在B中的像素的个数n;之后,每组中选出一条n最小的直线,认为是上表面边缘直线。Furthermore, when selecting a straight line, it is necessary to first construct a closed frame for each straight line, and then compare the difference between the closed range and the mask; when constructing a closed frame, match each straight line with the line closest to the center of the mask in other straight line groups to form a closed box; compare all the pixels in the closed box A with all the pixels in the mask B of grabcut, and record the number n of pixels that are in A but not in B for each line; after that, select a minimum n in each group The straight line is regarded as the upper surface edge straight line.
步骤八:直线缩短为物体边缘线段。由于在第四步得到的直线信息并不包括端点,因此要在本步骤求出边缘线的交点,也就是物体上表面的顶点,得到贴合物体边缘的线段。Step 8: The straight line is shortened to the edge segment of the object. Since the straight line information obtained in the fourth step does not include endpoints, it is necessary to obtain the intersection point of the edge lines in this step, that is, the vertex of the upper surface of the object, and obtain a line segment that fits the edge of the object.
为此,遍历当前所有直线的两两搭配,计算这两条直线的交点到掩膜的最小距离,若距离小于th5,认为这两条直线相邻。其中,计算点到掩膜的距离方式是,以该点为圆心,绘制半径逐渐增加的圆,当圆开始与掩膜有交集时,圆的半径就是点到掩膜的距离。得到所有直线的相邻关系后,再计算相邻直线顶点并依次连接顶点,得到物体上表面的边缘。To this end, iterate through the pairwise matching of all current straight lines, and calculate the minimum distance from the intersection point of the two straight lines to the mask. If the distance is less than th5, the two straight lines are considered to be adjacent. Among them, the way to calculate the distance from the point to the mask is to draw a circle with gradually increasing radius with the point as the center. When the circle starts to intersect with the mask, the radius of the circle is the distance from the point to the mask. After obtaining the adjacency relationship of all straight lines, calculate the vertices of the adjacent straight lines and connect the vertices in turn to obtain the edge of the upper surface of the object.
九:计算物体的形状、形心、角度。根据正多棱柱的形状和棱数一一对应的关系,由顶点个数即可得到形状;形心可根据上表面边缘围成的封闭图形计算;物体的角度由上表面最小外接矩形的旋转角度计算得到。Nine: Calculate the shape, centroid, and angle of an object. According to the one-to-one relationship between the shape of a regular polygonal prism and the number of edges, the shape can be obtained from the number of vertices; the centroid can be calculated according to the closed figure surrounded by the upper surface edge; the angle of the object is determined by the rotation angle of the smallest circumscribed rectangle on the upper surface calculated.
与现有技术相比,本发明的有益效果是:Compared with prior art, the beneficial effect of the present invention is:
本发明利用颜色空间的转化和多颜色空间信息的融合,解决了在RGB颜色空间中分割及检测效果不够好的问题。具体来说,对于图像分割,利用HSV的S分量分割出初始掩膜,再根据情况在Lab和YCrCb颜色空间中进一步做grabcut分割,尽可能地得到物体上表面掩膜。对于边缘检测,融合Lab颜色空间中的L分量和HSV颜色空间中的V分量的边缘检测,尽可能获得更完整的上表面边缘,能够准确地获得准确边缘,提高检测的准确性,并得到摆放任务需要的吸取位置、物体形状和物体角度,帮助摆放任务顺利完成。The invention utilizes the conversion of color space and the fusion of multi-color space information to solve the problem that the segmentation and detection effect in the RGB color space is not good enough. Specifically, for image segmentation, use the S component of HSV to segment the initial mask, and then further perform grabcut segmentation in the Lab and YCrCb color spaces according to the situation, to obtain the upper surface mask of the object as much as possible. For edge detection, the edge detection of the L component in the Lab color space and the V component in the HSV color space can be used to obtain a more complete upper surface edge as much as possible, which can accurately obtain accurate edges, improve the accuracy of detection, and obtain swing The suction position, object shape and object angle required by the placement task can help the placement task to be completed smoothly.
附图说明Description of drawings
图1是本发明所实施的流程图。Figure 1 is a flowchart of the implementation of the present invention.
图2是本发明所实施霍夫直线检测的流程图。Fig. 2 is a flow chart of the Hough straight line detection implemented by the present invention.
图3是操作台俯拍视图。Figure 3 is a top view of the console.
图4是本发明所实施获得全部物体掩膜的图。Fig. 4 is a diagram of obtaining all object masks implemented by the present invention.
图5是本发明所实施检测图像所有物体边缘的示意图。Fig. 5 is a schematic diagram of detecting the edges of all objects in an image implemented by the present invention.
图6是本发明所实施三角形去噪边缘的示意图。Fig. 6 is a schematic diagram of a triangle denoising edge implemented by the present invention.
图7是本发明所实施五边形去噪边缘的示意图。FIG. 7 is a schematic diagram of a pentagonal denoising edge implemented in the present invention.
图8是本发明所实施圆形去噪边缘的示意图。Fig. 8 is a schematic diagram of a circular denoising edge implemented by the present invention.
图9是本发明所实施正方形去噪边缘的示意图。Fig. 9 is a schematic diagram of a square denoising edge implemented by the present invention.
图10是本发明所实施全部图形去噪边缘的示意图。Fig. 10 is a schematic diagram of all the image denoising edges implemented by the present invention.
图11是本发明所实施三角形掩膜与图像的交集示意图。Fig. 11 is a schematic diagram of the intersection of a triangle mask and an image implemented in the present invention.
图12是本发明所实施四边形掩膜与图像的交集示意图。FIG. 12 is a schematic diagram of the intersection of a quadrilateral mask and an image implemented in the present invention.
图13是本发明所实施五边形掩膜与图像的交集示意图。Fig. 13 is a schematic diagram of the intersection of a pentagonal mask and an image implemented in the present invention.
图14是本发明所实施圆柱掩膜与图像的交集示意图。Fig. 14 is a schematic diagram of the intersection of a cylindrical mask and an image implemented in the present invention.
图15是本发明所实施检测三角形边缘直线图。Fig. 15 is a straight line diagram of the detected triangle edge implemented by the present invention.
图16是本发明所实施检测五边形边缘直线图。Fig. 16 is a straight line diagram of detecting pentagonal edges implemented by the present invention.
图17是本发明所实施检测正方形边缘直线图。Fig. 17 is a linear diagram of detecting square edges implemented by the present invention.
图18是本发明所实施三角形上表面直线示意图。Fig. 18 is a schematic diagram of a straight line on the upper surface of a triangle implemented in the present invention.
图19是本发明所实施五边形上表面直线示意图。Fig. 19 is a schematic diagram of a straight line on the upper surface of a pentagon implemented in the present invention.
图20是本发明所实施正方形上表面直线示意图。Fig. 20 is a schematic diagram of a straight line on the upper surface of a square implemented in the present invention.
图21是本发明所实施三角形边缘线段示意图。Fig. 21 is a schematic diagram of a triangle edge line segment implemented in the present invention.
图22是本发明所实施五边形边缘线段示意图。Fig. 22 is a schematic diagram of a pentagonal edge line segment implemented in the present invention.
图23是本发明所实施正方形边缘线段示意图。Fig. 23 is a schematic diagram of a square edge segment implemented in the present invention.
图24是本发明所实施计算物体信息示意图。Fig. 24 is a schematic diagram of computing object information implemented by the present invention.
具体实施方式Detailed ways
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
图1所示,为本发明所实现的用于机械臂的正多棱柱检测方法流程图。由于待装配物体大多为柱体,本发明以正多棱柱为例进行检测。As shown in FIG. 1 , it is a flowchart of a regular polygonal prism detection method for a mechanical arm implemented in the present invention. Since most of the objects to be assembled are cylinders, the present invention takes a regular polygonal prism as an example for detection.
图中所示,本发明的输入是俯视视角的操作台图片,其中将操作台设计为白色,待装配物体是其他颜色的柱体;输出图片中每个物体的上表面边缘以及该物体的形状、位置和角度信息。其中,使用的现有技术包括颜色空间转换、自适应阈值分割、grabcut分割、canny边缘检测、霍夫直线检测和形态学处理等,除了这些技术的组合,本发明根据待装配物体是柱体这一先验知识,创建了处理规则,用于从含有大量噪音的边缘检测结果中筛选出物体上表面真正的边缘。As shown in the figure, the input of the present invention is a picture of the console from a top view, wherein the console is designed to be white, and the objects to be assembled are cylinders of other colors; the upper surface edge of each object in the output picture and the shape of the object , position and angle information. Among them, the existing technologies used include color space conversion, adaptive threshold segmentation, grabcut segmentation, canny edge detection, Hough line detection and morphological processing, etc. In addition to the combination of these technologies, the present invention is based on the fact that the object to be assembled is a cylinder. Based on the prior knowledge, processing rules are created to filter out the real edges on the surface of the object from the edge detection results containing a lot of noise.
具体包括如下步骤:Specifically include the following steps:
步骤一:获得操作台俯视图像,使用RGB摄像头,以俯视视角拍摄台面以及台面上的待装配物体,获取操作台图片,如图3所示;Step 1: Obtain the top-view image of the console, use the RGB camera to take pictures of the table top and the objects to be assembled on the table from a top-down perspective, and obtain a picture of the console, as shown in Figure 3;
为了对操作台及待装配物体进行区分,以不同颜色对它们进行标识;操作台设计成白色,待装配物体为其它颜色。In order to distinguish the operating table and the objects to be assembled, they are marked with different colors; the operating table is designed in white, and the objects to be assembled are in other colors.
步骤二:获得物体掩膜,物体掩膜是指至少获得物体上表面的掩膜。Step 2: Obtain an object mask. The object mask refers to at least obtaining a mask on the upper surface of the object.
具体包括如下步骤:Specifically include the following steps:
S21、把图像转到HSV颜色空间,并使用其中的饱和度S通道做自适应阈值分割,由于待装配物体的饱和度比白色台面更高,得到物体掩膜;首先利用白色台面和待装配物体的颜色饱和度不同,把图像转到HSV颜色空间,并使用其中的饱和度S通道做自适应阈值分割,由于待装配物体的饱和度比白色台面更高,将会得到物体掩膜。S21. Transfer the image to the HSV color space, and use the saturation S channel therein to perform adaptive threshold segmentation. Since the saturation of the object to be assembled is higher than that of the white table, an object mask is obtained; first, use the white table and the object to be assembled The color saturation is different, transfer the image to the HSV color space, and use the saturation S channel to do adaptive threshold segmentation. Since the saturation of the object to be assembled is higher than that of the white table, the object mask will be obtained.
S22、去噪,使用膨胀、腐蚀、去除面积过大的连通域等运算去掉部分噪声;去噪技术为现有技术,在此不再赘述。S22. Denoising, using operations such as dilation, erosion, and removal of overly large connected domains to remove part of the noise; the denoising technology is an existing technology, and will not be repeated here.
S23、接着把去噪后的掩膜以及转到Lab颜色空间的台面图片一起输入到grabcut中;去噪后的掩膜以及台面图片一起输入到grabcut中时,掩膜起到替用户手动输入前景区域的作用,使得模块检测流程全自动化,图片转到Lab颜色空间比RGB颜色空间能得到更良好的上表面分割效果。S23, then input the mask after denoising and the table top picture transferred to the Lab color space together into grabcut; when the mask after denoising and the table top picture are input into grabcut together, the mask acts as a manual input foreground for the user The role of the region makes the module detection process fully automated, and the image is transferred to the Lab color space to obtain a better upper surface segmentation effect than the RGB color space.
S24、接下来检测分割掩膜中的连通域面积是否过大,如果过大,怀疑出现多个物体的掩膜粘连情况,把图片转到YCrCb空间中再做一次grabcut并作为物体上表面掩膜,否则直接使用当前Lab颜色空间中的分割结果作为物体上表面掩膜。获得全部物体掩膜如图4所示。S24. Next, check whether the area of the connected domain in the segmentation mask is too large. If it is too large, it is suspected that there is mask adhesion of multiple objects. Transfer the image to the YCrCb space and do a grabcut again and use it as the upper surface mask of the object. , otherwise directly use the segmentation result in the current Lab color space as the upper surface mask of the object. Obtaining all object masks is shown in Figure 4.
步骤三:检测图像中物体边缘。利用Canny边缘检测,得到边缘二值图像,如图5所示,图中显示了所有物体边缘。即使在俯视视角下,仍然存在物体侧面和侧边缘露出的情况,此时与侧表面相连的边缘,其两边颜色变化小,导致这条边缘难以被检出,为了解决这个问题,利用上表面和侧表面主要是在亮度上变化较大的规律,分别在Lab颜色空间中的L分量和HSV颜色空间中的V分量上做边缘检测,因为这两个分量更能体现亮度变化。然后把两个分量得到的检测结果求并集。Step 3: Detect the edge of the object in the image. Using Canny edge detection, the edge binary image is obtained, as shown in Figure 5, which shows the edges of all objects. Even in the top view angle, there are still cases where the sides and side edges of the object are exposed. At this time, the edge connected to the side surface has a small color change on both sides, making it difficult to detect this edge. In order to solve this problem, use the upper surface and The side surface is mainly in the law of large changes in brightness. Edge detection is performed on the L component in the Lab color space and the V component in the HSV color space, because these two components can better reflect the brightness change. Then the detection results obtained by the two components are combined.
步骤四:利用步骤二获得的掩膜去噪对第三步所得边缘去噪,此步骤希望获得噪声尽量少的边缘。去掉的噪声包括物体边缘内部和外部两种噪声。对掩膜做膨胀操作,并与边缘检测结果求交集,用于去除外部边缘噪声;再对掩膜做腐蚀操作,并求与边缘检测结果的差集,用于去除内部噪声,如图6-11所示,其中,图6是三角形去噪的示意图,图7是五边形去噪的示意图,图8是圆形去噪的示意图,图9是正方形去噪的示意图,图10是全部图形去噪的示意图。Step 4: Use the mask denoising obtained in step 2 to denoise the edge obtained in the third step. In this step, it is hoped to obtain an edge with as little noise as possible. The removed noise includes two kinds of noise inside and outside the edge of the object. Perform an expansion operation on the mask, and intersect with the edge detection result to remove external edge noise; then perform an erosion operation on the mask, and obtain the difference with the edge detection result to remove internal noise, as shown in Figure 6- 11, wherein, Fig. 6 is a schematic diagram of triangle denoising, Fig. 7 is a schematic diagram of pentagonal denoising, Fig. 8 is a schematic diagram of circular denoising, Fig. 9 is a schematic diagram of square denoising, Fig. 10 is a schematic diagram of all graphics Schematic diagram of denoising.
步骤五:检测是否存在圆。由于圆柱上表面为圆形,不包含直线,后续针对直线的检测和处理无法进行,因此在本步需要判断当前处理的目标物体是否为圆柱。Step 5: Detect whether there is a circle. Since the upper surface of the cylinder is circular and does not contain straight lines, subsequent detection and processing of straight lines cannot be performed. Therefore, in this step, it is necessary to determine whether the target object currently being processed is a cylinder.
检测过程如图11-14所示,图11是三角形掩膜与图像的交集示意图,图12是四边形掩膜与图像的交集示意图,图13是五边形掩膜与图像的交集示意图,图14是圆柱掩膜与图像的交集示意图。The detection process is shown in Figures 11-14. Figure 11 is a schematic diagram of the intersection of a triangular mask and an image. Figure 12 is a schematic diagram of the intersection of a quadrilateral mask and an image. Figure 13 is a schematic diagram of the intersection of a pentagonal mask and an image. Figure 14 is a schematic diagram of the intersection of a cylindrical mask and an image.
检测是否存在圆时,物体掩膜作用于Lab颜色空间所得交集结果中,利用霍夫圆变换检测检测是否存在圆形,若是,得到最合适的上表面圆并进入步骤九,否则进入步骤六。其中,得到上表面圆的流程为,分别在HSV和Lab颜色空间的图像中使用霍夫圆检测,自适应地找到该颜色空间中param2最大的圆,再以圆心靠外的圆作为上表面圆。其中param2是霍夫圆检测函数的输入参数,表示圆的规则程度,只有大于param2的形状,能被当做圆检出。选择靠外的圆作为上表面圆,依据是在俯视视角下,上表面总是相对靠近图片外围。When detecting whether there is a circle, the object mask is applied to the intersection result obtained in the Lab color space, and the Hough circle transformation is used to detect whether there is a circle. If so, the most suitable upper surface circle is obtained and enters step 9, otherwise, enters step 6. Among them, the process of obtaining the upper surface circle is to use Hough circle detection in the images of HSV and Lab color spaces respectively, adaptively find the circle with the largest param2 in the color space, and then use the circle with the outer center as the upper surface circle . Among them, param2 is the input parameter of the Hough circle detection function, which indicates the regularity of the circle. Only shapes larger than param2 can be detected as circles. The outer circle is selected as the upper surface circle, based on the fact that the upper surface is always relatively close to the periphery of the picture in the top view.
步骤六:获得边缘所在直线的信息。边缘检测结果图像形式的二值掩膜,而非各线段数学表达式,为了后续计算,要从二值掩膜中获得直线解析式。本发明使用霍夫直线检测技术,自适应地获得当前边缘检测图像中长度大于th1的线段所在的直线解析式。其中,阈值th1用于限制线段的最短长度,在图像上短于th1的直线将不被检出。在实际使用过程中,需要根据图像中待装配物体边缘的长度做调整,使得th1略小于物体边缘线段的长度,达到既能检出所有边缘线段,又能滤掉长度较短的噪音线段的目的。经验地,可设为物体边缘长度的0.6~0.8倍。比如,图像物体边缘的长度最短为100像素时,则可设th1为60~80中的某值。Step 6: Obtain the information of the straight line where the edge is located. The binary mask in the image form of the edge detection result is not the mathematical expression of each line segment. For subsequent calculations, the straight line analytical formula must be obtained from the binary mask. The present invention uses the Hough straight line detection technology to adaptively obtain the straight line analytical formula where the line segment whose length is greater than th1 in the current edge detection image is located. Among them, the threshold th1 is used to limit the shortest length of the line segment, and the straight line shorter than th1 on the image will not be detected. In actual use, it is necessary to adjust according to the length of the edge of the object to be assembled in the image, so that th1 is slightly smaller than the length of the edge line segment of the object, so as to achieve the purpose of not only detecting all edge line segments, but also filtering out shorter noise line segments . Empirically, it can be set as 0.6 to 0.8 times the length of the edge of the object. For example, when the length of the edge of the image object is at least 100 pixels, then th1 can be set to a value between 60 and 80.
具体流程如图2所示,通过这个流程,会根据线段长度的倒序,记录所有长度大于th1的线段所在的直线信息,信息包括倾斜角theta、直线到图片原点的距离rho和检出时的长度阈值th,其中,th是霍夫直线检测函数的输入参数,只有长度大于th的线段才会被检出。具体流程如下:The specific process is shown in Figure 2. Through this process, the line information of all line segments with a length greater than th1 will be recorded according to the reverse order of the length of the line segment. The information includes the inclination angle theta, the distance rho from the line to the origin of the image, and the length when detected. Threshold th, wherein, th is the input parameter of the Hough line detection function, and only the line segment whose length is greater than th will be detected. The specific process is as follows:
S41、获得th=th1的线段;S41. Obtain the line segment of th=th1;
S42、检测长度大于th的线段;S42, detecting a line segment whose length is greater than th;
S43、判断是否检测到直线;如果未检测到直线则继续下一步;如果有,则令th+=4,并返回S42;S43, judging whether a straight line is detected; if no straight line is detected, continue to the next step; if yes, make th+=4, and return to S42;
S44、令th-=1;S44, let th-=1;
S45、进一步判断th>th1,是则继续下一步,否则结束;S45. Further judge that th>th1, if yes, continue to the next step, otherwise end;
S46、检测长度大于th的线段;S46, detecting a line segment whose length is greater than th;
S47、判断是否检测到直线;如果检测到直线则记录th以及霍夫直线检测输出的直线倾斜角theta和到图片原点的距离rho,并在原图中删除本次检测到的直线;如果无,则返回S44步骤,令th-=1。S47. Determine whether a straight line is detected; if a straight line is detected, record th and the straight line inclination angle theta output by Hough line detection and the distance rho to the origin of the picture, and delete the detected straight line in the original image; if not, then Return to step S44, set th-=1.
删除检测到的直线后,循环执行上述步骤,直至所有检测完成。After deleting the detected straight lines, execute the above steps in a loop until all detections are completed.
检测三角形边缘直线如图15所示,检测五边形边缘直线如图16所示,检测正方形边缘直线如图17所示。步骤七:根据规则筛出物体上表面边缘直线,本步骤希望排除物体侧表面边缘、底面边缘和其他噪声的干扰,且选出最贴合物体上表面实际边缘的直线。由于步骤五由霍夫检测得到的直线会受到边缘检测结果的影响,当边缘二值掩膜的线段有像素级别的弯曲、线段宽度大于1,或有噪音时,物体的每条边缘附近都会检测出一系列直线,为了从中筛出最贴近真实边缘的直线,要依次进行直线分组、直线去噪和选择直线三个操作。其中,直线分组是为了把所有边缘的直线分别对应到各条实际边缘上,分类后每组直线都对应一条物体表面的实际边缘。直线去噪是在分组的基础上,去掉噪声线段及对应侧边缘线段的直线组,保证剩下的每个直线组都能对应物体的一条上表面边缘。此时,每组直线中,有贴近真正上表面边缘的直线,也可能有贴近下表面边缘的直线,这些直线还有角度差异,并非每一条都能紧密贴合实际上表面边缘。最后一步,直线选择,就是要在每组直线中,各自选出最能匹配物体真实边缘的一条直线,以此作为上表面直线检测结果。Figure 15 shows the detection of triangle edge straight lines, detection of pentagon edge straight lines is shown in Figure 16, and detection of square edge straight lines is shown in Figure 17. Step 7: Screen out the straight line on the upper surface edge of the object according to the rules. This step hopes to eliminate the interference of the side surface edge, bottom surface edge and other noises of the object, and select the straight line that best fits the actual edge of the upper surface of the object. Since the straight line obtained by Hough detection in step 5 will be affected by the edge detection result, when the line segment of the edge binary mask has pixel-level curvature, the line segment width is greater than 1, or there is noise, it will be detected near each edge of the object A series of straight lines are drawn, and in order to screen out the straight lines closest to the real edge, three operations of straight line grouping, straight line denoising and straight line selection are performed in sequence. Among them, the straight line grouping is to correspond the straight lines of all the edges to each actual edge respectively, and after classification, each group of straight lines corresponds to an actual edge of the object surface. Line denoising is to remove the noise line segment and the line group corresponding to the side edge line segment on the basis of grouping, so as to ensure that each remaining line group can correspond to an upper surface edge of the object. At this time, in each group of straight lines, there may be straight lines close to the edge of the real upper surface, and there may be straight lines close to the edge of the lower surface. These straight lines also have angle differences, and not all of them can closely fit the actual edge of the surface. The last step, straight line selection, is to select a straight line that best matches the real edge of the object in each group of straight lines, and use it as the result of the upper surface straight line detection.
直线分组:分组目的是使每组直线对应目标物体的一条边缘,需要找到用来分组的特征。由于物体是正多棱柱,上表面即为正多边形,已知奇数边的正多边形各边所在直线斜率不同,可使用角度特征区分各边;偶数边的正多边形的对边两两平行且间距较大,不同对边之间角度不同,可使用角度与距离特征同时区分各边。进一步考虑多棱柱侧表面边缘,当侧表面露出时,存在一条与上表面对应边缘平行且距离较近的棱,也就是下表面的边缘,以及两条在现实中垂直于操作台的棱,也就是只属于侧表面的边缘,他们的角度与上表面各边缘不同。因此,在任何情况下,同时考虑角度和距离特征,就可将直线对应到正多棱柱的各边。Straight line grouping: The purpose of grouping is to make each group of straight lines correspond to an edge of the target object, and it is necessary to find the features used for grouping. Since the object is a regular polygonal prism, the upper surface is a regular polygon. It is known that the slope of the straight line on each side of a regular polygon with odd sides is different, and the angle feature can be used to distinguish each side; the opposite sides of a regular polygon with even sides are parallel and have a large distance , the angles between different opposite sides are different, and the angle and distance features can be used to distinguish each side at the same time. Further consider the edge of the side surface of the polygonal prism. When the side surface is exposed, there is an edge parallel to and relatively close to the corresponding edge of the upper surface, that is, the edge of the lower surface, and two edges perpendicular to the operating table in reality. It is the edges that belong only to the side surfaces, and their angles are different from the edges of the upper surface. Therefore, in any case, considering both angle and distance features, straight lines can be mapped to the sides of regular polygonal prisms.
首先,分别设置角度阈值th2和距离阈值th3。其中,th2反映角度偏移的容差程度,角度之差在th2内的直线都归为同一组,当th2越大,则会把更大角度差距范围内的直线分进同一组,具体取值以能区分不同边、又能容忍一定角度误差为宜,可取值th2=0.3*min(内角角度,外角角度)。以三角形为例,其内角角度为60°,外角角度为120°,取两者最小值60°,再乘0.3,则可设th2=0.3*60°=18°。距离阈值th3,用于区分对边中的两条边,当两条直线距离之差小于th3时,认为他们属于同一条边,否则分别属于不同对边。Th3的取值需要根据图片上目标物体的尺寸做调整,使得能把物体上表面平行的边缘分成两组,而把平行的上下表面边缘合在同一组。可取值th3=0.5*上表面正多边形的最小外接矩形之宽。First, set the angle threshold th2 and the distance threshold th3 respectively. Among them, th2 reflects the degree of tolerance of the angle offset. The straight lines with the angle difference within th2 are all classified into the same group. When th2 is larger, the straight lines within the larger angle difference range will be classified into the same group. The specific value It is advisable to be able to distinguish different sides and tolerate a certain angle error, and the desirable value th2=0.3*min (inner angle angle, outer angle angle). Taking a triangle as an example, the interior angle is 60°, and the exterior angle is 120°. Take the minimum of the two angles of 60° and multiply by 0.3, then th2=0.3*60°=18°. The distance threshold th3 is used to distinguish two sides in the opposite side. When the difference between the two straight-line distances is less than th3, they are considered to belong to the same side, otherwise they belong to different opposite sides. The value of Th3 needs to be adjusted according to the size of the target object on the picture, so that the parallel edges on the upper surface of the object can be divided into two groups, and the parallel upper and lower surface edges can be combined into the same group. The possible value th3=0.5*the width of the smallest circumscribed rectangle of the regular polygon on the upper surface.
接着,使用th2和th3进行分组。根据记录的直线信息theta,将角度差距在th2内的所有直线分为一组,每组包含至少一条直线;在此基础上,距离差距大于th3且几乎平行的直线被分成不同组。其中判断直线几乎平行的规则是,两条直线在画面范围内没有交点。Next, use th2 and th3 for grouping. According to the recorded straight line information theta, all straight lines whose angle difference is within th2 are divided into one group, and each group contains at least one straight line; on this basis, straight lines whose distance difference is greater than th3 and are almost parallel are divided into different groups. The rule for judging that straight lines are almost parallel is that there is no intersection point between two straight lines within the scope of the screen.
在实际使用过程中,还需要根据分组结果,判断th2和th3取值的合理性,若有需要,可反复进行以上两步,直到分组效果达到预期,也就是使得每组直线对应物体的一条棱。In the actual use process, it is also necessary to judge the rationality of the values of th2 and th3 according to the grouping results. If necessary, the above two steps can be repeated until the grouping effect reaches the expectation, that is, each group of straight lines corresponds to an edge of the object .
直线去噪:本步目的为去掉侧边缘中垂直于操作台的两条边缘和其他噪声。利用俯视视角下这两条棱和噪声长度较短的规律,可设置长度阈值th4去掉它们。若某一组只有一条直线且对应th<th4,则去掉这一组。其中,th4的作用是,从所有直线中,分出较短的垂直棱和噪音,取值范围为(垂直棱和噪音直线长度,上表面边缘长度),可先取该范围的中值,然后根据实际去噪结果反复调整,知道能达到本步目的。Line denoising: The purpose of this step is to remove the two edges perpendicular to the operating table and other noises in the side edges. Taking advantage of the fact that the two edges and the noise are shorter in length from the top view angle, the length threshold th4 can be set to remove them. If a group has only one straight line and corresponds to th<th4, remove this group. Among them, the function of th4 is to separate shorter vertical edges and noises from all straight lines. The range of values is (the length of the vertical edges and the noise line, the length of the upper surface edge). The median value of this range can be taken first, and then according to The actual denoising results are adjusted repeatedly until the purpose of this step can be achieved.
选择直线:经过前面的直线分组和直线去噪步骤,目前的直线组中只包括对应上表面边缘和与其平行的下表面边缘的直线。本步的目的是,在检出的直线中,选出一条最合适的直线作为对应上表面边缘的检测结果。利用上表面直线相比下表面直线,框出的物体部分更少,框出部分不在第二步输出的掩膜范围的可能性越小的规律,分别比较每条直线框出的物体与掩膜的差异,为每组选出差异最小的直线,认为是上表面边缘。具体地,需要先为每条直线构建封闭框,接着比较封闭范围与掩膜的差异。其中,封闭框的边缘,由该条直线和其他直线组内距离掩膜中心最近的直线组成,目的是保证围成的封闭图形与掩膜的差异只由该直线决定。比较封闭框A中的所有像素与grabcut的掩膜B中的所有像素,为每条直线记录在A却不在B中的像素的个数n。之后,每组中选出一条n最小的直线,认为是真正的上表面边缘直线。Selecting straight lines: After the previous straight line grouping and straight line denoising steps, the current straight line group only includes straight lines corresponding to the upper surface edge and the lower surface edge parallel to it. The purpose of this step is to select the most suitable straight line among the detected straight lines as the detection result corresponding to the edge of the upper surface. Using the law that the upper surface straight line is compared with the lower surface straight line, the part of the framed object is less, and the possibility that the framed part is not in the range of the mask output in the second step is smaller, and the object framed by each straight line is compared with the mask. For each group, select the straight line with the smallest difference, which is considered to be the edge of the upper surface. Specifically, it is necessary to first construct a closed box for each straight line, and then compare the difference between the closed range and the mask. Among them, the edge of the closed frame is composed of this straight line and the straight line closest to the center of the mask in other straight line groups, so as to ensure that the difference between the enclosed figure and the mask is only determined by this straight line. Comparing all the pixels in the enclosing box A with all the pixels in the grabcut mask B, record the number n of pixels in A but not in B for each line. Afterwards, a straight line with the smallest n is selected from each group, which is considered to be the true upper surface edge straight line.
如图18-20所示,其中,图18是三角形上表面直线,图19是五边形上表面直线,图20是正方形上表面直线。As shown in Figures 18-20, Figure 18 is a straight line on the upper surface of a triangle, Figure 19 is a straight line on the upper surface of a pentagon, and Figure 20 is a straight line on the upper surface of a square.
步骤八:直线缩短为物体边缘线段。由于在第四步得到的是直线信息,非线段信息,而真正的边缘是线段,为此,本步骤首先求出正多边形的各顶点,然后连接相邻顶点,获得边缘线段。顶点是相邻边缘直线的交点,因此要先判断直线的相邻关系。具体做法是设置距离阈值th5,并遍历当前所有两两搭配的直线组合,计算直线交点到掩膜的距离,若距离小于th5,认为这两条直线相邻。此处依据的规律是,顶点到掩膜的距离较近,而非相邻直线的交点距离掩膜更远。Th5即为区分这两种距离而设,一般可设为30像素。计算点到掩膜的距离方式是,以该点为圆心,绘制半径逐渐增加的圆,当圆开始与掩膜有交集时,圆的半径就是点到掩膜的距离。得到所有直线的相邻关系后,再计算相邻直线顶点并依次连接顶点,得到物体上表面的边缘。Step 8: The straight line is shortened to the edge segment of the object. Since what is obtained in the fourth step is straight line information, not line segment information, and the real edge is a line segment, for this reason, this step first obtains each vertex of the regular polygon, and then connects adjacent vertices to obtain the edge line segment. The vertex is the intersection point of adjacent edge lines, so the adjacent relationship of the lines must be judged first. The specific method is to set the distance threshold th5, and traverse all the current pairwise combinations of straight lines, and calculate the distance from the intersection point of the straight lines to the mask. If the distance is less than th5, the two straight lines are considered adjacent. The rule here is that vertices are closer to the mask than intersections of non-adjacent lines are farther away from the mask. Th5 is designed to distinguish these two distances, and generally can be set to 30 pixels. The way to calculate the distance from the point to the mask is to use the point as the center to draw a circle with increasing radius. When the circle starts to intersect with the mask, the radius of the circle is the distance from the point to the mask. After obtaining the adjacency relationship of all straight lines, calculate the vertices of the adjacent straight lines and connect the vertices in turn to obtain the edge of the upper surface of the object.
如图21-23所示,其中,图21是三角形边缘线段,图22是五边形边缘线段,图23是正方形边缘线段。As shown in Figures 21-23, Figure 21 is a triangle edge line segment, Figure 22 is a pentagon edge line segment, and Figure 23 is a square edge line segment.
步骤九:计算物体的形状、形心、角度。根据正多棱柱的形状和顶点数一一对应的关系,由顶点个数即可得到形状,比如,有三个顶点说明是正三棱柱;形心可根据上表面边缘围成的封闭图形计算;物体的角度由上表面最小外接矩形的旋转角度计算得到。如图24所示。Step 9: Calculate the shape, centroid, and angle of the object. According to the one-to-one relationship between the shape of a regular polygonal prism and the number of vertices, the shape can be obtained from the number of vertices. For example, three vertices indicate that it is a regular triangular prism; the centroid can be calculated according to the closed figure surrounded by the upper surface edge; the object The angle of is calculated from the rotation angle of the smallest circumscribed rectangle on the upper surface. As shown in Figure 24.
因此,本发明能准确分割出正多棱柱物体的上表面,边缘平直锐利、顶点明确,在此基础上能更准确地计算出机械臂装配任务所需信息,包括得到的位置、角度和形状信息,使得自动化装配任务能顺利完成,降低由于分割获检测结果不理想导致装配失败的可能性,从而得到准确的摆放任务需要的吸取位置、物体形状和物体角度,帮助摆放任务顺利完成。Therefore, the present invention can accurately segment the upper surface of the regular polygonal prism, with straight and sharp edges and clear vertices. On this basis, the information required for the manipulator assembly task can be calculated more accurately, including the obtained position, angle and shape. Information, so that the automatic assembly task can be completed smoothly, reduce the possibility of assembly failure due to unsatisfactory segmentation and detection results, so as to obtain the accurate suction position, object shape and object angle required for the placement task, and help the placement task to be completed smoothly.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. within range.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310009829.7A CN116188571A (en) | 2023-01-04 | 2023-01-04 | A regular polygonal prism detection method for manipulator |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310009829.7A CN116188571A (en) | 2023-01-04 | 2023-01-04 | A regular polygonal prism detection method for manipulator |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116188571A true CN116188571A (en) | 2023-05-30 |
Family
ID=86448140
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310009829.7A Pending CN116188571A (en) | 2023-01-04 | 2023-01-04 | A regular polygonal prism detection method for manipulator |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116188571A (en) |
-
2023
- 2023-01-04 CN CN202310009829.7A patent/CN116188571A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110807355B (en) | A pointer meter detection and reading recognition method based on mobile robot | |
CN110286124B (en) | Machine vision-based refractory brick measuring system | |
JP5699788B2 (en) | Screen area detection method and system | |
WO2022088620A1 (en) | State detection method and apparatus for camera lens, device and storage medium | |
CN108846401A (en) | Commodity detect terminal, method, system and computer equipment, readable medium | |
WO2022033076A1 (en) | Target detection method and apparatus, device, storage medium, and program product | |
CN104298996B (en) | A kind of underwater active visual tracking method applied to bionic machine fish | |
CN113283439B (en) | Intelligent counting method, device and system based on image recognition | |
CN113449606B (en) | Target object identification method and device, computer equipment and storage medium | |
CN106203433A (en) | In a kind of vehicle monitoring image, car plate position automatically extracts and the method for perspective correction | |
CN111666824B (en) | Indicator recognition method for mobile robots based on color attributes and machine learning | |
CN111144337B (en) | Fire detection method and device and terminal equipment | |
CN109272513B (en) | Depth camera-based hand and object interactive segmentation method and device | |
CN112364865A (en) | Method for detecting small moving target in complex scene | |
CN111382658B (en) | Road traffic sign detection method in natural environment based on image gray gradient consistency | |
CN110569774B (en) | An Automatic Digitization Method of Line Chart Image Based on Image Processing and Pattern Recognition | |
JP3490482B2 (en) | Edge and contour extraction device | |
CN106774846B (en) | Interactive projection method and device | |
CN104637066A (en) | Method for extracting binary image quick skeleton based on sequential refining | |
CN114219946B (en) | Text image binarization method and device, electronic equipment and medium | |
CN113284158B (en) | Image edge extraction method and system based on structural constraint clustering | |
CN116188571A (en) | A regular polygonal prism detection method for manipulator | |
CN117787690A (en) | Hoisting operation safety risk identification method and identification device | |
CN114581890B (en) | Method and device for determining lane line, electronic equipment and storage medium | |
CN116959367A (en) | Bright and dark line correction method of screen and electronic equipment |
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 |