CN111504188A - Arc part measuring method and device based on machine vision - Google Patents
- ️Fri Aug 07 2020
技术领域technical field
本发明涉及精密测量技术领域,特别涉及一种基于机器视觉的圆弧零件测量方法及装置。The invention relates to the technical field of precision measurement, in particular to a method and device for measuring arc parts based on machine vision.
背景技术Background technique
在现代制造业中,许多机械零件具有多圆弧特征,如铣刀、齿轮、法兰、球笼联轴器内套等,这些零件上的圆弧特性加工精度直接影响着零件的功能能否实现,对后续装配产品的性能也具有重要影响。因此,对该类机械零件的尺寸测量是机械产品零部件检测中一项非常重要的内容。In modern manufacturing, many mechanical parts have multi-arc features, such as milling cutters, gears, flanges, inner sleeves of ball cage couplings, etc. The machining accuracy of the arc characteristics on these parts directly affects the function of the parts. It also has a significant impact on the performance of subsequent assembled products. Therefore, the dimensional measurement of such mechanical parts is a very important content in the inspection of mechanical product parts.
目前,在实际生产中,对这类零件的测量主要通过千分尺、卡规、专用量块等传统接触式测量方法,这些方法存在测量精度不稳定、容易损伤零件和效率低等缺点。基于机器视觉的尺寸测量技术是在计算机视觉研究的基础上发展的一种非接触式测量技术,具有测量精度高、速度快、成本低等优点,随着计算机硬件和图像处理技术的飞速发展,视觉测量在实际生产中已得到了广泛的应用。因此,如何提出一种基于机器视觉的圆弧零件测量方法及装置是亟待解决的问题。At present, in actual production, the measurement of such parts is mainly through traditional contact measurement methods such as micrometers, calipers, and special gauge blocks. These methods have shortcomings such as unstable measurement accuracy, easy damage to parts, and low efficiency. Dimensional measurement technology based on machine vision is a non-contact measurement technology developed on the basis of computer vision research. It has the advantages of high measurement accuracy, fast speed and low cost. With the rapid development of computer hardware and image processing technology, Visual measurement has been widely used in actual production. Therefore, how to propose a method and device for measuring arc parts based on machine vision is an urgent problem to be solved.
发明内容SUMMARY OF THE INVENTION
本发明的主要目的是提出一种基于机器视觉的圆弧零件测量方法及装置,旨在解决传统接触式测量方法,这些方法存在测量精度不稳定、容易损伤零件和效率低的问题。The main purpose of the present invention is to propose a method and device for measuring arc parts based on machine vision, aiming to solve the problems of traditional contact measurement methods, which have the problems of unstable measurement accuracy, easy damage to parts and low efficiency.
为实现上述目的,本发明提出一种基于机器视觉的圆弧零件测量方法,包括以下步骤:In order to achieve the above object, the present invention proposes a method for measuring arc parts based on machine vision, comprising the following steps:
获取圆弧零件的采样图像;Get sampled images of arc parts;
提取所述采样图像中圆弧零件的亚像素边缘轮廓;extracting the sub-pixel edge contour of the arc part in the sampled image;
根据所述亚像素边缘轮廓,计算获得轮廓拟合圆;According to the sub-pixel edge contour, calculate and obtain the contour fitting circle;
根据所述轮廓拟合圆的参数和圆弧零件的合格尺寸,计算获得圆弧零件的尺寸偏差量。According to the parameters of the contour fitting circle and the qualified size of the arc part, the dimensional deviation of the arc part is obtained by calculation.
可选地,所述获取圆弧零件的采样图像的步骤之前,还包括:Optionally, before the step of acquiring the sampling image of the arc part, the method further includes:
对拍摄所述采样图像的相机进行标定,以获取所述采样图像中的像素尺寸与圆弧零件的实际尺寸的映射关系。The camera that shoots the sampled image is calibrated to obtain the mapping relationship between the pixel size in the sampled image and the actual size of the arc part.
可选地,所述获取圆弧零件的采样图像的步骤之后,还包括:Optionally, after the step of acquiring the sampling image of the arc part, the method further includes:
通过傅里叶变换将所述采样图像变换至频域,对所述采样图像的频谱进行滤波修正,以得到频域滤波图像;Transform the sampled image into the frequency domain through Fourier transform, and filter and correct the spectrum of the sampled image to obtain a frequency-domain filtered image;
通过傅里叶反变换将所述频域滤波图像变换至空域,以得到图像增强后的所述采样图像。The frequency-domain filtered image is transformed into the spatial domain by inverse Fourier transform, so as to obtain the image-enhanced sampled image.
可选地,所述提取所述采样图像中圆弧零件的亚像素边缘轮廓的步骤,包括:Optionally, the step of extracting the sub-pixel edge contour of the arc part in the sampled image includes:
提取所述采样图像中圆弧零件的像素边缘轮廓,以及所述像素边缘轮廓灰度值的高斯分布曲线;Extracting the pixel edge contour of the arc part in the sampled image, and the Gaussian distribution curve of the gray value of the pixel edge contour;
计算获得用以高次逼近所述高斯分布曲线的二次曲线;calculating a quadratic curve for approximating the Gaussian distribution curve with a high degree;
根据所述二次曲线的顶点坐标,获取所述亚像素边缘轮廓。Obtain the sub-pixel edge contour according to the vertex coordinates of the quadratic curve.
可选地,当圆弧零件具有多段圆弧时,所述根据所述亚像素边缘轮廓,计算获得轮廓拟合圆的步骤,包括:Optionally, when the arc part has multiple arcs, the step of calculating and obtaining the contour fitting circle according to the sub-pixel edge contour includes:
分割所述亚像素边缘轮廓,获得圆弧零件中每段所述圆弧的亚像素边缘轮廓;Divide the sub-pixel edge contour to obtain the sub-pixel edge contour of each segment of the arc in the arc part;
将每段所述圆弧的亚像素边缘轮廓划分成单独的连通域;dividing the sub-pixel edge contour of each segment of the arc into separate connected domains;
对每个所述连通域进行轮廓拟合,得到每段所述圆弧对应的轮廓拟合圆。Contour fitting is performed on each of the connected domains to obtain a contour fitting circle corresponding to each segment of the arc.
可选地,当圆弧零件的外轮廓呈圆形设置,且圆弧零件的多段圆弧沿周向间隔排布时,所述对每个所述连通域进行轮廓拟合,得到每段所述圆弧对应的轮廓拟合圆的步骤之后,还包括:Optionally, when the outer contour of the arc part is arranged in a circular shape, and the multi-segment arcs of the arc part are arranged at intervals in the circumferential direction, the contour fitting is performed on each of the connected domains, and each segment is obtained. After the steps of fitting the circle to the contour corresponding to the arc, it also includes:
提取两段对称圆弧的轮廓拟合圆的点集(xk,yk),(k=1,2...n)和(xm,ym),(m=1,2...n),循环遍历两个所述点集,计算获得每对点的像素距离
其中,两段所述对称圆弧的圆心位于圆弧零件的直径所在的直线上;Extract the contours of two symmetrical arcs from the point sets (x k , y k ), (k=1, 2...n) and (x m , y m ), (m=1, 2.. .n), loop through the two point sets, and calculate the pixel distance of each pair of points Wherein, the centers of the two symmetrical arcs are located on the straight line where the diameter of the arc part is located;对每对点的所述像素距离进行排序,以获得所述像素距离的最小值Lmin和对应的点的坐标值;Sort the pixel distance of each pair of points to obtain the minimum value L min of the pixel distance and the coordinate value of the corresponding point;
对其他段所述对称圆弧的轮廓拟合圆的点集重复上述两个步骤,获得每对所述对称圆弧之间的距离的最小值Lmin’,以及对应的点的坐标值,以计算得到圆弧零件的内切拟合圆,所述内切拟合圆的半径
其中,所述内切拟合圆的半径R为每对所述对称圆弧之间的距离的最小值之和的平均数。Repeat the above two steps for the point sets of the contour fitting circles of the other segments of the symmetrical circular arcs to obtain the minimum value L min ' of the distance between each pair of the symmetrical circular arcs, and the coordinates of the corresponding points to obtain Calculate the inscribed fitting circle of the arc part, and the radius of the inscribed fitting circle Wherein, the radius R of the inscribed fitting circle is the average of the sum of the minimum values of the distances between each pair of the symmetrical circular arcs.可选地,所述对所述连通域进行轮廓拟合,得到所述轮廓拟合圆的步骤,具体包括:Optionally, the step of performing contour fitting on the connected domain to obtain the contour fitting circle specifically includes:
通过最小二乘法对每个所述连通域进行轮廓拟合,得到每段所述圆弧对应的轮廓拟合圆。Contour fitting is performed on each of the connected domains by the least squares method, and a contour fitting circle corresponding to each segment of the arc is obtained.
可选地,所述轮廓拟合圆的参数包括直径、同轴度、曲率半径和公差中的一种或多种。Optionally, the parameters of the contour fitting circle include one or more of diameter, coaxiality, radius of curvature and tolerance.
此外,本发明还提出一种基于机器视觉的圆弧零件测量装置,包括:In addition, the present invention also proposes a device for measuring arc parts based on machine vision, comprising:
载物台,用以放置圆弧零件;A stage for placing arc parts;
视觉采集装置,安装于所述载物台,所述视觉采集装置包括用以拍摄圆弧零件的相机,以拍摄得到圆弧零件的采样图像;以及,a visual acquisition device, installed on the object stage, the visual acquisition device includes a camera for photographing the arc part, so as to obtain a sampling image of the arc part; and,
终端,与所述视觉采集装置电性连接,所述终端包括处理器和存储介质,所述存储介质存储有基于机器视觉的圆弧零件测量程序,所述圆弧零件测量程序执行如本发明所述的基于机器视觉的圆弧零件测量方法的步骤。A terminal is electrically connected to the visual acquisition device, the terminal includes a processor and a storage medium, and the storage medium stores a machine vision-based arc part measurement program, and the execution of the arc part measurement program is as described in the present invention The steps of the described machine vision-based arc part measurement method.
本发明的技术方案中,基于机器视觉的圆弧零件测量方法及装置通过提取圆弧零件的亚像素边缘轮廓,获得了检测精度更高的图像轮廓,根据亚像素边缘轮廓得到的轮廓拟合圆更符合圆弧零件的实际边缘轮廓,使圆弧零件的尺寸偏差量能计算得更精准。In the technical solution of the present invention, the method and device for measuring arc parts based on machine vision obtains image contours with higher detection accuracy by extracting the sub-pixel edge contours of arc parts, and fits a circle according to the contour obtained by the sub-pixel edge contours. It is more in line with the actual edge contour of the arc part, so that the dimensional deviation of the arc part can be calculated more accurately.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图示出的结构获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can also be obtained according to the structures shown in these drawings without creative efforts.
图1为本发明的基于机器视觉的圆弧零件测量方法的第一实施例的流程示意图;Fig. 1 is the schematic flow chart of the first embodiment of the method for measuring arc parts based on machine vision of the present invention;
图2为本发明的基于机器视觉的圆弧零件测量方法的另一实施例的流程示意图;2 is a schematic flowchart of another embodiment of the method for measuring a circular arc part based on machine vision of the present invention;
图3为本发明的基于机器视觉的圆弧零件测量方法中计算获得的轮廓拟合圆的示意图;3 is a schematic diagram of a contour fitting circle obtained by calculation in the machine vision-based arc part measuring method of the present invention;
图4为本发明的采用二次曲线高次逼近高斯分布时的曲线示意图;Fig. 4 is the curve schematic diagram when adopting quadratic curve high-order approximation Gaussian distribution according to the present invention;
图5为当圆弧零件为球笼联轴器时对每段圆弧计算获得的轮廓拟合圆的示意图;5 is a schematic diagram of a contour fitting circle obtained by calculating each arc when the arc part is a ball cage coupling;
图6为本发明的基于机器视觉的圆弧零件测量装置的结构示意图。FIG. 6 is a schematic structural diagram of the machine vision-based arc part measuring device of the present invention.
附图标号说明:Description of reference numbers:
标号label 名称name 标号label 名称name 11 载物台Stage 33 相机camera 1111 背光源Backlight 44 终端terminal 22 相机支架camera mount 55 圆弧零件Arc Parts
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
需要说明,若本发明实施例中有涉及方向性指示(诸如上、下、左、右、前、后……),则该方向性指示仅用于解释在某一特定姿态(如附图所示)下各部件之间的相对位置关系、运动情况等,如果该特定姿态发生改变时,则该方向性指示也相应地随之改变。It should be noted that if there are directional indications (such as up, down, left, right, front, back, etc.) involved in the embodiments of the present invention, the directional indications are only used to explain a certain posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication also changes accordingly.
另外,若本发明实施例中有涉及“第一”、“第二”等的描述,则该“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,全文中出现的“和/或”的含义,包括三个并列的方案,以“A和/或B”为例,包括A方案、或B方案、或A和B同时满足的方案。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本发明要求的保护范围之内。In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for the purpose of description, and should not be construed as indicating or implying Its relative importance or implicitly indicates the number of technical features indicated. Thus, a feature delimited with "first", "second" may expressly or implicitly include at least one of that feature. In addition, the meaning of "and/or" in the whole text includes three parallel schemes. Taking "A and/or B" as an example, it includes scheme A, scheme B, or scheme satisfying both of A and B. In addition, the technical solutions between the various embodiments can be combined with each other, but must be based on the realization by those of ordinary skill in the art. When the combination of technical solutions is contradictory or cannot be realized, it should be considered that the combination of such technical solutions does not exist. , is not within the scope of protection required by the present invention.
在实际生产中,对这类零件的测量主要通过千分尺、卡规、专用量块等传统接触式测量方法,这些方法存在测量精度不稳定、容易损伤零件和效率低等缺点。基于机器视觉的尺寸测量技术是在计算机视觉研究的基础上发展的一种非接触式测量技术,具有测量精度高、速度快、成本低等优点。基于此,本发明提出一种基于机器视觉的圆弧零件测量方法,请参阅图1-图3,所述圆弧零件测量方法包括以下步骤:In actual production, the measurement of such parts is mainly through traditional contact measurement methods such as micrometers, calipers, and special gauge blocks. These methods have shortcomings such as unstable measurement accuracy, easy damage to parts, and low efficiency. Dimensional measurement technology based on machine vision is a non-contact measurement technology developed on the basis of computer vision research. It has the advantages of high measurement accuracy, fast speed and low cost. Based on this, the present invention proposes a method for measuring arc parts based on machine vision, please refer to Fig. 1 to Fig. 3 , and the method for measuring arc parts includes the following steps:
S100:获取圆弧零件的采样图像。S100: Obtain a sampling image of the arc part.
本步骤中,所述圆弧零件指的是带有圆弧形状或者圆形形状的零件,如铣刀、齿轮、法兰、球笼联轴器内套等。In this step, the arc parts refer to parts with arc shapes or circular shapes, such as milling cutters, gears, flanges, inner sleeves of ball cage couplings, and the like.
S200:提取采样图像中圆弧零件的亚像素边缘轮廓;S200: Extract the sub-pixel edge contour of the arc part in the sampled image;
采样图像的边缘实质上是图像像素点的灰度值发生变化的位置,也就是说,图像轮廓的位置通过灰度值发生变化的图像像素点的位置描述。现有的边缘轮廓检测算法提取的图像轮廓通常为像素级,对于一些检测精度要求较高的零件,像素级的图像轮廓不能满足精度要求。本步骤采用亚像素细分方法来提高零件的检测精度,其中,亚像素是指将像素这个基本单位进行进一步地细分,通常采用拟合像素级边缘位置的算法来描述零件的边缘轮廓。The edge of the sampled image is essentially the position where the gray value of the image pixel changes, that is, the position of the image contour is described by the position of the image pixel where the gray value changes. The image contours extracted by the existing edge contour detection algorithms are usually at the pixel level. For some parts with high detection accuracy requirements, the pixel-level image contours cannot meet the accuracy requirements. In this step, the sub-pixel subdivision method is used to improve the detection accuracy of the part, wherein the sub-pixel refers to the further subdivision of the basic unit of pixel, and the edge contour of the part is usually described by an algorithm of fitting pixel-level edge positions.
S300:根据亚像素边缘轮廓,计算获得轮廓拟合圆;S300: According to the sub-pixel edge contour, calculate and obtain the contour fitting circle;
S400:根据轮廓拟合圆的参数和圆弧零件的标定尺寸,计算获得圆弧零件的尺寸偏差量。S400: Calculate and obtain the size deviation of the arc part according to the parameters of the contour fitting circle and the calibrated size of the arc part.
本实施例中,通过提取圆弧零件的亚像素边缘轮廓,获得了检测精度更高的图像轮廓,根据亚像素边缘轮廓得到的轮廓拟合圆更符合圆弧零件的实际边缘轮廓,使圆弧零件的尺寸偏差量能计算得更精准。In this embodiment, by extracting the sub-pixel edge contour of the arc part, an image contour with higher detection accuracy is obtained, and the contour fitting circle obtained according to the sub-pixel edge contour is more in line with the actual edge contour of the arc part, so that the arc The dimensional deviation of parts can be calculated more accurately.
本实施例中,轮廓拟合圆的参数包括直径、同轴度、曲率半径和公差中的一种或多种,可以更全面地检测圆弧零件的尺寸精度。In this embodiment, the parameters of the contour fitting circle include one or more of diameter, coaxiality, radius of curvature and tolerance, so that the dimensional accuracy of the arc part can be detected more comprehensively.
进一步地,所述获取圆弧零件的采样图像的步骤之前,本发明的圆弧零件测量方法还包括:Further, before the step of acquiring the sampling image of the arc part, the arc part measuring method of the present invention further comprises:
S100’:对拍摄采样图像的相机进行标定,以获取采样图像中的像素尺寸与圆弧零件的实际尺寸的映射关系。S100': Calibrate the camera that shoots the sampled image to obtain the mapping relationship between the pixel size in the sampled image and the actual size of the arc part.
本发明的圆弧零件测量方法基于机器视觉理论,也就是需要相机拍摄待测的圆弧零件,然后对拍摄图像进行图像处理,由于计算得到的零件尺寸是以像素为单位的,为了得到零件的实际尺寸,本步骤对所述相机进行了标定,以实现尺寸转换。具体的,本步骤采用张正友标定法对相机进行标定,标定结果为calib=0.0058mm/pix。The arc part measurement method of the present invention is based on machine vision theory, that is, a camera is required to photograph the arc part to be measured, and then image processing is performed on the captured image. Since the calculated part size is in pixels, in order to obtain the part size In this step, the camera is calibrated to realize size conversion. Specifically, in this step, the camera is calibrated by Zhang Zhengyou's calibration method, and the calibration result is calib=0.0058mm/pix.
进一步地,所述获取圆弧零件的采样图像的步骤之后,本发明的圆弧零件测量方法还包括:Further, after the step of obtaining the sampling image of the arc part, the arc part measuring method of the present invention further comprises:
S210’:通过傅里叶变换将采样图像变换至频域,对采样图像的频谱进行滤波修正,以得到频域滤波图像;S210': transform the sampled image into the frequency domain through Fourier transform, and filter and correct the spectrum of the sampled image to obtain a frequency-domain filtered image;
S220’:通过傅里叶反变换将频域滤波图像变换至空域,以得到图像增强后的采样图像。S220': Transform the frequency-domain filtered image to the spatial domain through inverse Fourier transform to obtain an image-enhanced sampled image.
本步骤中,对圆弧零件的采样图像进行预处理,以实现图像增强,有利于提高测量的稳定性和精度。In this step, the sampling image of the arc part is preprocessed to realize image enhancement, which is beneficial to improve the stability and accuracy of the measurement.
进一步地,所述提取采样图像中圆弧零件的亚像素边缘轮廓的步骤,具体包括:Further, the step of extracting the sub-pixel edge contour of the arc part in the sampled image specifically includes:
S210:提取采样图像中圆弧零件的像素边缘轮廓,以及像素边缘轮廓灰度值的高斯分布曲线;S210: Extract the pixel edge contour of the arc part in the sampled image, and the Gaussian distribution curve of the gray value of the pixel edge contour;
本步骤中,采用Canny边缘检测算法提取像素边缘轮廓,根据中心极限定理,边缘轮廓区域的像素点的灰度值变化呈高斯分布。In this step, the Canny edge detection algorithm is used to extract the pixel edge contour, and according to the central limit theorem, the change of the gray value of the pixel point in the edge contour region is Gaussian distribution.
S220:计算获得用以高次逼近高斯分布曲线的二次曲线;S220: Calculate and obtain a quadratic curve for approximating the Gaussian distribution curve with a high degree;
S230:根据二次曲线的顶点坐标,获取亚像素边缘轮廓。S230: Obtain the sub-pixel edge contour according to the vertex coordinates of the quadratic curve.
请参阅图4,本实施例中,考虑到二次曲线是高斯曲线的高次逼近,而且计算二次曲线的速度快,效率高,因此使用二次曲线来代替高斯曲线,也即使用计算二次曲线来作为计算亚像素边缘轮廓的算法,相应地,二次曲线顶点坐标值对应于图像亚像素精度的边缘轮廓的位置。Please refer to FIG. 4. In this embodiment, considering that the quadratic curve is a high-order approximation of the Gaussian curve, and the calculation of the quadratic curve is fast and efficient, the quadratic curve is used instead of the Gaussian curve, that is, the second calculation method is used. The sub-curve is used as an algorithm for calculating the sub-pixel edge contour, and accordingly, the vertex coordinate value of the quadratic curve corresponds to the position of the sub-pixel edge contour of the image.
由方形孔径的采样定理可知,像素值是像素感光面上各部分光强综合作用的结果,任意一个像素的灰度值可以表示为:According to the sampling theorem of the square aperture, the pixel value is the result of the combined effect of the light intensity of each part on the photosensitive surface of the pixel, and the gray value of any pixel can be expressed as:
其中,f(i,j)为像素值,g(x,y)为连续图像的光强分布。Among them, f(i,j) is the pixel value, and g(x,y) is the light intensity distribution of the continuous image.
设本实施例中的二次曲线的方程为:Let the equation of the quadratic curve in this embodiment be:
y=ax2+bx+c(2)y=ax 2 +bx+c(2)
由公式(1)可得出每个像素的灰度值为:From formula (1), the gray value of each pixel can be obtained:
首选找到像素级边缘区域的局部最大值,令该点的灰度值为f0,该点相邻的两个差分点的灰度值为f-1和f1,求出局部最大值像素点的灰度值为:The first step is to find the local maximum value of the pixel-level edge area, let the gray value of this point be f 0 , the gray values of the two adjacent difference points of this point are f -1 and f 1 , and find the local maximum pixel point. The grayscale value of :
通过式(4)、(5)和(6)可求出:By formulas (4), (5) and (6), it can be obtained:
将a和b分别代入二次曲线顶点的横坐标
即可得到二次曲线顶点的横坐标也即亚像素精度的边缘轮廓的坐标。Substitute a and b into the abscissa of the vertex of the quadratic curve respectively The abscissa of the vertices of the quadratic curve can be obtained That is, the coordinates of the edge contour with sub-pixel precision.进一步地,当圆弧零件具有多段圆弧时,根据亚像素边缘轮廓,计算获得轮廓拟合圆的步骤,包括:Further, when the arc part has multiple arcs, according to the sub-pixel edge contour, the steps of calculating and obtaining the contour fitting circle include:
S310:分割亚像素边缘轮廓,获得圆弧零件中每段圆弧的亚像素边缘轮廓;S310: segment the sub-pixel edge contour to obtain the sub-pixel edge contour of each arc in the arc part;
S320:将每段圆弧的亚像素边缘轮廓划分成单独的连通域;S320: Divide the sub-pixel edge contour of each arc into separate connected domains;
S330:对每个连通域进行轮廓拟合,得到每段圆弧对应的轮廓拟合圆。S330: Perform contour fitting on each connected domain to obtain a contour fitting circle corresponding to each arc.
圆弧零件的种类繁多,而且通常具有多段圆弧,本实施例中针对具有多段圆弧的圆弧零件提出了计算每段圆弧对应的轮廓拟合圆的算法,使不同种类、形状的圆弧零件都能有效的实现高精度检测。There are many types of arc parts, and they usually have multiple arcs. In this embodiment, an algorithm for calculating the contour fitting circle corresponding to each arc is proposed for arc parts with multiple arcs, so that different types and shapes of circles can be used. Arc parts can effectively achieve high-precision detection.
进一步地,对连通域进行轮廓拟合,得到轮廓拟合圆的步骤,具体包括:Further, the steps of performing contour fitting on the connected domain to obtain the contour fitting circle specifically include:
S330’:通过最小二乘法对每个连通域进行轮廓拟合,得到每段圆弧对应的轮廓拟合圆。S330': Perform contour fitting on each connected domain by the least squares method to obtain a contour fitting circle corresponding to each arc.
本实施例中,采用最小二乘法对圆形边界轮廓进行逼近,可以通过最小化误差的平方和找到一组亚像素轮廓点的最佳函数匹配,可实现亚像素边缘轮廓的精确拟合定位,即便是采样图像中的圆弧受光照强度不均等因素的影响而产生边缘缺失,也不会影响其圆心的定位和半径的检测。In this embodiment, the circular boundary contour is approximated by the least squares method, and the optimal function matching of a group of sub-pixel contour points can be found by minimizing the square sum of the error, so that accurate fitting and positioning of the sub-pixel edge contour can be realized, Even if the circular arc in the sampled image is affected by the uneven illumination intensity and the edge is missing, it will not affect the location of the center of the circle and the detection of the radius.
更进一步地,当圆弧零件的外轮廓呈圆形设置,且圆弧零件的多段圆弧沿周向间隔排布时,对每个连通域进行轮廓拟合,得到每段圆弧对应的轮廓拟合圆的步骤之后,还包括:Further, when the outer contour of the arc part is set in a circle, and the multi-segment arcs of the arc part are arranged at intervals in the circumferential direction, contour fitting is performed on each connected domain, and the contour corresponding to each arc is obtained. After the step of fitting the circle, it also includes:
S331:提取两段对称圆弧的轮廓拟合圆的点集(xk,yk),(k=1,2...n)和(xm,ym),(m=1,2...n),循环遍历两个点集,计算获得每对点的像素距离
其中,两段对称圆弧的圆心位于圆弧零件的直径所在的直线上;S331: Extract the point sets (x k , y k ), (k=1, 2...n) and (x m , y m ), (m=1, 2 of the contour fitting circle of the two symmetrical arcs) ...n), loop through the two point sets, and calculate the pixel distance of each pair of points Among them, the center of the two symmetrical arcs is located on the straight line where the diameter of the arc part is located;S332:对每对点的像素距离进行排序,以获得像素距离的最小值Lmin和对应的点的坐标值;S332: Sort the pixel distance of each pair of points to obtain the minimum value L min of the pixel distance and the coordinate value of the corresponding point;
S333:对其他段对称圆弧的轮廓拟合圆的点集重复上述两个步骤,获得每对对称圆弧之间的距离的最小值Lmin’,以及对应的点的坐标值,以计算得到圆弧零件的内切拟合圆,内切拟合圆的半径
其中,内切拟合圆的半径R为每对对称圆弧之间的距离的最小值之和的平均数。S333: Repeat the above two steps for the point set of the contour fitting circle of other symmetrical arcs to obtain the minimum value L min ' of the distance between each pair of symmetrical arcs, and the coordinate value of the corresponding point, so as to obtain by calculation The inscribed fitting circle of the arc part, the radius of the inscribed fitting circle Among them, the radius R of the inscribed fitting circle is the average of the minimum sum of the distances between each pair of symmetrical circular arcs.请参阅图5,本实施例以球笼联轴器零件为例,针对具有多段圆弧,且段圆弧沿周向间隔排布的圆弧零件提出了计算得到轮廓拟合圆的算法,使形状较为复杂、圆弧较多的零件都能有效的实现高精度检测。Please refer to FIG. 5 . In this embodiment, a ball-cage coupling part is used as an example. For the arc parts with multiple arcs, and the arcs are arranged at intervals in the circumferential direction, an algorithm for calculating the contour fitting circle is proposed, so that the Parts with more complex shapes and more arcs can effectively achieve high-precision detection.
如表1所示,本实施例对球笼联轴器的外圆直径、外圆与内花键同轴度、外沟道直径、外沟道与外圆同轴度、圆弧曲率半径和外沟道六等分公差进行了检测,其中,球笼联轴器的合格尺寸设定为外圆直径Ф101.80~101.90mm、外沟道直径Ф73.70~73.90mm。As shown in Table 1, the outer diameter of the ball cage coupling, the coaxiality between the outer circle and the inner spline, the diameter of the outer channel, the coaxiality between the outer channel and the outer circle, the radius of curvature of the arc and the The six-section tolerance of the outer channel was tested, and the qualified size of the ball cage coupling was set as the outer diameter Ф101.80-101.90mm and the outer channel diameter Ф73.70-73.90mm.
表1Table 1
序号serial number 检查项目Check item 检查尺寸Check the size 合格尺寸Acceptable size 11 Ф102外圆直径Ф102 outer diameter 102102 101.80~101.90101.80~101.90 22 Ф102外圆圆度Ф102 Outer roundness 11 1~0.991~0.99 33 Ф102外圆与内花键同轴度Ф102 Coaxiality between outer circle and inner spline 00 0~0.10~0.1 44 Ф73.8外沟道直径Ф73.8 outer channel diameter 73.873.8 73.70~73.9073.70~73.90 55 Ф73.8外沟道与Ф102外圆同轴度Coaxiality between Ф73.8 outer channel and Ф102 outer circle 00 0~0.10~0.1 66 R15.16曲率半径R15.16 Radius of curvature 15.1615.16 15.10~15.4015.10~15.40 77 外沟道六等分公差Outer Channel Hexagonal Tolerance 60°60° 59.97°~60.03°59.97°~60.03°
经过多次重复检测,当球笼联轴器零件任意摆放时重复测量的标准偏差大于稳定测量,但仍然很小,表明系统稳定,系统测得Ф73.8mm外沟道直径最大值为73.7398mm,最小值为73.7312mm,测量误差为0.0086mm,其他测量项目的重复测量误差均小与0.009mm,故系统测量精度可达0.01mm,满足测量精度要求。After repeated testing for many times, the standard deviation of repeated measurement is larger than the stable measurement when the parts of the ball cage coupling are placed arbitrarily, but it is still small, indicating that the system is stable. The maximum diameter of the outer channel measured by the system is 73.7398mm. , the minimum value is 73.7312mm, the measurement error is 0.0086mm, and the repeated measurement error of other measurement items is less than 0.009mm, so the system measurement accuracy can reach 0.01mm, which meets the measurement accuracy requirements.
基于本发明提出的基于机器视觉的圆弧零件测量方法,本发明提出一种基于机器视觉的圆弧零件测量装置,所述圆弧零件测量装置包括载物台1、视觉采集装置以及终端4,载物台1用以放置圆弧零件5,视觉采集装置安装于载物台1,视觉采集装置包括用以拍摄圆弧零件5的相机3,以拍摄得到圆弧零件5的采样图像,载物台1上设置有用于安装相机3的相机支架2,终端4与视觉采集装置电性连接,终端4包括处理器和存储介质,存储介质存储有基于机器视觉的圆弧零件测量程序,圆弧零件测量程序本发明的基于机器视觉的圆弧零件测量方法的步骤。Based on the method for measuring arc parts based on machine vision proposed by the present invention, the present invention proposes a device for measuring arc parts based on machine vision. The object stage 1 is used to place the arc part 5, and the visual acquisition device is installed on the object stage 1. The visual acquisition device includes a camera 3 for photographing the arc part 5, so as to obtain a sampling image of the arc part 5 by taking pictures. The stage 1 is provided with a camera bracket 2 for installing the camera 3, the terminal 4 is electrically connected with the visual acquisition device, the terminal 4 includes a processor and a storage medium, and the storage medium stores a machine vision-based arc part measurement program, and the arc parts Measurement Procedure The steps of the machine vision-based arc part measurement method of the present invention.
为了提高测量精度,本发明的圆弧零件测量装置以载物台1为基础,采用一体式装配。载物台1上设置有用于放置圆弧零件5的载物玻璃面板,载物台内部设置有背光源11,载物玻璃面板呈水平可调设置,以保证测量圆弧零5件相对于镜头尽可能呈水平放置,同时使圆弧零件5与背景信息得到最佳分离,可以大大降低图像处理算法分割、识别的难度,同时提高定位和测量的精度,使测量装置的可靠性和综合性能得到提高。In order to improve the measurement accuracy, the circular arc part measurement device of the present invention is based on the stage 1 and adopts an integrated assembly. The object stage 1 is provided with an object glass panel for placing the arc parts 5, a backlight 11 is arranged inside the object stage, and the object glass panel is horizontally adjustable to ensure the measurement of the arc parts 5 relative to the lens. It can be placed horizontally as much as possible, and at the same time, the arc parts 5 can be optimally separated from the background information, which can greatly reduce the difficulty of image processing algorithm segmentation and identification, and improve the accuracy of positioning and measurement, so that the reliability and comprehensive performance of the measuring device can be improved. improve.
为了纠正传统镜头的视差,获得更好的成像效果和成像精度,本圆弧零件测量装置的相机3采用双远心镜头,它比普通镜头相比具有更大的光通量,远心度小,无透视误差,分辨率高,光学畸变率小于0.04%,在一定的物距范围内,图像的放大倍率不会随物距的变化而变化。In order to correct the parallax of the traditional lens and obtain better imaging effect and imaging accuracy, the camera 3 of the arc parts measuring device adopts a double telecentric lens, which has a larger luminous flux than ordinary lenses, small telecentricity, no Perspective error, high resolution, optical distortion rate less than 0.04%, within a certain object distance range, the magnification of the image will not change with the change of object distance.
以上所述仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是在本发明的构思下,利用本发明说明书及附图内容所作的等效结构变换,或直接/间接运用在其他相关的技术领域均包括在本发明的专利保护范围内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Under the conception of the present invention, the equivalent structural transformations made by the contents of the description and accompanying drawings of the present invention, or directly/indirectly applied in Other related technical fields are included within the scope of patent protection of the present invention.