CN112325772A - Punching size measuring method, system, equipment and medium based on machine vision - Google Patents

Punching size measuring method, system, equipment and medium based on machine vision Download PDF

Info

Publication number
CN112325772A
CN112325772A CN202011173827.4A CN202011173827A CN112325772A CN 112325772 A CN112325772 A CN 112325772A CN 202011173827 A CN202011173827 A CN 202011173827A CN 112325772 A CN112325772 A CN 112325772A
Authority
CN
China
Prior art keywords
image
measured
edge
size
aperture value
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
CN202011173827.4A
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.)
State Grid Corp of China SGCC
China Electric Power Research Institute Co Ltd CEPRI
Original Assignee
State Grid Corp of China SGCC
China Electric Power Research Institute Co Ltd CEPRI
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 State Grid Corp of China SGCC, China Electric Power Research Institute Co Ltd CEPRI filed Critical State Grid Corp of China SGCC
Priority to CN202011173827.4A priority Critical patent/CN112325772A/en
Publication of CN112325772A publication Critical patent/CN112325772A/en
Pending legal-status Critical Current

Links

Images

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
    • 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
    • G01B11/08Measuring arrangements characterised by the use of optical techniques for measuring diameters
    • G01B11/12Measuring arrangements characterised by the use of optical techniques for measuring diameters internal diameters
    • 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
    • G01B11/14Measuring arrangements characterised by the use of optical techniques for measuring distance or clearance between spaced objects or spaced apertures
    • 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/20048Transform domain processing
    • G06T2207/20061Hough transform
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30164Workpiece; Machine component

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Theoretical Computer Science (AREA)
  • Geometry (AREA)
  • Image Analysis (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

The invention belongs to the field of machine vision measurement, and discloses a punching size measuring method, a punching size measuring system, punching size measuring equipment and a punching size measuring medium based on machine vision, which comprise the following steps: acquiring a binary image of a part to be measured; based on the binary image, acquiring edge points of punched holes on the part to be measured through an edge detection algorithm; obtaining a maximum aperture value and a minimum aperture value of the punched image according to the edge points of the punched hole; and converting the image maximum aperture value and the image minimum aperture value into an actual maximum aperture value and an actual minimum aperture value based on a calibration coefficient between the image size and the actual size of the part to be measured. The image is directly used as a size calculation basis, the actual physical size is calculated by multiplying the image size value by the calibration coefficient, the automation of punching size measurement is realized, the detection efficiency is greatly improved, and meanwhile, the interference of human errors in the traditional manual detection process is effectively reduced.

Description

Punching size measuring method, system, equipment and medium based on machine vision
Technical Field
The invention belongs to the field of machine vision measurement, and relates to a punching size measuring method, system, equipment and medium based on machine vision.
Background
With the continuous improvement of the economic living standard, the demands of various industries represented by manufacturing industry and building industry on electric power energy are increasingly urgent, and therefore, the construction of the ultrahigh voltage transmission line with the goals of power grid expansion and trans-regional power transmission is accelerated. The power transmission iron tower is an important component of a power transmission line and is the key for ensuring the safe transmission of electric energy. In the hole machining production process of the angle steel tower component, a punching machining process is adopted for 80% of holes, and the position precision and the size precision of punching directly influence the assembly quality of the iron tower.
The traditional punching measurement adopts a vernier caliper to measure the relevant size of punching, and the whole process is finished manually. However, the measurement by workers is time-consuming and labor-consuming, the measurement result is easily affected by the detection personnel, and the repeatability of the measurement result is poor. Therefore, the existing manual measurement method has difficulty in meeting the requirement of modern industrial mass production on measurement efficiency.
Disclosure of Invention
The invention aims to overcome the defects that the existing punching measurement is time-consuming and labor-consuming, is easily influenced by detection personnel and has low measurement efficiency in the prior art, and provides a punching size measurement method, a punching size measurement system, punching size measurement equipment and a punching size measurement medium based on machine vision.
In order to achieve the purpose, the invention adopts the following technical scheme to realize the purpose:
in a first aspect of the present invention, a punch hole size measuring method based on machine vision includes the following steps:
acquiring a binary image of a part to be measured;
based on the binary image, acquiring edge points of punched holes on the part to be measured through an edge detection algorithm;
obtaining a maximum aperture value and a minimum aperture value of the punched image according to the edge points of the punched hole;
and converting the image maximum aperture value and the image minimum aperture value into an actual maximum aperture value and an actual minimum aperture value based on a calibration coefficient between the image size and the actual size of the part to be measured.
The punching size measuring method based on machine vision of the invention is further improved in that:
the specific method for acquiring the binary image of the part to be measured comprises the following steps:
acquiring an image and a gray level histogram of a part to be measured;
and setting a separation threshold value based on the gray level histogram, and performing threshold value segmentation on the image of the part to be measured according to the segmentation threshold value to obtain a binary image of the part to be measured.
The specific method for acquiring the edge point of the punched hole on the part to be measured by the edge detection algorithm comprises the following steps:
acquiring an initial edge point of a punched hole on a part to be measured by a Canny edge detection algorithm;
and (4) optimizing the initial edge point by an edge detection method based on Zernike moment to obtain the punched edge point.
The calibration coefficient is determined in the following way:
acquiring an image of a calibration block based on the same acquisition environment as the part to be measured; the calibration coefficient is the ratio of the size of the calibration block to the image size of the calibration block.
Further comprising:
determining a plurality of external rectangles of the punched hole according to the edge points of the punched hole;
taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole;
and calculating the image distance between the centers of the two adjacent holes, and obtaining the distance between the centers of the two adjacent punched holes on the part to be measured based on the calibration coefficient between the image size and the actual size of the part to be measured.
Further comprising:
determining a plurality of external rectangles of the punched hole according to the edge points of the punched hole;
taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole;
based on the binary image, acquiring an edge straight line of the part to be measured through a straight line detection algorithm;
and calculating the image distance from the center of the hole to the edge straight line, and obtaining the distance between the center of the punched hole of the part to be measured and the edge of the part to be measured based on the calibration coefficient between the image size and the actual size of the part to be measured.
The straight line detection algorithm is a Hough transform straight line detection algorithm.
In a second aspect of the present invention, a punch hole size measuring system based on machine vision includes:
the image acquisition module is used for acquiring a binary image of the part to be measured;
the edge determining module is used for acquiring edge points of the punched hole on the part to be measured through an edge detection algorithm based on the binary image;
the image aperture determining module is used for obtaining the maximum aperture value and the minimum aperture value of the punched image according to the edge points of the punched hole; and
and the conversion module is used for converting the maximum image aperture value and the minimum image aperture value into the actual maximum aperture value and the actual minimum aperture value based on the calibration coefficient between the image size and the actual size of the part to be measured.
In a third aspect of the present invention, a computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned machine vision-based punch hole size measuring method when executing the computer program.
In a fourth aspect of the present invention, a computer-readable storage medium stores a computer program which, when executed by a processor, implements the steps of the above-described machine vision-based punch hole sizing method.
Compared with the prior art, the invention has the following beneficial effects:
the invention relates to a punching size measuring method based on machine vision, which comprises the steps of obtaining a binary image of a part to be measured, obtaining edge points of a punched hole on the part to be measured based on the binary image and an edge detection algorithm, further obtaining a maximum aperture value and a minimum aperture value of the punched hole based on the edge points, converting the maximum aperture value and the minimum aperture value of the punched hole into an actual maximum aperture value and an actual minimum aperture value of the punched hole according to a calibration coefficient between the image size and the actual size, and further judging whether the punched hole size is qualified or not by calculating a difference value between a measuring size and a drawing design size. Through directly adopting the image as the size calculation basis, obtain actual physical dimension through the image size, realize punching a hole automatic measure of size, and then effectively reduce the interference of human error among the traditional manual testing process, simultaneously, very big improvement measurement and detection efficiency.
Drawings
FIG. 1 is a flow chart of a punch hole size measuring method based on machine vision according to an embodiment of the present invention;
FIG. 2 is a gray level histogram of an image of a part to be measured according to an embodiment of the present invention;
FIG. 3 is a binary diagram of a part to be measured according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a circumscribed rectangle of a punched hole of a part to be measured according to an embodiment of the invention;
FIG. 5 is a schematic diagram of hole spacing between adjacent punched holes of a part to be measured according to an embodiment of the invention;
FIG. 6 is a detailed flowchart of a punching size measuring method based on machine vision according to an embodiment of the present invention;
fig. 7 is a schematic diagram of the hole edge distance of the punched hole of the part to be measured according to the embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, 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 derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The invention is described in further detail below with reference to the accompanying drawings:
referring to fig. 1, in an embodiment of the present invention, an image is directly used as a size calculation basis, and an actual physical size is calculated by multiplying an image size value by a calibration coefficient, so that automation of punching size measurement is realized, detection efficiency is greatly improved, and interference of human errors in a conventional manual detection process is effectively reduced. Specifically, the punching hole size measuring method based on machine vision comprises the following steps.
S1: and acquiring a binary image of the part to be measured.
Specifically, in this embodiment, the image of the part to be measured is acquired by using an image acquisition system, such as a camera. And through reading the image of the part to be measured, see fig. 2, obtain the gray level histogram of the image of the part to be measured, set up the separation threshold value through the gray level distribution of the gray level histogram, cut apart the threshold value to carry on the threshold value to the image of the part to be measured through the simple threshold value method according to cutting apart the threshold value, it is simple to realize, the calculated amount is little, the performance is stable. Referring to fig. 3, a binary map of the part to be measured is obtained, specifically, a pixel with a gray value greater than a segmentation threshold is defined as 1, and a pixel with a gray value less than the segmentation threshold is defined as 0.
S2: and acquiring edge points of the punched hole on the part to be measured by an edge detection algorithm based on the binary image.
Specifically, the edge detection algorithm may adopt a Canny edge detection algorithm, an HED (integral nested edge detection) algorithm or a Fast edge detection algorithm (structured forest Fast edge detection); in the embodiment, based on the binary image, the initial edge point of the punched hole on the part to be measured is obtained through a Canny edge detection algorithm, a Canny operator is not easily interfered by noise, a real weak edge can be detected, and the real weak edge is included in the output image. And then optimizing initial edge points by an edge detection method based on Zernike moments, and obtaining punched edge points, wherein the method has the advantages of insensitivity to noise and high efficiency compared with a fitting method and an interpolation method.
The Canny edge detection algorithm is a multi-stage edge detection algorithm developed by John f.canny in 1986, and specifically, the step of obtaining an initial edge point of a punched hole on a part to be measured by the Canny edge detection algorithm comprises the following steps:
s201: and performing Gaussian filtering on the binary image by using a Gaussian filter to remove noise of the binary image, wherein the two-dimensional Gaussian function is H (x, y):
Figure BDA0002748131700000061
G(x,y)=f(x,y)*H(x,y)
wherein f (x, y) is image data of a binary image, a convolution sign, and G (x, y) is image data of a gaussian-filtered binary image.
S202: calculating gradient amplitude M (x, y) and gradient direction theta (x, y) of each pixel of the binary image by using a difference operator of first-order partial derivatives:
Figure BDA0002748131700000062
Figure BDA0002748131700000063
s203: non-maximum suppression of gradient magnitude is performed. And comparing the gradient intensity of each pixel in the binary image with two pixels in the positive and negative gradient directions, if the gradient intensity of the current pixel is maximum compared with the other two pixels, keeping the pixel as an initial edge point, and otherwise, setting the pixel point to be zero.
S204: double thresholding and edge joining are performed. By presetting two thresholds of T1 and T2, when the gradient value of a pixel is larger than T1, the pixel is called a strong edge, when the gradient value of the pixel is smaller than T1 and larger than T2, the pixel is called a weak edge, and when the gradient value of the pixel is smaller than T2, the pixel is not an edge point. The strong edge is bound to be an edge point, when the strong edge point exists in the 8 neighborhood around the weak edge pixel point, the weak edge point is changed into the strong edge point, so that edge supplement is realized, when the strong edge point does not exist in the 8 neighborhood around the weak edge pixel point, the weak edge point is considered to be a non-edge point, and all initial edge points are obtained in such a mode.
The edge detection method based on the Zernike moment is a sub-pixel edge detection algorithm, and specifically, the specific process of optimizing the initial edge point by the edge detection method based on the Zernike moment is as follows:
s211: and (5) parameter definition is carried out. The nth order m Zernike moments of the data f (x, y) of the binary map are defined as:
Figure BDA0002748131700000071
wherein f (x, y) is the gray scale value of the (x, y) point in the binary image,
Figure BDA0002748131700000074
is a Zernike polynomial VnmComplex conjugation of (ρ, θ).
Under discrete conditions, the Zernike moment solving function is:
Znm=P*Mnm
wherein Z isnmIs n-order M-order Zernike moment of pixel-level edge point, P is convolution window center with pixel-level edge point as center, M isnmIs a template matrix of n-order m-order moments.
S21: using a template Re (M)11)、Im(M11) Respectively calculating with binary image convolution to obtain corresponding real part Re (Z) of Zernike moment11) And an imaginary part Im (Z)11),M20Obtaining second-order zero-order Zernike moment Z by convolution operation of binary image20
S213: and calculating values of parameters phi, l and k by using the rotation invariant characteristic of the Zernike moment:
Figure BDA0002748131700000072
Figure BDA0002748131700000073
Figure BDA0002748131700000081
wherein phi represents an included angle between the vertical line from the center of the convolution window to the actual edge and the horizontal direction by taking the edge center pixel P as the center of the convolution window, l represents the distance from the edge center P to the actual edge, k represents a gray level step value of the edge relative to the background, and Z'11Is Z11Zernike moment after the angle phi is rotated.
S214: presetting thresholds delta and tau, carrying out edge judgment on each pixel point, if the pixel point meets the condition that l is less than or equal to delta and k is greater than or equal to tau, considering the pixel point as an edge point, judging whether the initial edge point is the edge point by adopting the mode, realizing the optimization of the initial edge point, and further obtaining the punched edge point.
S3: and obtaining the maximum aperture value and the minimum aperture value of the punched image according to the edge points of the punched hole.
In this embodiment, a plurality of external rectangles of the punched hole are determined according to the edge points of the punched hole, the length of the external rectangle with the smallest area among the plurality of external rectangles is used as the maximum aperture value of the image of the punched hole, and the width of the external rectangle with the smallest area among the plurality of external rectangles is used as the minimum aperture value of the image of the punched hole. Specifically, the method comprises the following steps:
s301: referring to fig. 4, by comparing the x and y coordinate values of each pixel point on the punched edge, 4 pixel points on the leftmost end, the rightmost end, the uppermost end and the lowermost end of the punched edge are obtained, a straight line parallel to the y axis is made through the leftmost end and the rightmost end, a straight line parallel to the x axis is made through the uppermost end and the lowermost end, four straight lines obtain a simple external rectangle of which the sealed area is a punched hole, the area of the external rectangle is recorded, the external rectangle RectMin is obtained, a face value is obtained and given to the variable AreaMin, and meanwhile, the rotation angle α is set to be 0 °.
S302: for the outline region, i.e., the punched region, a rotation angle β (the smaller β is, the higher the detection accuracy) is set, α ═ α + β, and the circumscribed rectangle rectmp after the rotation is calculated in the manner of S301, thereby obtaining the area AreaTmp.
S303: comparing the sizes of the AreaTmp and the AreaMin, assigning a small area to the AreaMin, assigning the rotation angle at the moment to beta, namely, the beta is alpha, and assigning rectangle information to the RectMin.
S304: and circularly executing the processes of S302 and S303, rotating the simple circumscribed rectangle obtained in S301 by 180 degrees to stop the circulation, and obtaining the final minimum circumscribed rectangle RectMin and the rotation angle alpha corresponding to the minimum circumscribed rectangle RectMin. The length of the circumscribed rectangle is used as the maximum aperture value of the punched image, and the width is used as the minimum aperture value of the punched image.
S4: and converting the image maximum aperture value and the image minimum aperture value into an actual maximum aperture value and an actual minimum aperture value based on a calibration coefficient between the image size and the actual size of the part to be measured.
In this embodiment, the image of the calibration block is acquired based on the same acquisition environment as the part to be measured; the ratio of the size of the calibration block to the size of the image of the calibration block is obtained as a calibration coefficient, specifically, the image of the calibration block is collected by an image collection system, the number of pixels of the calibration block in the image is N (millimeter is used as unit), the actual length of the calibration block is M, and the calibration coefficient K can be expressed as:
Figure BDA0002748131700000091
when the camera lens parameters, the external connection conditions and the relative position relation between the camera and the target of the image acquisition system are unchanged, the calibration coefficient of the camera is unchanged. Let the actual size value of part be L (with millimeter as the unit), the camera gathers part size pixel size and is P, and part actual size is:
Figure BDA0002748131700000092
based on the mode, the maximum image aperture value and the minimum image aperture value are multiplied by calibration coefficients respectively to obtain the actual maximum aperture value and the actual minimum aperture value of the punched hole.
And finally, calculating a difference value between the measured punching size and the design size of a drawing by setting an error range, judging whether the difference value is within the error range, judging that the part is qualified if the difference value is within the error allowable range, and judging that the part is unqualified if the difference value is not within the error allowable range, thereby realizing the detection of the part to be measured.
In summary, according to the punching size measuring method based on machine vision, the binary image of the part to be measured is obtained, the edge point of the punched hole on the part to be measured is obtained through the edge detection algorithm based on the binary image, the maximum aperture value and the minimum aperture value of the punched hole are obtained based on the edge point, the maximum aperture value and the minimum aperture value of the punched hole are converted into the actual maximum aperture value and the actual minimum aperture value of the punched hole according to the calibration coefficient between the image size and the actual size, and the punching size is judged to be qualified or not through calculating the difference between the measured size and the design size of the drawing. Through directly adopting the image as the size calculation basis, obtain actual physical dimension through the image size, realize punching a hole automatic measure of size, and then effectively reduce the interference of human error among the traditional manual testing process, simultaneously, very big improvement measurement and detection efficiency.
In yet another embodiment of the present invention, a punch hole size measuring method based on machine vision is provided, which is different from the punch hole size measuring method in the embodiment shown in fig. 1 in that, in addition to the whole content, the method further comprises at least the following steps:
determining a plurality of external rectangles of the punched hole according to the edge points of the punched hole; taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole; referring to fig. 5, the image distance between the centers of two adjacent holes is calculated, and the distance between the centers of two adjacent punched holes on the part to be measured is obtained based on the calibration coefficient between the image size and the actual size of the part to be measured.
Through the steps, the distance between the hole centers of the two adjacent punched holes on the part to be measured is obtained, the difference value between the measured distance between the hole centers of the two adjacent punched holes and the design size of a drawing is calculated through setting an error range, whether the difference value is within the error range or not is judged, and if the difference value is within the error allowable range, the part is judged to be qualified, and if the difference value is not within the error allowable range, the part is not qualified.
In still another embodiment of the present invention, referring to fig. 6, there is provided a punch hole size measuring method based on machine vision, which is different from the punch hole size measuring method in the embodiment shown in fig. 1 in that, in addition to the whole contents, the method further comprises at least the following steps:
determining a plurality of external rectangles of the punched hole according to the edge points of the punched hole; taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole; based on the binary image, acquiring an edge straight line of the part to be measured through a straight line detection algorithm; referring to fig. 7, the image distance of the straight line from the center of the hole to the edge is calculated, and the distance between the center of the hole of the punched hole of the part to be measured and the edge of the part to be measured is obtained based on the calibration coefficient between the image size and the actual size of the part to be measured.
In this embodiment, when the edge straight line of the part to be measured is obtained by the straight line detection algorithm, the edge straight line of the part to be measured is obtained by using the hough transform straight line detection algorithm, specifically, the method includes the following steps:
t1: defining the equation of a straight line ρ ═ xcos θ + ysin θ, establishing a discrete parameter space between the maxima and minima for ρ, θ, typically values in the range-D ≦ ρ ≦ D and-90 ° ≦ θ ≦ +90 °, where D is the farthest distance between the two diagonals in the binary image of the part to be measured.
T2: the parameter space (ρ, θ) is quantized into m × n cells, and an accumulator matrix is set, where m is the number of equal parts of ρ and n is the number of equal parts of θ.
T3: each cell of the parameter space is assigned an accumulator Q (i, j) and the initial value of the accumulator is set to 0.
T4: for each pixel point (edge point) (x, y) detected by the edge, ρ ═ xcos θ + ysin θ is substituted, and ρ value corresponding to each θ is obtained.
T5: and finding a unit corresponding to rho and theta in the parameter space, and adding 1 to an accumulator of the unit.
T6: when all points in the rectangular coordinate system are traversed through two steps of T4 and T5, the value of the parameter space accumulator is checked, and rho and theta corresponding to the maximum unit of the accumulator are parameters of a linear equation in the rectangular coordinate system, namely edge lines of the part to be measured.
After the edge straight line of the part to be measured is obtained, the center of the punched hole is used as a perpendicular line of the edge straight line of the part to be measured, the foot-hanging coordinate is stored as a characteristic point, the pixel value from the center of the hole to the characteristic point, namely the image distance (image hole edge distance) between the punched hole and the edge of the part to be measured is calculated, then the image hole edge distance is multiplied by a calibration coefficient, and the actual hole edge distance between the punched hole and the edge is calculated and used as a qualified detection index of the part to be measured. And calculating the difference between the measured actual hole edge distance and the design size of the drawing by setting an error range, judging whether the difference is within the error range, and if so, judging that the hole is qualified, otherwise, judging that the hole is unqualified.
The following are embodiments of the apparatus of the present invention that may be used to perform embodiments of the method of the present invention. For details of non-careless mistakes in the embodiment of the apparatus, please refer to the embodiment of the method of the present invention.
In another embodiment of the present invention, a machine vision-based punching dimension measuring system is provided, which can be used to implement the above machine vision-based punching dimension measuring method, and specifically, the machine vision-based punching dimension measuring system includes an image acquisition module, an edge determination module, an image aperture determination module, and a conversion module.
The image acquisition module is used for acquiring a binary image of the part to be measured; the edge determining module is used for acquiring edge points of the punched hole on the part to be measured through an edge detection algorithm based on the binary image; the image aperture determining module is used for obtaining the maximum aperture value and the minimum aperture value of the punched image according to the edge points of the punched hole; the conversion module is used for converting the image maximum aperture value and the image minimum aperture value into an actual maximum aperture value and an actual minimum aperture value based on a calibration coefficient between the image size and the actual size of the part to be measured.
Preferably, the punching size measuring system based on machine vision further comprises a hole spacing measuring module, which is used for determining a plurality of circumscribed rectangles of the punched hole according to the edge points of the punched hole; taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole; and calculating the image distance between the centers of the two adjacent holes, and obtaining the distance between the centers of the two adjacent punched holes on the part to be measured based on the calibration coefficient between the image size and the actual size of the part to be measured.
Preferably, the punching size measuring system based on machine vision further comprises a hole edge distance measuring module, which is used for determining a plurality of circumscribed rectangles of the punched hole according to the edge points of the punched hole; taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole; based on the binary image, acquiring an edge straight line of the part to be measured through a straight line detection algorithm; and calculating the image distance from the center of the hole to the edge straight line, and obtaining the distance between the center of the punched hole of the part to be measured and the edge of the part to be measured based on the calibration coefficient between the image size and the actual size of the part to be measured.
In yet another embodiment of the present invention, a terminal device is provided that includes a processor and a memory for storing a computer program comprising program instructions, the processor being configured to execute the program instructions stored by the computer storage medium. The Processor may be a Central Processing Unit (CPU), or may be other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable gate array (FPGA) or other Programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc., which is a computing core and a control core of the terminal, and is adapted to implement one or more instructions, and is specifically adapted to load and execute one or more instructions to implement a corresponding method flow or a corresponding function; the processor of the embodiment of the invention can be used for the operation of the punching size measuring method based on machine vision, and comprises the following steps: acquiring a binary image of a part to be measured; based on the binary image, acquiring edge points of punched holes on the part to be measured through an edge detection algorithm; obtaining a maximum aperture value and a minimum aperture value of the punched image according to the edge points of the punched hole; and converting the image maximum aperture value and the image minimum aperture value into an actual maximum aperture value and an actual minimum aperture value based on a calibration coefficient between the image size and the actual size of the part to be measured.
In still another embodiment of the present invention, the present invention further provides a storage medium, specifically a computer-readable storage medium (Memory), which is a Memory device in a terminal device and is used for storing programs and data. It is understood that the computer readable storage medium herein may include a built-in storage medium in the terminal device, and may also include an extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space storing an operating system of the terminal. Also, one or more instructions, which may be one or more computer programs (including program code), are stored in the memory space and are adapted to be loaded and executed by the processor. It should be noted that the computer-readable storage medium may be a high-speed RAM memory, or may be a non-volatile memory (non-volatile memory), such as at least one disk memory.
One or more instructions stored in a computer-readable storage medium may be loaded and executed by a processor to perform the corresponding steps of the above embodiments with respect to the machine vision based punch sizing method; one or more instructions in the computer-readable storage medium are loaded by the processor and perform the steps of: acquiring a binary image of a part to be measured; based on the binary image, acquiring edge points of punched holes on the part to be measured through an edge detection algorithm; obtaining a maximum aperture value and a minimum aperture value of the punched image according to the edge points of the punched hole; and converting the image maximum aperture value and the image minimum aperture value into an actual maximum aperture value and an actual minimum aperture value based on a calibration coefficient between the image size and the actual size of the part to be measured.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting the same, and although the present invention is described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that: modifications and equivalents may be made to the embodiments of the invention without departing from the spirit and scope of the invention, which is to be covered by the claims.

