[go: up one dir, main page]

CN111189387A - A Machine Vision-Based Dimensional Detection Method for Industrial Parts - Google Patents

A Machine Vision-Based Dimensional Detection Method for Industrial Parts Download PDF

Info

Publication number
CN111189387A
CN111189387A CN202010001694.6A CN202010001694A CN111189387A CN 111189387 A CN111189387 A CN 111189387A CN 202010001694 A CN202010001694 A CN 202010001694A CN 111189387 A CN111189387 A CN 111189387A
Authority
CN
China
Prior art keywords
image
pixel
size
machine vision
detection method
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
Application number
CN202010001694.6A
Other languages
Chinese (zh)
Inventor
张周强
王德祥
胥光申
郭忠超
贾江涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Polytechnic University
Original Assignee
Xian Polytechnic University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Xian Polytechnic University filed Critical Xian Polytechnic University
Priority to CN202010001694.6A priority Critical patent/CN111189387A/en
Publication of CN111189387A publication Critical patent/CN111189387A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01BMEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
    • G01B11/00Measuring arrangements characterised by the use of optical techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20024Filtering details
    • G06T2207/20032Median filtering

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Mathematical Physics (AREA)
  • Mathematical Analysis (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Algebra (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)

Abstract

本发明公开了一种基于机器视觉的工业零件尺寸检测方法,具体按照以下步骤实施:步骤1、利用图像采集系统采集图像;步骤2、对图像依次进行中值滤波、阈值分割、图像填充、Canny边缘粗提取、边缘精提取、尺寸标定,得到尺寸数据;步骤3、将检测到的尺寸数据与标准尺寸数据进行对比,判定检测到的尺寸数据是否在标准尺寸数据的误差范围内;若是,则合格;若否,则不合格。本发明一种基于机器视觉的工业零件尺寸检测方法,解决了传统技术中存在的零件测量效率低、准确度差和目前市场上的检测系统价格昂贵、操作难度高的问题。The invention discloses a size detection method for industrial parts based on machine vision, which is specifically implemented according to the following steps: step 1, using an image acquisition system to collect images; step 2, performing median filtering, threshold segmentation, image filling, Canny Rough edge extraction, fine edge extraction, and size calibration to obtain size data; step 3, compare the detected size data with the standard size data, and determine whether the detected size data is within the error range of the standard size data; if so, then pass; if not, fail. The invention is an industrial part size detection method based on machine vision, which solves the problems of low measurement efficiency and poor accuracy of parts existing in the traditional technology, and the detection systems currently on the market are expensive and difficult to operate.

Description

Industrial part size detection method based on machine vision
Technical Field
The invention belongs to the technical field of machine vision detection, and particularly relates to a machine vision-based industrial part size detection method.
Background
With the continuous development of scientific technology, the traditional machining process of mechanical parts is developed towards high-precision, high-efficiency and high-grade materials, and the machining automation is also one of important development directions, and the technology upgrading of the whole machining industry is accompanied by higher requirements on the inspection and detection of mechanical finished products. In the traditional machining process, workers need to judge whether parts are qualified or not by means of naked eyes and simple tools, and the detection mode depends on the technical experience and the subjective nature of the workers seriously. Even if workers with skilled technology repeatedly perform detection work, fatigue and negligence are easy to generate, detection omission or wrong detection is caused, the improvement of machining precision and production efficiency is greatly restricted, and more advanced detection technology needs to be introduced in the machining industry.
Machine vision is a modern detection technology which utilizes an industrial camera CCD to replace human eyes for detection, and the industrial camera CCD is used for carrying out image processing on a detected object, converting image information into a digital signal and extracting required characteristics from the digital signal, thereby realizing the detection of the state of the detected object. The development of digital processing technology and artificial intelligence makes people have higher and higher requirements on product quality and benefit, and it is also very important to find a method capable of improving product quality and increasing detection speed.
Disclosure of Invention
The invention aims to provide a machine vision-based industrial part size detection method, which solves the problems of low part measurement efficiency, poor accuracy, high price of a detection system in the current market and high operation difficulty in the traditional technology.
The technical scheme adopted by the invention is that the industrial part size detection method based on machine vision is implemented according to the following steps:
step 1, collecting an image by using an image collection system;
step 2, sequentially carrying out median filtering, threshold segmentation, image filling, Canny edge rough extraction, edge fine extraction and size calibration on the image to obtain size data;
step 3, comparing the detected size data with the standard size data, and judging whether the detected size data is within the error range of the standard size data; if yes, the product is qualified; if not, the product is not qualified.
The invention is also characterized in that:
in step 1, the image acquisition system comprises a CCD industrial camera; the CCD industrial camera, the computer, the singlechip and the relay are connected in sequence; the computer is also connected with an infrared sensor.
The infrared sensor is an active infrared sensor;
the type of the singlechip is 89C51 singlechip.
In step 2, the specific process of median filtering is as follows:
and (3) sorting pixels in the plate according to the size of pixel values by adopting a 3X 3 two-dimensional sliding template to generate a monotonously rising two-dimensional data sequence, putting an intermediate value into the central position of the template, restoring the intermediate value into an original image, and scanning the whole image by analogy to obtain an image f (x, y).
In step 2, the specific process of threshold segmentation is as follows:
(1) given an initial threshold Th=Th0The original image can be classified into two types, namely C1 and C2, when the original image is searched from the beginning by default to be 1;
(2) the intra-class variance of two classes is calculated respectively:
Figure BDA0002353736070000031
Figure BDA0002353736070000032
Figure BDA0002353736070000033
Figure BDA0002353736070000034
wherein f (x, y) is the acquired image; n is a radical ofc1Is the probability that the pixel is classified at C1; n is a radical ofc2Is the probability that the pixel is classified at C2; mu is a mean value; sigma2Is the variance;
(3) and (4) carrying out classification treatment: if | f (x, y) - μ1|≤|f(x,y)-μ2If f (x, y) belongs to C1, otherwise f (x, y) belongs to C2;
(4) respectively recalculating the mean value and the variance of all pixels in C1 and C2 obtained after the last step of reclassification;
(5) equation (II) of
Figure BDA0002353736070000035
If true, the calculated threshold value T is outputh(t-1), otherwise repeating (4) and (5).
In step 2, the specific process of image filling is as follows:
(1) selecting a seed point in the image, namely a seed pixel point;
(2) pressing the point into a stack by taking the point as a starting point, setting the color of the point as A if the color to be filled is A, and then judging four neighborhood pixels of the point, wherein a color threshold value T is set, and the gray value of the current pixel is p (x, y), the four neighborhood pixels are M (n), and n is 1,2,3 and 4; judging the gray difference D between the current pixel and the four-adjacent-domain pixel as | P-M |, if D is less than T, using the pixel M as the next seed point and pressing the next seed point into a stack, otherwise, continuing the judgment;
(3) when the stack is empty, the seed padding ends, otherwise (2) is repeated.
In step 2, the specific process of crude extraction of the Canny edge is as follows:
(1) gaussian filter smoothing image to eliminate noise
Scanning each pixel in the image by adopting a 3 x 3 template, and replacing the value of the central pixel point of the template by using the weighted average gray value of the pixels in the field determined by the template:
Figure BDA0002353736070000041
Figure BDA0002353736070000042
wherein f (m, n) is the filled image; w is amnThe gray value of the pixel point of the mth row and the nth column is obtained; m is a filtering template;
(2) calculating the gradient strength and direction of each pixel point in the image
Approximation is performed using first order finite differences, resulting in two matrices of partial derivatives of the image in the x and y directions:
Figure BDA0002353736070000043
Figure BDA0002353736070000044
in the formula, the mathematical expressions of the first-order partial derivative matrix in the x direction and the y direction, the gradient amplitude and the gradient direction are as follows:
P[i,j]=(f[i,j+1]-f[i,j]+f[i+1,j+1]-f[i+1,j])/2 (9)
Q[i,j]=(f[i,j]-f[i+1,j]+f[i,j+1]-f[i+1,j+1])/2 (10)
Figure BDA0002353736070000051
θ[i,j]=arctan(Q[i,j]/P[i,j]) (12)
in the formula, P [ i, j ] is the difference of the image in the horizontal direction; q [ i, j ] is the difference of the image in the vertical direction; m [ i, j ] is gradient strength; theta [ i, j ] is the gradient direction;
(3) applying non-maximum suppression to eliminate spurious response caused by edge detection
Comparing the gradient strength of the current pixel with two pixels along the positive and negative gradient directions; if the gradient intensity of the current pixel is maximum compared with the other two pixels, the pixel point is reserved as an edge point, otherwise, the pixel point is inhibited;
(4) applying dual threshold detection and connection edges
Two thresholds th1 and th2 for non-maximal inhibition, with the relationship th1 being 0.4th 2; firstly, setting the gray value of a pixel with the gradient value smaller than th1 as 0 to obtain an image 1; then, setting the gray value of the pixel with the gradient value less than th2 as 0 to obtain an image 2; finally, the edges of the images are connected on the basis of image 2, supplemented by image 1.
In the step 2, the specific process of edge fine extraction is as follows:
and (3) further extracting by adopting a cubic spline interpolation method:
Figure BDA0002353736070000052
in the formula, S (w) is an interpolation kernel; w is a spline node;
the calculation formula of spline interpolation is represented by a matrix:
F(m,n)=ABC (14)
in the formula (I), the compound is shown in the specification,
Figure BDA0002353736070000061
Figure BDA0002353736070000062
f (m, n) represents the interpolated image; f (i, j) represents a pixel point before interpolation; v ═ n- [ n ], [ ] denotes rounding.
In step 2, the specific process of size calibration is as follows:
obtaining the corresponding relation between the real value and the pixel value of the gauge block through the image after the edge fine extraction to obtain a calibration coefficient K1, and then calibrating the measured part to further realize the size measurement;
the actual length of the gauge block is M (in mm), the pixel size of the gauge block in the image acquired by the camera is N (in number of pixels), and the ratio of the actual size M to the pixel size N is the calibration coefficient K1 of the gauge block, and is expressed by the formula:
Figure BDA0002353736070000063
assuming that the actual side length dimension of the part is L (in mm), and the pixel size of the side length of the part in the image collected by the camera is P (in number of pixels), the calibration coefficient K2 is expressed by the following formula:
Figure BDA0002353736070000064
when the parameters of the camera lens during image acquisition, namely the visual distance, the focal length and the magnification, and the external conditions, namely the relative positions of the illumination, the camera and the target are unchanged, the calibration coefficient K1 of the gauge block is equal to the calibration coefficient K2 of the side length of the part; then it can be derived from the above two equations:
Figure BDA0002353736070000071
the invention has the beneficial effects that:
the industrial part size detection method based on machine vision adopts an edge extraction method combining a Canny algorithm and a cubic spline interpolation method, and obtains a more accurate edge position; the method solves the problems of low size measurement precision and high fault tolerance rate in industrial production, has wide application in size measurement, provides a new idea for size measurement, and provides a new idea for part detection.
Detailed Description
The present invention will be described in detail with reference to the following embodiments.
The invention relates to a machine vision-based industrial part size detection method, which is implemented according to the following steps:
step 1, collecting an image by using an image collection system; wherein, the image acquisition system comprises a CCD industrial camera; the CCD industrial camera, the computer, the singlechip and the relay are connected in sequence; the computer is also connected with an infrared sensor;
the infrared sensor is an active infrared sensor;
the type of the singlechip is 89C51 singlechip.
Step 2, sequentially carrying out median filtering, threshold segmentation, image filling, Canny edge rough extraction, edge fine extraction and size calibration on the image to obtain size data;
the specific process of median filtering is as follows:
and (3) sorting pixels in the plate according to the size of pixel values by adopting a 3X 3 two-dimensional sliding template to generate a monotonously rising two-dimensional data sequence, putting an intermediate value into the central position of the template, restoring the intermediate value into an original image, and scanning the whole image by analogy to obtain an image f (x, y).
The specific process of threshold segmentation is as follows:
(1) given an initial threshold Th=Th0The original image can be classified into two types, namely C1 and C2, when the original image is searched from the beginning by default to be 1;
(2) the intra-class variance of two classes is calculated respectively:
Figure BDA0002353736070000081
Figure BDA0002353736070000082
Figure BDA0002353736070000083
Figure BDA0002353736070000084
wherein f (x, y) is the acquired image; n is a radical ofc1Is the probability that the pixel is classified at C1; n is a radical ofc2For pixels classified at C2Rate; mu is a mean value; sigma2Is the variance;
(3) and (4) carrying out classification treatment: if | f (x, y) - μ1|≤|f(x,y)-μ2If f (x, y) belongs to C1, otherwise f (x, y) belongs to C2;
(4) respectively recalculating the mean value and the variance of all pixels in C1 and C2 obtained after the last step of reclassification;
(5) equation (II) of
Figure BDA0002353736070000085
If true, the calculated threshold value T is outputh(t-1), otherwise repeating (4) and (5).
The specific process of image filling is as follows:
(1) selecting a seed point in the image, namely a seed pixel point;
(2) pressing the point into a stack by taking the point as a starting point, setting the color of the point as A if the color to be filled is A, and then judging four neighborhood pixels of the point, wherein a color threshold value T is set, and the gray value of the current pixel is p (x, y), the four neighborhood pixels are M (n), and n is 1,2,3 and 4; judging the gray difference D between the current pixel and the four-adjacent-domain pixel as | P-M |, if D is less than T, using the pixel M as the next seed point and pressing the next seed point into a stack, otherwise, continuing the judgment;
(3) when the stack is empty, the seed padding ends, otherwise (2) is repeated.
The Canny edge crude extraction process is as follows:
(1) gaussian filter smoothing image to eliminate noise
Scanning each pixel in the image by adopting a 3 x 3 template, and replacing the value of the central pixel point of the template by using the weighted average gray value of the pixels in the field determined by the template:
Figure BDA0002353736070000091
Figure BDA0002353736070000092
wherein f (m, n) is the filled image; w is amnThe gray value of the pixel point of the mth row and the nth column is obtained; m is a filtering template;
(2) calculating the gradient strength and direction of each pixel point in the image
Approximation is performed using first order finite differences, resulting in two matrices of partial derivatives of the image in the x and y directions:
Figure BDA0002353736070000101
in the formula, the mathematical expressions of the first-order partial derivative matrix in the x direction and the y direction, the gradient amplitude and the gradient direction are as follows:
P[i,j]=(f[i,j+1]-f[i,j]+f[i+1,j+1]-f[i+1,j])/2 (9)
Q[i,j]=(f[i,j]-f[i+1,j]+f[i,j+1]-f[i+1,j+1])/2 (10)
Figure BDA0002353736070000103
θ[i,j]=arctan(Q[i,j]/P[i,j]) (12)
in the formula, P [ i, j ] is the difference of the image in the horizontal direction; q [ i, j ] is the difference of the image in the vertical direction; m [ i, j ] is gradient strength; theta [ i, j ] is the gradient direction;
(3) applying non-maximum suppression to eliminate spurious response caused by edge detection
Comparing the gradient strength of the current pixel with two pixels along the positive and negative gradient directions; if the gradient intensity of the current pixel is maximum compared with the other two pixels, the pixel point is reserved as an edge point, otherwise, the pixel point is inhibited;
(4) applying dual threshold detection and connection edges
Two thresholds th1 and th2 for non-maximal inhibition, with the relationship th1 being 0.4th 2; firstly, setting the gray value of a pixel with the gradient value smaller than th1 as 0 to obtain an image 1; then, setting the gray value of the pixel with the gradient value less than th2 as 0 to obtain an image 2; finally, the edges of the images are connected on the basis of image 2, supplemented by image 1.
The specific process of edge fine extraction is as follows:
and (3) further extracting by adopting a cubic spline interpolation method:
Figure BDA0002353736070000111
in the formula, S (w) is an interpolation kernel; w is a spline node;
the calculation formula of spline interpolation is represented by a matrix:
F(m,n)=ABC (14)
in the formula (I), the compound is shown in the specification,
Figure BDA0002353736070000112
Figure BDA0002353736070000113
f (m, n) represents the interpolated image; f (i, j) represents a pixel point before interpolation; v ═ n- [ n ], [ ] denotes rounding.
The specific process of dimension calibration is as follows:
obtaining the corresponding relation between the real value and the pixel value of the gauge block through the image after the edge fine extraction to obtain a calibration coefficient K1, and then calibrating the measured part to further realize the size measurement;
the actual length of the gauge block is M (in mm), the pixel size of the gauge block in the image acquired by the camera is N (in number of pixels), and the ratio of the actual size M to the pixel size N is the calibration coefficient K1 of the gauge block, and is expressed by the formula:
Figure BDA0002353736070000121
assuming that the actual side length dimension of the part is L (in mm), and the pixel size of the side length of the part in the image collected by the camera is P (in number of pixels), the calibration coefficient K2 is expressed by the following formula:
Figure BDA0002353736070000122
when the parameters of the camera lens during image acquisition, namely the visual distance, the focal length and the magnification, and the external conditions, namely the relative positions of the illumination, the camera and the target are unchanged, the calibration coefficient K1 of the gauge block is equal to the calibration coefficient K2 of the side length of the part; then it can be derived from the above two equations:
Figure BDA0002353736070000123
step 3, comparing the detected size data with the standard size data, and judging whether the detected size data is within the error range of the standard size data; if yes, the product is qualified; if not, the product is not qualified.
The device in the image acquisition system has the following functions:
CCD industry camera: collecting images, and converting optical signals into ordered telecommunication signals;
a computer: receiving signals of an industrial camera, and carrying out image processing to obtain required characteristics of the part; receiving signals of the infrared sensor, and making a camera photographing instruction according to the signals;
a single chip microcomputer: receiving a separation instruction of a computer and controlling the rotation and stop of the motor;
a relay: an automatic switch which uses small current to control large current operation, an actuating mechanism which can realize on and off control to a controlled circuit;
an infrared sensor: the infrared sensor is a pair of infrared signal transmitting and receiving diodes, the transmitting tube transmits an infrared signal with a specific frequency, the receiving tube receives the infrared signal with the frequency, when the infrared detection direction meets an obstacle, the infrared signal cannot be received by the receiving tube, and the receiver signal changes and returns to the computer through a self-carried digital sensor interface.
The industrial part size detection method based on machine vision adopts an edge extraction method combining a Canny algorithm and a cubic spline interpolation method, and obtains a more accurate edge position; the method solves the problems of low size measurement precision and high fault tolerance rate in industrial production, has wide application in size measurement, provides a new idea for size measurement, and provides a new idea for part detection.

Claims (9)

1.一种基于机器视觉的工业零件尺寸检测方法,其特征在于,具体按照以下步骤实施:1. a kind of industrial part size detection method based on machine vision, is characterized in that, is specifically implemented according to the following steps: 步骤1、利用图像采集系统采集图像;Step 1. Use an image acquisition system to collect images; 步骤2、对图像依次进行中值滤波、阈值分割、图像填充、Canny边缘粗提取、边缘精提取、尺寸标定,得到尺寸数据;Step 2. Perform median filtering, threshold segmentation, image filling, Canny edge rough extraction, edge fine extraction, and size calibration on the image in turn to obtain size data; 步骤3、将检测到的尺寸数据与标准尺寸数据进行对比,判定检测到的尺寸数据是否在标准尺寸数据的误差范围内;若是,则合格;若否,则不合格。Step 3: Compare the detected size data with the standard size data, and determine whether the detected size data is within the error range of the standard size data; if so, it is qualified; if not, it is unqualified. 2.如权利要求1所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述步骤1中,图像采集系统包括CCD工业相机;CCD工业相机、计算机、单片机、继电器依次连接;计算机还连接有红外传感器。2. The industrial part size detection method based on machine vision as claimed in claim 1, wherein in the step 1, the image acquisition system comprises a CCD industrial camera; the CCD industrial camera, a computer, a single-chip microcomputer, and a relay are connected in sequence; the computer An infrared sensor is also connected. 3.如权利要求2所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述红外传感器为主动式红外传感器;3. The industrial part size detection method based on machine vision as claimed in claim 2, wherein the infrared sensor is an active infrared sensor; 所述单片机的型号是89C51单片机。The model of the single-chip microcomputer is 89C51 single-chip microcomputer. 4.如权利要求1所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述步骤2中,中值滤波的具体过程如下:4. the industrial part size detection method based on machine vision as claimed in claim 1, is characterized in that, in described step 2, the concrete process of median filtering is as follows: 采用3×3的二维滑动模板,将板内像素按照像素值的大小进行排序,生成单调上升的为二维数据序列,取中间值放入模板的中心位置,再还原到原图中,以此类推扫描整个图像,获得图像f(x,y)。Using a 3×3 two-dimensional sliding template, the pixels in the plate are sorted according to the size of the pixel value, and the monotonically rising two-dimensional data sequence is generated. And so on to scan the whole image to get the image f(x, y). 5.如权利要求1所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述步骤2中,阈值分割的具体过程如下:5. The industrial part size detection method based on machine vision as claimed in claim 1, wherein in the step 2, the specific process of threshold segmentation is as follows: (1)给定一个初始阈值Th=Th0,可以默认为1,从头开始搜索,则将原图分为C1和C2两类;(1) Given an initial threshold Th =T h0 , it can be set to 1 by default, and the search starts from the beginning, and the original image is divided into two categories: C1 and C2; (2)分别计算两类的类内方差:(2) Calculate the intra-class variance of the two classes separately:
Figure FDA0002353736060000021
Figure FDA0002353736060000021
Figure FDA0002353736060000022
Figure FDA0002353736060000022
Figure FDA0002353736060000023
Figure FDA0002353736060000023
Figure FDA0002353736060000024
Figure FDA0002353736060000024
式中,f(x,y)为采集的图像;Nc1为像素被分在C1的概率;Nc2为像素被分在C2的概率;μ为均值;σ2为方差;In the formula, f(x,y) is the collected image; N c1 is the probability that the pixel is classified in C1; N c2 is the probability that the pixel is classified in C2; μ is the mean value; σ 2 is the variance; (3)进行分类处理:如果|f(x,y)-μ1|≤|f(x,y)-μ2|,则f(x,y)属于C1,否则f(x,y)属于C2;(3) Perform classification processing: if |f(x,y)-μ 1 |≤|f(x,y)-μ 2 |, then f(x, y) belongs to C1, otherwise f(x, y) belongs to C2; (4)对上一步重新分类后得到的C1和C2中的所有像素,分别重新计算其各自的均值与方差;(4) For all the pixels in C1 and C2 obtained after reclassification in the previous step, recalculate their respective mean and variance respectively; (5)如果式子
Figure FDA0002353736060000025
成立,则输出计算得到的阈值Th(t-1),否则重复(4)、(5)。
(5) If the formula
Figure FDA0002353736060000025
If established, output the calculated threshold Th (t-1), otherwise repeat (4) and (5).
6.如权利要求1所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述步骤2中,图像填充的具体过程如下:6. The industrial part size detection method based on machine vision as claimed in claim 1, is characterized in that, in described step 2, the concrete process of image filling is as follows: (1)在图像中选择一个种子点,即种子像素点;(1) Select a seed point in the image, that is, the seed pixel point; (2)以这个点为起点,将它压入栈中,假设我们要填充的颜色为A,则将该点颜色设置为A,然后判断它的四邻域像素,这里我们设置一个颜色阈值T,假设当前像素灰度值为p(x,y),四邻域像素为M(n),n=1,2,3,4;那么判断当前像素与四邻域像素的灰度差值D=|P-M|,如果D小于T,那么将该像素M作为下一个种子点,压入栈中,否则继续判断;(2) Take this point as the starting point and push it into the stack. Suppose the color we want to fill is A, then set the color of the point to A, and then judge its four neighborhood pixels. Here we set a color threshold T, Assuming that the gray value of the current pixel is p(x, y), and the four neighboring pixels are M(n), n=1, 2, 3, 4; then determine the grayscale difference between the current pixel and the four neighboring pixels D=|P-M |, if D is less than T, then use the pixel M as the next seed point and push it into the stack, otherwise continue to judge; (3)当栈为空时,种子填充结束,否则重复(2)。(3) When the stack is empty, the seed filling ends, otherwise (2) is repeated. 7.如权利要求1所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述步骤2中,Canny边缘粗提取具体过程如下:7. the industrial part size detection method based on machine vision as claimed in claim 1, is characterized in that, in described step 2, the concrete process of Canny edge rough extraction is as follows: (1)高斯滤波器平滑图像以消除噪声(1) Gaussian filter to smooth the image to remove noise 采用3×3的模板扫描图像中的每一个像素,用模板确定的领域内像素的加权平均灰度值去替代模板中心像素点的值:Use a 3×3 template to scan each pixel in the image, and use the weighted average gray value of the pixels in the area determined by the template to replace the value of the center pixel of the template:
Figure FDA0002353736060000031
Figure FDA0002353736060000031
Figure FDA0002353736060000032
Figure FDA0002353736060000032
式中,f(m,n)为填充后的图像;wmn为第m行n列像素点的灰度值;M为滤波模板;In the formula, f(m,n) is the image after filling; wmn is the gray value of the pixel point in the mth row and nth column; M is the filter template; (2)计算图像中每个像素点的梯度强度和方向(2) Calculate the gradient intensity and direction of each pixel in the image 采用一阶有限差分来进行近似,得到图像在x和y方向上偏导数的两个矩阵:The first-order finite difference is used for approximation, and two matrices of partial derivatives of the image in the x and y directions are obtained:
Figure FDA0002353736060000033
Figure FDA0002353736060000033
Figure FDA0002353736060000041
Figure FDA0002353736060000041
式中,x向、y向的一阶偏导数矩阵,梯度幅值以及梯度方向的数学表达式为:In the formula, the first-order partial derivative matrix of x-direction and y-direction, the mathematical expression of gradient magnitude and gradient direction are: P[i,j]=(f[i,j+1]-f[i,j]+f[i+1,j+1]-f[i+1,j])/2 (9)P[i,j]=(f[i,j+1]-f[i,j]+f[i+1,j+1]-f[i+1,j])/2 (9) Q[i,j]=(f[i,j]-f[i+1,j]+f[i,j+1]-f[i+1,j+1])/2 (10)Q[i,j]=(f[i,j]-f[i+1,j]+f[i,j+1]-f[i+1,j+1])/2 (10)
Figure FDA0002353736060000042
Figure FDA0002353736060000042
θ[i,j]=arctan(Q[i,j]/P[i,j]) (12)θ[i,j]=arctan(Q[i,j]/P[i,j]) (12) 式中,P[i,j]为图像在水平方向的差分;Q[i,j]为图像在垂直方向的差分;M[i,j]为梯度强度;θ[i,j]为梯度方向;In the formula, P[i,j] is the difference of the image in the horizontal direction; Q[i,j] is the difference of the image in the vertical direction; M[i,j] is the gradient strength; θ[i,j] is the gradient direction ; (3)应用非极大值抑制,消除边缘检测带来的杂散相应(3) Apply non-maximum suppression to eliminate spurious responses caused by edge detection 将当前像素的梯度强度与沿正负梯度方向上的两个像素进行比较;如果当前像素的梯度强度与另外两个像素相比最大,则该像素点保留为边缘点,否则该像素点将被抑制;Compare the gradient strength of the current pixel with the two pixels along the positive and negative gradient directions; if the gradient strength of the current pixel is the largest compared with the other two pixels, the pixel is reserved as an edge point, otherwise the pixel will be inhibition; (4)应用双阈值检测和连接边缘(4) Apply dual thresholds to detect and connect edges 对非极大值抑制作用两个阈值th1和th2,两者关系th1=0.4th2;首先把梯度值小于th1的像素的灰度值设为0,得到图像1;然后把梯度值小于th2的像素的灰度值设为0,得到图像2;最后以图像2为基础,以图像1为补充来连接图像的边缘。There are two thresholds th1 and th2 for non-maximum suppression, and the relationship between the two is th1=0.4th2; first, set the gray value of the pixel whose gradient value is less than th1 to 0 to obtain image 1; then set the pixel whose gradient value is less than th2. The gray value of 0 is set to 0, and image 2 is obtained; finally, image 2 is used as the basis, and image 1 is supplemented to connect the edges of the image.
8.如权利要求1所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述步骤2中,边缘精提取的具体过程如下:8. The industrial part size detection method based on machine vision as claimed in claim 1, is characterized in that, in described step 2, the concrete process of edge fine extraction is as follows: 采用三次样条插值法边缘进行进一步提取:Edges are further extracted using cubic spline interpolation:
Figure FDA0002353736060000051
Figure FDA0002353736060000051
式中,S(w)为插值核;w为样条节点;In the formula, S(w) is the interpolation kernel; w is the spline node; 用矩阵表示样条插值的计算公式:Use a matrix to represent the calculation formula of spline interpolation: F(m,n)=ABC (14)F(m,n)=ABC (14) 式中,
Figure FDA0002353736060000052
In the formula,
Figure FDA0002353736060000052
Figure FDA0002353736060000053
Figure FDA0002353736060000053
F(m,n)表示插值后的图像;f(i,j)表示插值前像素点;v=n-[n],[]表示取整。F(m,n) represents the image after interpolation; f(i,j) represents the pixel point before interpolation; v=n-[n], [] represents rounding.
9.如权利要求1所述的基于机器视觉的工业零件尺寸检测方法,其特征在于,所述步骤2中,尺寸标定的具体过程如下:9. The industrial part size detection method based on machine vision as claimed in claim 1, wherein in the step 2, the specific process of size calibration is as follows: 通过边缘精提取后的图像,获取量块的真实值和像素值之间的对应关系,得到标定系数K1,然后对被测零件进行标定,进而实现尺寸测量;The corresponding relationship between the real value and the pixel value of the gauge block is obtained through the image after the edge extraction, and the calibration coefficient K1 is obtained, and then the measured part is calibrated to realize the size measurement; 量块的实际长度为M(以毫米mm为单位),运用相机采集的图像中量块像素尺寸为N(以像素个数为单位),则实际尺寸M与像素尺寸N的比值就是量块的标定系数K1,用公式表示为:The actual length of the gauge block is M (in millimeters), and the pixel size of the gauge block in the image captured by the camera is N (in the number of pixels), then the ratio of the actual size M to the pixel size N is the size of the gauge block. The calibration coefficient K1 is expressed by the formula as:
Figure FDA0002353736060000061
Figure FDA0002353736060000061
设零件的边长实际尺寸值为L(以毫米mm为单位),运用相机采集的图像中的零件边长像素尺寸为P(以像素个数为单位),则其标定系数K2用公式表示为:Suppose the actual size of the side length of the part is L (in millimeters), and the pixel size of the side length of the part in the image collected by the camera is P (in the number of pixels), then its calibration coefficient K2 is expressed by the formula as :
Figure FDA0002353736060000062
Figure FDA0002353736060000062
当图像采集时相机镜头的参数,即视距、焦距、放大倍率,以及外界条件,即照明、相机与目标的相对位置,不变时,量块的标定系数K1等于零件边长的标定系数K2;则由以上两公式可以得出:When the parameters of the camera lens during image acquisition, that is, the viewing distance, focal length, magnification, and external conditions, that is, the relative position of the illumination, the camera and the target, remain unchanged, the calibration coefficient K1 of the gauge block is equal to the calibration coefficient K2 of the side length of the part ; then it can be obtained from the above two formulas:
Figure FDA0002353736060000063
Figure FDA0002353736060000063
CN202010001694.6A 2020-01-02 2020-01-02 A Machine Vision-Based Dimensional Detection Method for Industrial Parts Pending CN111189387A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010001694.6A CN111189387A (en) 2020-01-02 2020-01-02 A Machine Vision-Based Dimensional Detection Method for Industrial Parts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010001694.6A CN111189387A (en) 2020-01-02 2020-01-02 A Machine Vision-Based Dimensional Detection Method for Industrial Parts

Publications (1)

Publication Number Publication Date
CN111189387A true CN111189387A (en) 2020-05-22

Family

ID=70706403

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010001694.6A Pending CN111189387A (en) 2020-01-02 2020-01-02 A Machine Vision-Based Dimensional Detection Method for Industrial Parts

Country Status (1)

Country Link
CN (1) CN111189387A (en)

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111578838A (en) * 2020-05-25 2020-08-25 安徽工业大学 Gear size visual measurement device and measurement method
CN111871848A (en) * 2020-06-23 2020-11-03 安徽信息工程学院 Machine vision part sorting method and system based on serial port communication control
CN112304954A (en) * 2020-10-20 2021-02-02 西安工程大学 A method for detecting surface defects of parts based on line laser scanning and machine vision
CN113011719A (en) * 2021-03-03 2021-06-22 苏州盛弘森科技有限公司 Visual quality detection method and system for industrial production
CN113066097A (en) * 2021-05-24 2021-07-02 广东技术师范大学 Method and system for rapidly and accurately measuring width, period and metallization ratio of interdigital transducer finger
CN113256551A (en) * 2021-01-21 2021-08-13 中国煤炭科工集团太原研究院有限公司 Roadway roof rigid belt drilling identification and positioning system and method based on machine vision
CN113409256A (en) * 2021-06-08 2021-09-17 沈阳化工大学 Axial size detection method for pipeline corrugated compensator
CN113701632A (en) * 2021-09-01 2021-11-26 威海北洋电气集团股份有限公司 Thread detection method based on difference value
CN114199127A (en) * 2021-12-07 2022-03-18 长春汽车工业高等专科学校 Automobile part size detection system and method based on machine vision
CN114674223A (en) * 2020-10-15 2022-06-28 浙江大学台州研究院 Dimension measurement scoring system based on machine vision detection method
CN115112183A (en) * 2022-08-30 2022-09-27 南通科强智能设备有限公司 System for detecting size of special-shaped mechanical part
CN115147350A (en) * 2022-05-17 2022-10-04 南京理工大学 A method for dimension detection of clamp parts based on machine vision
CN115240146A (en) * 2022-09-23 2022-10-25 南通韦俐数控机床有限公司 Intelligent machine tool assembly acceptance method based on computer vision
CN115731165A (en) * 2022-09-28 2023-03-03 广州市易鸿智能装备有限公司 Detection system and method for lithium battery online size point inspection
CN115984177A (en) * 2022-12-01 2023-04-18 五邑大学 Machine vision detection device, control method thereof, control device, and storage medium
CN116447972A (en) * 2023-03-28 2023-07-18 一汽丰田汽车有限公司 Method, device and storage medium for detecting dimension parameters of vehicle parts
CN119151917A (en) * 2024-11-14 2024-12-17 清华大学 Part layer height dimension detection method and device for laser wire feeding additive manufacturing

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101782526A (en) * 2010-01-19 2010-07-21 江苏大学 Method and device for automatically restoring, measuring and classifying steel dimple images
CN103983190A (en) * 2014-05-22 2014-08-13 华中农业大学 Visual inspection classification device and method for appearance dimensions of group origin duck eggs
CN105865344A (en) * 2016-06-13 2016-08-17 长春工业大学 Workpiece dimension measuring method and device based on machine vision
CN106289070A (en) * 2016-08-03 2017-01-04 上海创和亿电子科技发展有限公司 The method measuring irregularly shaped object length and width
CN109225915A (en) * 2018-11-02 2019-01-18 西南交通大学 A kind of rivet quality classification and Automated Sorting System and method
CN110044910A (en) * 2019-05-09 2019-07-23 河南大学 A kind of automobile sets glass box components detection system and a detection method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101782526A (en) * 2010-01-19 2010-07-21 江苏大学 Method and device for automatically restoring, measuring and classifying steel dimple images
CN103983190A (en) * 2014-05-22 2014-08-13 华中农业大学 Visual inspection classification device and method for appearance dimensions of group origin duck eggs
CN105865344A (en) * 2016-06-13 2016-08-17 长春工业大学 Workpiece dimension measuring method and device based on machine vision
CN106289070A (en) * 2016-08-03 2017-01-04 上海创和亿电子科技发展有限公司 The method measuring irregularly shaped object length and width
CN109225915A (en) * 2018-11-02 2019-01-18 西南交通大学 A kind of rivet quality classification and Automated Sorting System and method
CN110044910A (en) * 2019-05-09 2019-07-23 河南大学 A kind of automobile sets glass box components detection system and a detection method

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
丁爱玲: "《计算机图形学》", 31 July 2005, 西安电子科技大学出版社 *
张美静 等: "《改进形态学梯度的样条插值亚像素边缘检测方法》", 《沈阳理工大学学报》 *
曹晨洁 等: "《基于CANNY算法的道路交通标线识别方法》", 《信息技术与网络安全》 *
李莲 等: "《破损胶囊图像处理算法的比较研究》", 《仪器仪表学报》 *

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111578838A (en) * 2020-05-25 2020-08-25 安徽工业大学 Gear size visual measurement device and measurement method
CN111871848A (en) * 2020-06-23 2020-11-03 安徽信息工程学院 Machine vision part sorting method and system based on serial port communication control
CN114674223B (en) * 2020-10-15 2023-06-23 浙江大学台州研究院 A Dimension Measurement Scoring System Based on Machine Vision Inspection Method
CN114674223A (en) * 2020-10-15 2022-06-28 浙江大学台州研究院 Dimension measurement scoring system based on machine vision detection method
CN112304954A (en) * 2020-10-20 2021-02-02 西安工程大学 A method for detecting surface defects of parts based on line laser scanning and machine vision
CN113256551A (en) * 2021-01-21 2021-08-13 中国煤炭科工集团太原研究院有限公司 Roadway roof rigid belt drilling identification and positioning system and method based on machine vision
CN113256551B (en) * 2021-01-21 2023-03-14 中国煤炭科工集团太原研究院有限公司 Roadway roof rigid belt drilling identification and positioning system and method based on machine vision
CN113011719A (en) * 2021-03-03 2021-06-22 苏州盛弘森科技有限公司 Visual quality detection method and system for industrial production
CN113066097A (en) * 2021-05-24 2021-07-02 广东技术师范大学 Method and system for rapidly and accurately measuring width, period and metallization ratio of interdigital transducer finger
CN113409256A (en) * 2021-06-08 2021-09-17 沈阳化工大学 Axial size detection method for pipeline corrugated compensator
CN113409256B (en) * 2021-06-08 2023-09-15 沈阳化工大学 Method for detecting axial dimension of pipeline corrugated compensator
CN113701632B (en) * 2021-09-01 2024-02-13 威海北洋电气集团股份有限公司 Thread detection method based on difference value
CN113701632A (en) * 2021-09-01 2021-11-26 威海北洋电气集团股份有限公司 Thread detection method based on difference value
CN114199127B (en) * 2021-12-07 2024-02-02 长春汽车工业高等专科学校 Automobile part size detection system and method based on machine vision
CN114199127A (en) * 2021-12-07 2022-03-18 长春汽车工业高等专科学校 Automobile part size detection system and method based on machine vision
CN115147350A (en) * 2022-05-17 2022-10-04 南京理工大学 A method for dimension detection of clamp parts based on machine vision
CN115112183A (en) * 2022-08-30 2022-09-27 南通科强智能设备有限公司 System for detecting size of special-shaped mechanical part
CN115240146A (en) * 2022-09-23 2022-10-25 南通韦俐数控机床有限公司 Intelligent machine tool assembly acceptance method based on computer vision
CN115731165B (en) * 2022-09-28 2023-10-20 广州市易鸿智能装备有限公司 Detection system and method for on-line size spot inspection of lithium battery
CN115731165A (en) * 2022-09-28 2023-03-03 广州市易鸿智能装备有限公司 Detection system and method for lithium battery online size point inspection
CN115984177A (en) * 2022-12-01 2023-04-18 五邑大学 Machine vision detection device, control method thereof, control device, and storage medium
CN116447972A (en) * 2023-03-28 2023-07-18 一汽丰田汽车有限公司 Method, device and storage medium for detecting dimension parameters of vehicle parts
CN119151917A (en) * 2024-11-14 2024-12-17 清华大学 Part layer height dimension detection method and device for laser wire feeding additive manufacturing

Similar Documents

Publication Publication Date Title
CN111189387A (en) A Machine Vision-Based Dimensional Detection Method for Industrial Parts
CN111080582B (en) Method for detecting defects of inner and outer surfaces of workpiece
CN105225482B (en) Vehicle detecting system and method based on binocular stereo vision
CN107804514B (en) Toothbrush sorting method based on image recognition
CN105547834B (en) The measuring method of quick stress-strain diagram measuring system based on binocular vision
WO2017128865A1 (en) Multiple lens-based smart mechanical arm and positioning and assembly method
CN107392929B (en) An intelligent target detection and size measurement method based on human visual model
CN110308151A (en) A method and device for identifying surface defects of metal workpieces based on machine vision
CN109974582A (en) A non-contact visual detection device and method for core wire size of automobile wiring harness
CN109978940B (en) Visual measurement method for SAB safety airbag size
CN109584239B (en) High-light object surface defect detection system and method based on reflected light
CN103454285A (en) Transmission chain quality detection system based on machine vision
CN107941808A (en) 3D printing Forming Quality detecting system and method based on machine vision
CN101804720A (en) Vision-based online digital electronic engraving quality monitoring method and device
CN117132655B (en) Filling barrel opening position measuring method based on machine vision
CN110991360B (en) Robot inspection point position intelligent configuration method based on visual algorithm
CN110096980A (en) Character machining identifying system
CN107016353A (en) A kind of method and system of variable resolution target detection and identification integration
CN115375636A (en) A full-scale detection method and device for a power battery module
CN114155226A (en) Micro defect edge calculation method
CN110807763A (en) Method and system for detecting ceramic tile surface bulge
CN112338898B (en) Image processing method and device of object sorting system and object sorting system
CN115184362A (en) Rapid defect detection method based on structured light projection
CN115147350A (en) A method for dimension detection of clamp parts based on machine vision
CN117522778A (en) Hollow brick flaw detection system

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200522

RJ01 Rejection of invention patent application after publication