CN114791265A - Workpiece dimension measuring method and system based on machine vision - Google Patents
Workpiece dimension measuring method and system based on machine vision Download PDFInfo
- Publication number
- CN114791265A CN114791265A CN202210444500.9A CN202210444500A CN114791265A CN 114791265 A CN114791265 A CN 114791265A CN 202210444500 A CN202210444500 A CN 202210444500A CN 114791265 A CN114791265 A CN 114791265A
- Authority
- CN
- China
- Prior art keywords
- workpiece
- image
- voting
- width
- length
- 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
- 238000000034 method Methods 0.000 title claims description 13
- 238000012887 quadratic function Methods 0.000 claims abstract description 14
- 238000007781 pre-processing Methods 0.000 claims abstract description 13
- 238000005259 measurement Methods 0.000 claims abstract description 11
- 238000001514 detection method Methods 0.000 claims description 19
- 238000012545 processing Methods 0.000 claims description 4
- 238000004364 calculation method Methods 0.000 claims description 3
- 238000000691 measurement method Methods 0.000 abstract description 9
- 238000005516 engineering process Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000002708 enhancing effect Effects 0.000 description 1
- 230000007613 environmental effect Effects 0.000 description 1
- 238000005286 illumination Methods 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G01—MEASURING; TESTING
- G01B—MEASURING LENGTH, THICKNESS OR SIMILAR LINEAR DIMENSIONS; MEASURING ANGLES; MEASURING AREAS; MEASURING IRREGULARITIES OF SURFACES OR CONTOURS
- G01B11/00—Measuring arrangements characterised by the use of optical techniques
- G01B11/02—Measuring arrangements characterised by the use of optical techniques for measuring length, width or thickness
-
- 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/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
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
- G06T2207/30164—Workpiece; Machine component
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Theoretical Computer Science (AREA)
- Geometry (AREA)
- Quality & Reliability (AREA)
- Length Measuring Devices By Optical Means (AREA)
Abstract
The invention relates to the technical field of workpiece dimension measurement, in particular to a workpiece dimension measurement method and a workpiece dimension measurement system based on machine vision, which comprises the following steps: acquiring images, namely shooting a workpiece by using an industrial camera and acquiring an image of the workpiece; image preprocessing, namely converting an acquired image into a binary image; and detecting the size of a workpiece, selecting black point pixels in the binary image, voting towards a Hough space, selecting a group of voting angles near the maximum voting value, and calculating the corresponding voting variance. Fitting the voting variance into a quadratic function, and detecting the length and the width of the workpiece in the image space based on the fitted quadratic function coefficient; and calculating the size of the workpiece, namely calculating the physical size of the workpiece by combining the calibration parameters of the camera and the detected length and width of the workpiece. The invention detects the length and the width of the workpiece and calculates the physical size of the workpiece based on the regional pixels of the workpiece instead of the edge profile of the workpiece, and has high measurement precision and strong applicability.
Description
Technical Field
The invention relates to the technical field of workpiece dimension measurement, in particular to a workpiece dimension measurement method and a workpiece dimension measurement system based on machine vision.
Background
After the workpiece is completely generated, the size of the workpiece needs to be measured to ensure that the size of the produced workpiece reaches the standard. In a conventional measurement method, a workpiece is manually measured by using a measuring tool such as a vernier caliper. However, this contact-type manual measurement method has low measurement accuracy and low measurement efficiency.
With the development of machine vision technology, non-contact measurement methods have emerged. The workpiece size is measured by shooting visual images of the workpiece and applying image processing and artificial intelligence technology. The method comprises the steps of acquiring a workpiece image by using an industrial camera, firstly extracting an edge profile of the workpiece, then calculating linear parameters of the edge profile, and finally calculating the physical size of the workpiece by combining calibration data of the camera.
Current machine vision based measurement methods rely heavily on extracted workpiece edge information. However, in reality, due to the interference of surface reflection, texture and noise, the extracted workpiece edge is irregular, incomplete or even distorted, which causes measurement errors. In addition, different illumination conditions, workpiece materials and environmental backgrounds all affect the detection of the edge of the workpiece, so that the edge-based size measurement method has poor adaptability.
Disclosure of Invention
In view of the problems mentioned in the background art, the object of the present invention is to provide a workpiece dimension measuring method and system based on machine vision; the method can be based on the pixels of the workpiece area instead of the edge profile of the workpiece, thereby improving the measurement precision of the workpiece size and enhancing the adaptability of the measurement method.
The technical purpose of the invention is realized by the following technical scheme: a workpiece dimension measurement method based on machine vision comprises the following steps:
s1, image acquisition: shooting a workpiece to be measured by using an industrial camera, and acquiring a workpiece image;
s2, image preprocessing: converting the collected workpiece image into a binary image;
s3, workpiece size detection: detecting the length and the width of a workpiece in an image space;
s4, calculating the size of the workpiece: and calculating the physical length and width of the workpiece by combining the calibration parameters of the camera and the length and width of the workpiece detected in the image space.
Preferably, in step S3, the workpiece size detection includes the steps of:
s31, selecting all black pixels in the binary image, and voting in the Hough space by using the formula ρ ═ x · cos θ + y · sin θ;
s32, searching the maximum voting value in the Hough space, and selecting 2 x n +1 columns of voting data near the maximum voting value for further processing;
s33, calculating voting variance sigma of each column i 2 :
s34, voting angle theta of voting data in 2 x n +1 columns i Making abscissa and voting variance σ i 2 As ordinate, fit a quadratic function: a is 2 x 2 +a 1 x+a 0 ;
S35, coefficient a of quadratic function according to fitting 2 、a 1 And a 0 The length and width of the workpiece in image space are detected.
Preferably, the step S35 specifically includes:
the technical purpose of the invention is realized by the following technical scheme: a machine vision based workpiece dimension measurement system comprising the following modules: the device comprises an image acquisition module, an image preprocessing module, a workpiece size detection module and a workpiece size calculation module.
The image acquisition module is used for photographing the workpiece and acquiring a workpiece image; before acquiring a workpiece image, calibrating a selected industrial camera in advance;
the image preprocessing module is used for preprocessing the workpiece image, converting the workpiece image into a gray image and then converting the gray image into a binary image;
the workpiece size detection module is used for detecting the length and the width of the workpiece in the image; selecting black point pixels to perform Hough voting, selecting a group of voting angles near the maximum voting value, calculating a corresponding voting variance, fitting the voting variance into a quadratic function, and detecting the length and the width of a workpiece in an image space based on a fitting coefficient;
the workpiece size calculating module is used for calculating the physical size of the workpiece; and calculating the physical size of the workpiece by combining the calibration parameters of the camera and the length and the width of the workpiece in the image space, which are obtained by the workpiece size detection module.
In summary, the invention mainly has the following beneficial effects: the workpiece dimension measuring method and system based on machine vision of the invention detect the length and width of the workpiece by fitting the voting variance to the quadratic function and applying the fitting coefficient, and have sub-pixel precision, so the measuring precision is high; the method is directly based on the binary image, does not need to extract the edge profile of the workpiece, and has wider adaptability.
Drawings
FIG. 1 is a flow chart of a method for measuring dimensions of a workpiece based on machine vision according to the present invention;
FIG. 2 is a flow chart of an embodiment of the present invention for detecting a length and a width of a workpiece in image space;
fig. 3 is a block diagram of a workpiece dimension measuring system based on machine vision according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
Fig. 1 is a flow chart of a workpiece dimension measuring method based on machine vision according to the present invention, which includes the following steps:
step one, image acquisition: and selecting a common industrial camera to calibrate the camera parameters. Shooting a workpiece to be measured by using a calibrated camera, and collecting a workpiece image;
step two, image preprocessing: firstly, converting an acquired color image into a gray image, then calculating a binary threshold value by using OTSU, and converting the gray image into a binary image; optionally, performing inverse value operation on the binary image to make the workpiece pixel appear black and the background pixel appear white;
step three, workpiece size detection: based on the binary image, selecting all black point pixels to vote to a Hough space; calculating the voting variance in a Hough space, fitting the voting variance into a quadratic function, and detecting the length and the width of a workpiece in an image space;
further, the third step is specifically:
(1) in the binary image, all black pixels are selected, and voting is performed on the Hough space by using the following formula.
ρ=x·cosθ+y·sinθ
Wherein x and y represent pixel point coordinates, and theta and rho are voting angles and voting distances;
the Hough space is represented by a two-dimensional array A, and the range of the voting angle theta is [ -0.23.4]Step size is 0.02 radian; the range of voting distances ρ -400400]The step size is 1. In Hough space, element A of ith column and jth row ij Representing the corresponding voting angle theta i Voting distance ρ j The vote value of (2).
(2) Searching the maximum voting value in the Hough space after all the black point pixels vote; the voting angle corresponding to the maximum voting value is as follows: Θ is 0.52 radian. 9 columns are selected on the left side and the right side of the theta, and 19 columns of voting data are selected. Processing the 19 columns of voting data, and detecting the length and the width of the workpiece;
(3) at theta i Column, calculate voting variance σ i 2 :
(4) voting angle theta of 19 columns of voting data i As abscissa, variance σ of vote i 2 For the ordinate, a quadratic function is fitted, which is:
f:y=a 2 x 2 +a 1 x+a 0
=3101.1x 2 -3440.4x+1017.7
(5) coefficient of quadratic function a according to fitting 2 、a 1 、a 0 And detecting the length and width of the workpiece in the image space as follows:
step four, calculating the size of the workpiece: and calculating the physical length and width of the workpiece based on the length L and width W of the workpiece detected in the third step by combining the calibration parameters of the camera.
The invention also provides a workpiece dimension measuring system based on machine vision, which comprises: the device comprises an image acquisition module, an image preprocessing module, a workpiece size detection module and a workpiece size calculation module.
The image acquisition module is used for photographing the workpiece and acquiring a workpiece image I. Before acquiring the workpiece image, calibrating the selected industrial camera in advance.
The image preprocessing module is used for preprocessing the workpiece image, converting the color image into a gray image and then converting the gray image into a binary image B. Optionally, the inverse value operation is performed on the binary image, so that the workpiece pixel appears black, and the background pixel appears white.
The workpiece size detection module is used for detecting the length and the width of the workpiece in the image; selecting black point pixels in the image to vote in a two-dimensional Hough space, selecting a group of voting angles near the maximum voting value, and calculating the voting variance corresponding to each voting angle; the voting variance is fitted to a quadratic function, and the length L and width W of the workpiece in image space are detected based on the coefficients of the fitted quadratic function.
And the workpiece size calculating module is used for calculating the physical size of the workpiece. And calculating the physical size of the workpiece based on the length L and the width W of the workpiece obtained by the workpiece size detection module by combining the calibration parameters of the camera.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
Claims (5)
1. A workpiece dimension measuring method based on machine vision, characterized by comprising the following steps:
s1, image acquisition: shooting a workpiece to be measured by using an industrial camera, and acquiring a workpiece image;
s2, image preprocessing: converting the collected workpiece image into a binary image;
s3, workpiece size detection: detecting the length and the width of a workpiece in an image space;
s4, calculating the size of the workpiece: the physical length and width of the workpiece are calculated in combination with the calibration parameters of the camera, and the length and width of the workpiece detected in image space.
2. The machine-vision based workpiece dimension measuring method of claim 1, wherein the workpiece dimension is directly detected on the binary image without extracting an edge profile of the workpiece.
3. The machine-vision-based workpiece dimension measuring method of claim 1, wherein in the step S3, the workpiece dimension detection comprises the steps of:
s31, selecting all black pixels in the binary image, and voting in the Hough space by using the formula ρ ═ x · cos θ + y · sin θ;
s32, searching the maximum voting value in the Hough space, and selecting 2 x n +1 columns of voting data near the maximum voting value for further processing;
s33, calculating voting variance sigma of each column i 2 :
Wherein m is i Is the mean of the votes for this column:A ij is the vote value, ρ, of the ith column and jth row j Is the voting distance corresponding to the jth line.
S34, voting angle theta of voting data in 2 x n +1 columns i Making abscissa and voting variance σ i 2 As ordinate, fit a quadratic function: a is 2 x 2 +a 1 x+a 0 ;
S35 coefficient a of quadratic function based on fitting 2 、a 1 And a 0 The length and width of the workpiece in image space are detected.
5. a workpiece dimension measurement system based on machine vision, comprising the following modules: the device comprises an image acquisition module, an image preprocessing module, a workpiece size detection module and a workpiece size calculation module.
The image acquisition module is used for photographing the workpiece and acquiring a workpiece image; before acquiring a workpiece image, calibrating a selected industrial camera in advance;
the image preprocessing module is used for preprocessing the workpiece image, converting the workpiece image into a gray image and then converting the gray image into a binary image;
the workpiece size detection module is used for detecting the length and the width of the workpiece in the image; selecting black point pixels to perform Hough voting, selecting a group of voting angles near the maximum voting value, calculating a corresponding voting variance, fitting the voting variance into a quadratic function, and detecting the length and the width of a workpiece in an image space based on a fitting coefficient;
the workpiece size calculating module is used for calculating the physical size of the workpiece; and calculating the physical size of the workpiece by combining the calibration parameters of the camera and the length and the width of the workpiece in the image space, which are obtained by the workpiece size detection module.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210444500.9A CN114791265A (en) | 2022-04-26 | 2022-04-26 | Workpiece dimension measuring method and system based on machine vision |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210444500.9A CN114791265A (en) | 2022-04-26 | 2022-04-26 | Workpiece dimension measuring method and system based on machine vision |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114791265A true CN114791265A (en) | 2022-07-26 |
Family
ID=82462545
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210444500.9A Pending CN114791265A (en) | 2022-04-26 | 2022-04-26 | Workpiece dimension measuring method and system based on machine vision |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114791265A (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105865344A (en) * | 2016-06-13 | 2016-08-17 | 长春工业大学 | Workpiece dimension measuring method and device based on machine vision |
CN109934839A (en) * | 2019-03-08 | 2019-06-25 | 北京工业大学 | A kind of workpiece inspection method of view-based access control model |
-
2022
- 2022-04-26 CN CN202210444500.9A patent/CN114791265A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105865344A (en) * | 2016-06-13 | 2016-08-17 | 长春工业大学 | Workpiece dimension measuring method and device based on machine vision |
CN109934839A (en) * | 2019-03-08 | 2019-06-25 | 北京工业大学 | A kind of workpiece inspection method of view-based access control model |
Non-Patent Citations (1)
Title |
---|
ZEZHONG XU等: "《Closed form line-segment extraction using the Hough transform》", 《PATTERNRECOGNITION》, 26 June 2015 (2015-06-26), pages 4012 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108921176B (en) | Pointer instrument positioning and identifying method based on machine vision | |
CN110276808B (en) | Method for measuring unevenness of glass plate by combining single camera with two-dimensional code | |
CN109410207B (en) | NCC (non-return control) feature-based unmanned aerial vehicle line inspection image transmission line detection method | |
JP7037876B2 (en) | Use of 3D vision in automated industrial inspection | |
CN112651968B (en) | Wood board deformation and pit detection method based on depth information | |
CN111353993B (en) | Thread angle measuring method based on machine vision | |
CN111308448A (en) | Image acquisition equipment and radar external parameter determination method and device | |
CN111429533B (en) | Camera lens distortion parameter estimation device and method | |
CN107796826B (en) | Micro duplicate gear broken tooth defect detection method based on tooth center distance curve analysis | |
CN112686920A (en) | Visual measurement method and system for geometric dimension parameters of circular part | |
CN110517265A (en) | A kind of detection method of surface defects of products, device and storage medium | |
CN111996883A (en) | Method for detecting width of road surface | |
CN114005108A (en) | Pointer instrument degree identification method based on coordinate transformation | |
CN113607058B (en) | Straight blade size detection method and system based on machine vision | |
CN114485433A (en) | Three-dimensional measurement system, method and device based on pseudo-random speckles | |
CN112419225B (en) | SOP type chip detection method and system based on pin segmentation | |
CN111667429B (en) | Target positioning correction method for inspection robot | |
CN115760860B (en) | Multi-type workpiece dimension visual measurement method based on DXF file import | |
CN113310426A (en) | Thread parameter measuring method and system based on three-dimensional profile | |
CN110751690B (en) | Visual positioning method for milling machine tool bit | |
CN114791265A (en) | Workpiece dimension measuring method and system based on machine vision | |
CN116880353A (en) | Machine tool setting method based on two-point gap | |
CN116152532A (en) | Remote sensing image feature extraction and matching method and device and electronic equipment | |
CN113450335B (en) | Road edge detection method, road edge detection device and road surface construction vehicle | |
CN115100153A (en) | Binocular matching-based in-pipe detection method and device, electronic equipment and medium |
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 |