Claims (10)

1. A punching hole size measuring method based on machine vision is characterized by comprising the following steps:
acquiring a binary image of a part to be measured;
based on the binary image, acquiring edge points of punched holes on the part to be measured through an edge detection algorithm;
obtaining a maximum aperture value and a minimum aperture value of the punched image according to the edge points of the punched hole;
and converting the image maximum aperture value and the image minimum aperture value into an actual maximum aperture value and an actual minimum aperture value based on a calibration coefficient between the image size and the actual size of the part to be measured.
2. A punch hole size measuring method based on machine vision according to claim 1, characterized in that the specific method for obtaining the binary image of the part to be measured is as follows:
acquiring an image and a gray level histogram of a part to be measured;
and setting a separation threshold value based on the gray level histogram, and performing threshold value segmentation on the image of the part to be measured according to the segmentation threshold value to obtain a binary image of the part to be measured.
3. A punch hole size measuring method based on machine vision according to claim 1, characterized in that the specific method for obtaining the edge point of the punch hole on the part to be measured by the edge detection algorithm is as follows:
acquiring an initial edge point of a punched hole on a part to be measured by a Canny edge detection algorithm;
and (4) optimizing the initial edge point by an edge detection method based on Zernike moment to obtain the punched edge point.
4. A machine vision based punch hole sizing method according to claim 1, characterized in that the calibration coefficients are determined as follows:
acquiring an image of a calibration block based on the same acquisition environment as the part to be measured; the calibration coefficient is the ratio of the size of the calibration block to the image size of the calibration block.
5. The machine-vision-based punch hole sizing method of claim 1, further comprising:
determining a plurality of external rectangles of the punched hole according to the edge points of the punched hole;
taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole;
and calculating the image distance between the centers of the two adjacent holes, and obtaining the distance between the centers of the two adjacent punched holes on the part to be measured based on the calibration coefficient between the image size and the actual size of the part to be measured.
6. The machine-vision-based punch hole sizing method of claim 1, further comprising:
determining a plurality of external rectangles of the punched hole according to the edge points of the punched hole;
taking the intersection point of the diagonal lines of the external rectangles with the smallest area in the plurality of external rectangles as the hole center of the punched hole;
based on the binary image, acquiring an edge straight line of the part to be measured through a straight line detection algorithm;
and calculating the image distance from the center of the hole to the edge straight line, and obtaining the distance between the center of the punched hole of the part to be measured and the edge of the part to be measured based on the calibration coefficient between the image size and the actual size of the part to be measured.
7. A punch hole size measurement method based on machine vision according to claim 6, characterized in that the straight line detection algorithm is Hough transform straight line detection algorithm.
8. A punch hole sizing system based on machine vision, comprising:
the image acquisition module is used for acquiring a binary image of the part to be measured;
the edge determining module is used for acquiring edge points of the punched hole on the part to be measured through an edge detection algorithm based on the binary image;
the image aperture determining module is used for obtaining the maximum aperture value and the minimum aperture value of the punched image according to the edge points of the punched hole; and
and the conversion module is used for converting the maximum image aperture value and the minimum image aperture value into the actual maximum aperture value and the actual minimum aperture value based on the calibration coefficient between the image size and the actual size of the part to be measured.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor when executing the computer program performs the steps of the machine vision based punch sizing method of any one of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of the machine-vision based punch sizing method according to any one of claims 1 to 7.
CN202011173827.4A 2020-10-28 2020-10-28 Punching size measuring method, system, equipment and medium based on machine vision Pending CN112325772A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011173827.4A CN112325772A (en) 2020-10-28 2020-10-28 Punching size measuring method, system, equipment and medium based on machine vision

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011173827.4A CN112325772A (en) 2020-10-28 2020-10-28 Punching size measuring method, system, equipment and medium based on machine vision

Publications (1)

Publication Number Publication Date
CN112325772A true CN112325772A (en) 2021-02-05

Family

ID=74297253

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011173827.4A Pending CN112325772A (en) 2020-10-28 2020-10-28 Punching size measuring method, system, equipment and medium based on machine vision

Country Status (1)

Country Link
CN (1) CN112325772A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114111622A (en) * 2021-11-30 2022-03-01 江苏沙钢集团淮钢特钢股份有限公司 Method for detecting pass depth of bar rolling based on image processing
CN115829922A (en) * 2022-09-23 2023-03-21 正泰新能科技有限公司 Method, device, equipment and medium for detecting space between battery pieces
CN117036359A (en) * 2023-10-10 2023-11-10 成都中轨轨道设备有限公司 Contact net geometric parameter measurement method based on binocular machine vision
CN117115233A (en) * 2023-10-24 2023-11-24 杭州百子尖科技股份有限公司 Dimension measurement method and device based on machine vision and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004337743A (en) * 2003-03-20 2004-12-02 Honda Motor Co Ltd Apparatus for sorting workpiece
CN106778541A (en) * 2016-11-28 2017-05-31 华中科技大学 A kind of identification in the multilayer beam China and foreign countries beam hole of view-based access control model and localization method
CN106780562A (en) * 2017-01-16 2017-05-31 哈尔滨理工大学 A kind of spindle rotation error new algorithm based on aberration diagram image procossing
CN107705297A (en) * 2017-09-18 2018-02-16 华南理工大学 A kind of Threshold segmentation detection method of flexible PCB circular hole
CN107907063A (en) * 2017-11-14 2018-04-13 湖南文理学院 A kind of the steel band punching processing detecting system and method for view-based access control model measurement
CN108876850A (en) * 2018-06-29 2018-11-23 闽江学院 A kind of pcb board punching localization method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004337743A (en) * 2003-03-20 2004-12-02 Honda Motor Co Ltd Apparatus for sorting workpiece
CN106778541A (en) * 2016-11-28 2017-05-31 华中科技大学 A kind of identification in the multilayer beam China and foreign countries beam hole of view-based access control model and localization method
CN106780562A (en) * 2017-01-16 2017-05-31 哈尔滨理工大学 A kind of spindle rotation error new algorithm based on aberration diagram image procossing
CN107705297A (en) * 2017-09-18 2018-02-16 华南理工大学 A kind of Threshold segmentation detection method of flexible PCB circular hole
CN107907063A (en) * 2017-11-14 2018-04-13 湖南文理学院 A kind of the steel band punching processing detecting system and method for view-based access control model measurement
CN108876850A (en) * 2018-06-29 2018-11-23 闽江学院 A kind of pcb board punching localization method

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114111622A (en) * 2021-11-30 2022-03-01 江苏沙钢集团淮钢特钢股份有限公司 Method for detecting pass depth of bar rolling based on image processing
CN115829922A (en) * 2022-09-23 2023-03-21 正泰新能科技有限公司 Method, device, equipment and medium for detecting space between battery pieces
CN115829922B (en) * 2022-09-23 2024-06-04 正泰新能科技股份有限公司 Method, device, equipment and medium for detecting spacing of battery pieces
CN117036359A (en) * 2023-10-10 2023-11-10 成都中轨轨道设备有限公司 Contact net geometric parameter measurement method based on binocular machine vision
CN117036359B (en) * 2023-10-10 2023-12-08 成都中轨轨道设备有限公司 Contact net geometric parameter measurement method based on binocular machine vision
CN117115233A (en) * 2023-10-24 2023-11-24 杭州百子尖科技股份有限公司 Dimension measurement method and device based on machine vision and electronic equipment
CN117115233B (en) * 2023-10-24 2024-02-06 杭州百子尖科技股份有限公司 Dimension measurement method and device based on machine vision and electronic equipment

Similar Documents

Publication Publication Date Title
CN112325772A (en) Punching size measuring method, system, equipment and medium based on machine vision
US10430951B2 (en) Method and device for straight line detection and image processing
CN109543489B (en) Positioning method and device based on two-dimensional code and storage medium
US20160203387A1 (en) Vision system and analytical method for planar surface segmentation
CN109784250B (en) Positioning method and device of automatic guide trolley
CN110211110B (en) Component size detection method and system and terminal equipment
CN110135514B (en) Workpiece classification method, device, equipment and medium
CN110148117B (en) Power equipment defect identification method and device based on power image and storage medium
CN107230212B (en) Vision-based mobile phone size measuring method and system
CN112465809A (en) Mold defect detection method based on image recognition, computer-readable storage medium and device
CN112085709A (en) Image contrast method and equipment
CN112861870A (en) Pointer instrument image correction method, system and storage medium
CN114549393B (en) Image labeling method, device, equipment and computer storage medium
CN116573366B (en) Belt deviation detection method, system, equipment and storage medium based on vision
CN112734689A (en) Gasket quality detection method, system, device and storage medium
CN110310239B (en) Image processing method for eliminating illumination influence based on characteristic value fitting
CN116862881A (en) Multi-target real-time offset detection method based on image processing
CN115511884B (en) Punching compound die surface quality detection method based on computer vision
CN114549429B (en) Depth data quality evaluation method and device based on hypergraph structure
CN116012242A (en) Camera distortion correction effect evaluation method, device, medium and equipment
CN111861997B (en) Method, system and device for detecting circular hole size of patterned plate
CN113298755B (en) Method and device for rapidly detecting ecological environment change patch based on time sequence image
CN111260723B (en) Barycenter positioning method of bar and terminal equipment
CN113250914A (en) 2D displacement measurement method, system, equipment and storage medium for cabin tower top
CN114565551A (en) Label detection method, device, equipment and computer readable storage 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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210205

RJ01 Rejection of invention patent application after publication