CN115760860A - Multi-type workpiece dimension visual measurement method based on DXF file import - Google Patents

Multi-type workpiece dimension visual measurement method based on DXF file import Download PDF

Info

Publication number
CN115760860A
CN115760860A CN202310038340.2A CN202310038340A CN115760860A CN 115760860 A CN115760860 A CN 115760860A CN 202310038340 A CN202310038340 A CN 202310038340A CN 115760860 A CN115760860 A CN 115760860A
Authority
CN
China
Prior art keywords
image
detected
workpiece
primitive
template
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.)
Granted
Application number
CN202310038340.2A
Other languages
Chinese (zh)
Other versions
CN115760860B (en
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.)
Guangdong Polytechnic Normal University
Original Assignee
Guangdong Polytechnic Normal 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 Guangdong Polytechnic Normal University filed Critical Guangdong Polytechnic Normal University
Priority to CN202310038340.2A priority Critical patent/CN115760860B/en
Publication of CN115760860A publication Critical patent/CN115760860A/en
Application granted granted Critical
Publication of CN115760860B publication Critical patent/CN115760860B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Image Analysis (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

The invention relates to the technical field of workpiece dimension measurement, and discloses a multi-type workpiece dimension visual measurement method based on DXF file import, which comprises the following steps of: s1: generating a template file; s2: acquiring an image of a workpiece to be detected; s3: preprocessing the acquired image to enhance the image characteristics; s4: carrying out template matching on the template image and the image processed in the S3; s5: identifying and positioning the primitive of the workpiece to be detected; s6: measuring a primitive to be detected of the workpiece, and judging whether a detection result meets tolerance requirements or not; compared with the prior art, the method and the device solve the problem that the existing measuring device is single in measuring object, do not need to manually select the geometric primitives to be measured in the measuring process, can realize the automatic measurement of the geometric primitives to be measured only by importing the DXF file, can effectively improve the production efficiency, reduce the production cost of enterprises, and lay a foundation for realizing intelligent manufacturing.

Description

Multi-type workpiece dimension visual measurement method based on DXF file import
Technical Field
The invention relates to the technical field of workpiece dimension measurement, in particular to a visual measurement method for the dimensions of multiple types of workpieces based on DXF file import.
Background
In the industrial manufacturing field, quality inspection of products is important, and the size of a workpiece is highly regarded by manufacturers as a key factor of product quality. The traditional workpiece primitive (straight line, circle and arc) size detection mainly depends on manual visual detection, and the manual visual detection has the limitations of high labor intensity, low detection efficiency, easy generation of human errors and the like. With the development of machine vision and image processing technology, various new detection algorithms are developed and widely applied to the field of product quality detection, so that the detection efficiency and reliability are greatly improved. However, a common primitive detection method is to use a Canny edge detection algorithm and a Hough transform algorithm in combination, and the method not only needs to perform binarization operation on the acquired image, but also needs to adjust algorithm parameters according to different types of detection objects, so that the algorithm has high calculation complexity and low robustness, and is not suitable for size measurement of various types of workpieces. In addition, the existing visual measuring instruments in the market mainly collect images through an industrial camera, select the primitives to be measured of the workpiece in a manual interaction mode, and then save the template file to further realize visual measurement.
Disclosure of Invention
The invention aims to provide a multi-type workpiece dimension visual measurement method based on DXF file import. Firstly, marking the dimension and tolerance of a workpiece graphic element to be measured by a user by using CAD software, and storing the dimension and tolerance as a DXF file; then, the vision measuring device reads the DXF file to obtain the graphic elements to be measured; and finally, acquiring an image through a camera to realize visual measurement. In the whole process, interactive operations such as manual selection and the like on the primitives to be detected in the image are not needed, and the technical problem can be effectively solved.
A multi-type workpiece dimension vision measurement method based on DXF file import comprises the following steps:
s1: and (3) generating a template file:
s11: storing the entity data of the workpiece read from the DXF file into a corresponding container, and generating a template image of the workpiece to be detected;
s12: performing quadrant division on the to-be-detected primitive in the template image according to a contour center coordinate method;
s13: sequencing the primitives to be detected in the template image according to a contour center distance method;
s14: generating a template file;
s2: acquiring an image of a workpiece to be detected;
s3: carrying out preprocessing operation on the acquired image to enhance the image characteristics;
s4: carrying out template matching on the template image and the image processed in the S3; if the matching is successful, entering S5; otherwise, returning to the S2;
s5: identifying and positioning the primitive of the workpiece to be detected:
s51: extracting the primitive to be detected in the image successfully matched with the template image in the step S4;
s52: matching the primitive to be detected with the primitive in the template file to realize the positioning of the geometric primitive to be detected;
s6: measuring a primitive to be detected of the workpiece, and judging whether a detection result meets a tolerance requirement or not; if yes, the size of the workpiece to be detected is qualified; otherwise, the size of the workpiece to be measured is unqualified.
According to an embodiment of the present invention, the quadrant division of the primitives in the template image according to the contour center coordinate method in step S12 includes the following steps:
s121: generating a minimum external positive rectangle of a workpiece to be detected in the template image, and establishing a rectangular coordinate system by taking a central point of the rectangle as a reference;
s122: coordinate information of the primitive to be detected in the rectangular coordinate system is obtained, coordinate quadrant division is carried out on the primitive to be detected, and the primitive to be detected is stored into an XML template file.
According to an embodiment of the present invention, the specific operation steps of sorting the primitives to be tested in the template image according to the contour center distance method in step S13 are as follows: and calculating the vertical distance between the primitive to be tested and the origin of coordinates of the rectangular coordinate system established in the step S121, sequencing the primitives to be tested of the same type according to the distance, and storing the sequencing result into an XML template file.
According to an embodiment of the present invention, in step S13, the method for calculating the vertical distance between the primitive to be measured and the origin of coordinates of the rectangular coordinate system established in step S121 includes: setting the coordinates of end points at two ends of a straight line in a graphic element as (x) 1 ,y 1 )、(x 2 ,y 2 ) The coordinate point of the center of the circle or the circular arc in the graphic element is (x) 3 ,y 3 ) The coordinate of the center of the rectangle is (x) 0 ,y 0 ) (ii) a The calculation of the distance between the linear graphic primitive and the coordinate point of the center of the rectangle is divided into three conditions:
(1) when the straight line segment is parallel to the x-axis of the coordinate system, the distance is D = | y 1 -y 0 |;
(2) When a straight line segment is parallel to the y-axis of the coordinate system, the distance is D = | x 1 -x 0 |;
(3) When a straight line segment is neither parallel to the x-axis nor the y-axis, assuming that the straight line equation is Ax + Bx + C =0, the distance D is calculated by establishing a perpendicular line passing through the origin of coordinates and perpendicular to the straight line segment:
Figure 628399DEST_PATH_IMAGE001
the distance between the center of the circle or the circular arc primitive and the center of the rectangle is as follows:
Figure 217643DEST_PATH_IMAGE002
according to an embodiment of the present invention, step S3 includes:
s31: carrying out graying processing on the original image by adopting a weighted average method;
s32: and adopting median filtering to suppress noise in the image after the graying processing.
According to an embodiment of the present invention, the method for template matching the template image and the image processed in S3 in step S4 is shape matching based on Hu invariant moment, matching is performed by calculating invariant moment features of the outer contour of the template image and the outer contour of the target image processed in step S3, and when the matching coefficient is smaller than a specified threshold, it indicates that the object to be measured exists in the image processed in S3.
According to an embodiment of the present invention, in step S51, the extracting the primitive to be measured in the image successfully matched with the template image in step S4 includes the following steps:
s511: extracting the profile characteristics of the workpiece to be detected by an LSD linear detection algorithm, and fitting the primitive characteristics by adopting a least square method;
s512: and (4) solving the minimum circumscribed regular rectangle of the image processed in the step (S511), obtaining the central coordinates of the rectangle and further establishing a rectangular coordinate system.
According to an embodiment of the present invention, the step S52 of matching the primitive to be tested with the primitive in the template file includes the following steps:
s521: performing quadrant division on the to-be-detected primitives extracted in the step S51 by adopting a contour center coordinate method, and then sequencing the to-be-detected primitives by adopting a contour center distance method;
s522: judging whether the pixel coordinate quadrant and the serial number obtained in the step S521 are consistent with the coordinate quadrant and the serial number in the template file or not; if yes, successfully positioning the geometric primitive to be measured and entering the step S6; otherwise, the process returns to step S521.
Compared with the prior art, the method for visually measuring the sizes of the multiple types of workpieces based on DXF file import has the following advantages:
the visual measurement method for the sizes of the multiple types of workpieces based on the DXF file import solves the problem that the existing measurement equipment is single in measurement object, does not need to manually select geometric primitives to be measured in the measurement process, can realize automatic measurement of the geometric primitives to be measured only by importing the template file, can effectively improve the production efficiency, reduces the production cost of enterprises, and lays a foundation for realizing intelligent manufacturing.
Drawings
FIG. 1 is a flow chart of a method for visual measurement of dimensions of a multi-type workpiece based on DXF file import according to the present invention;
FIG. 2 is a template image of a workpiece to be measured, wherein FIG. 2 (a) is a CAD drawing of the workpiece to be measured, and FIG. 2 (b) is a positioning effect drawing of a primitive to be measured of the workpiece;
fig. 3 is a diagram of quadrant division according to the end point coordinates of the straight line to be measured in the template image and the positions of the circle center coordinates of the circle and the arc to be measured in the rectangular coordinate system, wherein fig. 3 (a) is a quadrant diagram of the circle and the arc in the geometric primitive to be measured, and fig. 3 (b) is a quadrant diagram of the straight line in the geometric primitive to be measured;
fig. 4 is an experimental result of the measuring system matching the workpiece to be measured in the acquired image with the template image by using the shape matching method based on the Hu invariant moment, where fig. 4 (a) is the template image, and fig. 4 (b) is a matching result of the acquired image and the template image;
FIG. 5 shows the detection result of the LSD algorithm;
fig. 6 is a result graph of fitting the primitive features by using the least square method, where fig. 6 (a) is a graph of the effect of the collected image on the points at the circle and the arc after being processed in step S511, and fig. 6 (b) is a graph of the fitting effect of the least square method on the points at the circle and the arc;
FIG. 7 is a checkerboard calibration plate.
The implementation and advantages of the functions of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
In the following description, for purposes of explanation, numerous implementation details are set forth in order to provide a thorough understanding of various embodiments of the present invention. It should be understood, however, that these implementation details should not be taken to limit the invention. That is, in some embodiments of the invention, such practical details are not necessary. In addition, some conventional structures and components are shown in simplified schematic form in the drawings for the sake of simplicity.
It should be noted that all directional indicators (such as upper, lower, left and right, front and rear \8230;) in the embodiments of the present invention are only used for explaining the relative positional relationship between the components in a specific posture (as shown in the attached drawings), the motion situation, etc., and if the specific posture is changed, the directional indicator is changed accordingly.
In addition, the descriptions related to the first, the second, etc. in the present invention are only used for description purposes, do not particularly refer to an order or sequence, and do not limit the present invention, but only distinguish components or operations described in the same technical terms, and are not understood to indicate or imply relative importance or implicitly indicate the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In addition, technical solutions between the embodiments may be combined with each other, but must be based on the realization of the technical solutions by a person skilled in the art, and when the technical solutions are contradictory to each other or cannot be realized, such a combination should not be considered to exist, and is not within the protection scope of the present invention.
For a further understanding of the contents, features and effects of the present invention, reference will now be made to the following examples, which are illustrated in the accompanying drawings and described in the following detailed description:
the first embodiment is as follows:
according to the visual measurement method for the sizes of the multiple types of workpieces imported based on the DXF file, before detection, a user marks the primitive sizes and the tolerances of the workpieces to be measured by using CAD software and stores the primitive sizes and the tolerances as the DXF file; when a workpiece is detected, a vision measuring device reads a DXF file saved before detection to obtain a graphic element to be measured; and then, acquiring an image through a camera, and comparing the primitives to be detected in the acquired image with the primitives in the DXF file to realize visual measurement. The whole process does not need to manually select the primitives to be detected in the image and other interactive operations, and the method is simple to operate and high in detection efficiency. The invention discloses a DXF file import-based multi-type workpiece dimension visual measurement method, which comprises the following steps of:
s1: and (3) generating a template file:
s11: storing the entity data of the workpiece read from the DXF file into a corresponding container, and generating a template image of the workpiece to be detected;
the entity data of the workpiece read from the DXF file comprise the starting point coordinates, the end point coordinates and the length of a straight line segment, the central point coordinates and the radius of a circle and a circular arc and the like; by reading the group value and the group code of the geometric feature information of the workpiece contained in the DXF file, the coordinate information and the size information of the workpiece to be detected can be obtained, and a template image of the workpiece to be detected is generated.
S12: performing quadrant division on the primitive to be detected in the template image according to a contour center coordinate method:
s121: generating a minimum external positive rectangle of a workpiece to be detected in the template image, and establishing a rectangular coordinate system by taking a central point of the rectangle as a reference;
s122: acquiring coordinate information of a to-be-detected pixel in a rectangular coordinate system, performing coordinate quadrant division on the to-be-detected pixel, and storing the to-be-detected pixel into an XML template file; the quadrant division method comprises the following steps: performing quadrant division according to the end point coordinates of the straight line to be measured in the template image and the positions of the circle center coordinates of the circle to be measured and the circular arc in the rectangular coordinate system; the two end points of the straight line primitive may be located in different quadrants or may be located in the same quadrant.
S13: sequencing the primitives to be detected in the template image according to a contour center distance method; the specific operation steps are as follows: and calculating the vertical distance between the primitive to be tested and the origin of coordinates of the rectangular coordinate system established in the step S121, sorting the primitives to be tested of the same type according to the distance, and storing the sorting result into an XML template file. Wherein:
in practical application, the primitives to be tested comprise one or more of straight lines, circular arcs and circles, one or more primitives are provided for each primitive, when the primitives are sorted, the primitives of the same type are sorted according to the vertical distance between the primitives and the origin of coordinates of the rectangular coordinate system, and then the sorting result is stored into an XML template file; for example, if n straight line primitives, n > 1, m circular primitives, m > 1, b circular primitives, and b > 1 are calculated, the vertical distance between each straight line primitive and the origin of coordinates of the rectangular coordinate system is calculated, then the straight line primitives are sorted according to the distance, the vertical distance between the center of circle of each circular primitive and the origin of coordinates is calculated, then the circular primitives are sorted according to the distance, and finally the sorting results of all the primitives are stored in an XML template file.
The method for calculating the vertical distance between the primitive to be measured and the origin of coordinates of the rectangular coordinate system comprises the following steps: setting the coordinates of end points at two ends of a straight line in a graphic element as (x) 1 ,y 1 )、(x 2 ,y 2 ) The coordinate point of the center of the circle or the circular arc in the graphic element is (x) 3 ,y 3 ) The coordinate of the center of the rectangle is (x) 0 ,y 0 ) (ii) a The calculation of the distance between the linear graphic primitive and the coordinate point of the center of the rectangle is divided into three conditions:
(1) when the straight line segment is parallel to the x-axis of the coordinate system, the distance is D = | y 1 -y 0 |;
(2) When the straight line segment is parallel to the y-axis of the coordinate system, the distance is D = | x 1 -x 0 |;
(3) When a straight line segment is neither parallel to the x-axis nor the y-axis, assuming that the straight line equation is Ax + Bx + C =0, the distance D is calculated by establishing a perpendicular line passing through the origin of coordinates and perpendicular to the straight line segment:
Figure 935064DEST_PATH_IMAGE001
the distance between the center of the circle or the circular arc primitive and the center of the rectangle is as follows:
Figure 2377DEST_PATH_IMAGE002
s14: and generating a template file.
S2: acquiring an image of a workpiece to be detected; the system for completing image acquisition comprises an industrial camera, a lens and a light source, wherein:
the precision of the industrial camera meets the following requirements:
Figure 754432DEST_PATH_IMAGE003
wherein, the first and the second end of the pipe are connected with each other,
Figure 248999DEST_PATH_IMAGE004
is the maximum length in the field of view of the camera in the x direction,
Figure 453715DEST_PATH_IMAGE005
is the maximum length in the field of view of the camera in the y-direction,
Figure 590298DEST_PATH_IMAGE006
detecting the precision for the camera system;
the lens magnification satisfies:
Figure 462439DEST_PATH_IMAGE007
wherein, in the process,lthe size of the target surface of the camera is v, and the size of the field of view of the camera is v;
the focal length of the lens meets the following conditions:
Figure 393486DEST_PATH_IMAGE008
wherein, L is the working distance of the camera, and f is the focal length of the lens.
S3: pre-processing the acquired image to enhance image features:
s31: carrying out graying processing on the original image by adopting a weighted average method;
the image collected by the industrial camera is an R, G and B three-channel color image, and the image graying is to convert the three-channel image into a single-channel image. The size measurement of the workpiece is irrelevant to the color of the picture, and each channel of the color image respectively occupies 8 bit storage space, so that the gray processing of the color image can reduce the data volume of the image and improve the arithmetic operation speed. The method for visually measuring the sizes of the multiple types of workpieces imported based on the DXF file adopts a weighted average method to perform graying processing on an original image, namely, R, G and B are respectively endowed with different weights according to different sensitivities of human eyes to RGB colors, and a calculation formula is as follows:
Figure 351078DEST_PATH_IMAGE009
s32: adopting median filtering to inhibit noise in the image after graying processing;
the image filtering operation is mainly used for inhibiting noise in an image and facilitating extraction of image features, median filtering is a nonlinear filtering algorithm based on a sequencing statistics theory, the basic principle is that the median of all pixels in the pixel field replaces the original pixel value, the median filtering algorithm is sensitive to the abnormal pixel value, and pulse noise and salt and pepper noise in the image can be effectively removed; as salt and pepper noise is easy to generate in the image acquisition process, the method selects median filtering to inhibit noise interference based on the DXF file imported multi-type workpiece dimension visual measurement method.
S4: carrying out template matching on the template image and the image processed in the step S3; if the matching is successful, entering S5; otherwise, returning to the S2;
in actual measurement, a problem that a non-target object is included in a workpiece to be measured may occur, and therefore, a target object in an image needs to be identified so as to perform measurement. Hu invariant moment is a method for realizing object matching and recognition through moment features, wherein the moment features are mainly represented as geometrical features of an image region and have the characteristics of translation, scaling and rotation invariance, so that the Hu invariant moment is also called as invariant moment.
In step S4, the template matching method for matching the template image with the image processed in step S3 is based on Hu invariant moment shape matching, and the contour of the template image is matched with the invariant moment feature of the contour of the target image processed in step S3 by calculating the invariant moment feature, and when the matching coefficient is smaller than a specified threshold, it indicates that the object to be measured exists in the image processed in step S3.
S5: primitive identification and positioning of the workpiece to be detected:
s51: extracting the primitive to be detected in the image successfully matched with the template image in the step S4:
s511: extracting the profile characteristics of the workpiece to be detected through an LSD (linear stress detection) algorithm, and fitting the primitive characteristics by adopting a least square method;
the basic idea of the LSD algorithm is to traverse image pixels, calculate the gradient size and direction of each pixel, further form pixel direction fields (level line fields), then merge and expand the pixels with strong correlation into line support regions (line support regions) according to the region growing theory, finally verify the straight line corresponding to each line support region, and screen out the straight line profile with the highest matching degree; the end points and the line segment widths of the straight line segments can be obtained through the processing of the LSD straight line detection algorithm, the LSD algorithm has accurate recognition effect on the straight line profile, and the circle and arc primitives in the image are divided into a plurality of straight line segments. The core idea of least squares is to fit a straight or curved line approximating these data points, based on a given set of data points, and to minimize the deviation of the fit results.
S512: and (4) solving the minimum circumscribed regular rectangle of the image processed in the step (S511), obtaining the center coordinates of the rectangle and further establishing a rectangular coordinate system.
S52: matching the primitive to be detected with the primitive in the template file to realize the positioning of the geometric primitive to be detected:
s521: performing quadrant division on the to-be-detected primitives extracted in the step S51 by adopting a contour center coordinate method, and then sequencing the primitives by adopting a contour center distance method;
s522: judging whether the pixel coordinate quadrant and the serial number obtained in the step S521 are consistent with the coordinate quadrant and the serial number in the template file; if yes, successfully positioning the geometric primitive to be measured and entering the step S6; otherwise, the process returns to step S521.
S6: measuring the primitive of the workpiece to be detected, and judging whether the detection result meets the tolerance requirement; if so, the size of the workpiece to be detected is qualified; otherwise, the size of the workpiece to be measured is unqualified. The specific operation method comprises the following steps:
converting all pixel sizes into corresponding actual sizes L according to a scale coefficient K calibrated in advance; the calculation formula is as follows:
Figure 25773DEST_PATH_IMAGE010
wherein, in the step (A),lthe number of pixels.
Example two:
the following method for visually measuring the dimensions of a specific workpiece by using the DXF-file import-based multi-type workpiece according to the present invention is as follows:
s1: and (3) generating a template file:
s11: storing the entity data of the workpiece read from the DXF file into a corresponding container, and generating a template image of the workpiece to be detected;
fig. 2 (a) is a CAD drawing of a workpiece to be measured read from a DXF file, where the dimension information is an interactive mark of a user on a feature to be measured, such as a circular arc with a radius of 5 indicating that the user needs to measure the circular arc. Fig. 2 (b) is a feature mapping map obtained from the dimensional information of fig. 2 (a), and the light gray line segments, circles, and circular arcs in fig. 2 (b) are target measurement features.
S12: performing quadrant division on the primitives in the template image according to a contour center coordinate method:
s121: generating a minimum external right rectangle of a workpiece to be detected in the template image, and establishing a rectangular coordinate system by taking a central point of the rectangle as a reference;
s122: and acquiring coordinate information of the to-be-detected pixel in the rectangular coordinate system, performing coordinate quadrant division on the to-be-detected pixel, and storing the to-be-detected pixel into an XML template file.
Performing quadrant division according to the end point coordinates of the straight line to be measured in the template image and the positions of the circle center coordinates of the circle to be measured and the circular arc in the rectangular coordinate system; the result of quadrant division is shown in fig. 3 (a) (b), where the circle and the circular arc are located in the second quadrant and the first quadrant, respectively, the end point of the straight line 1 is located in the third quadrant and the fourth quadrant, and the end point of the straight line 2 is located in the first quadrant and the fourth quadrant.
S13: sorting the primitives in the template image according to a contour center distance method; the specific operation steps are as follows: and calculating the vertical distance between the primitive to be tested and the origin of coordinates of the rectangular coordinate system established in the step S121, sorting the primitives to be tested of the same type according to the distance, and storing the sorting result into an XML template file.
In order to distinguish geometric primitives of which coordinate positions in a light gray circle are in the same quadrant as in fig. 3 (b), the DXF file import-based multi-type workpiece dimension visual measurement method of the present invention provides a contour center distance method, that is, geometric primitives of the same type are sorted according to distance by calculating the distance between the geometric primitive to be measured and the origin of coordinates, and the sorting result and the obtained primitive coordinate quadrant result are respectively stored in an XML template file. Setting the coordinates of end points at two ends of a straight line in a graphic element as (x) 1 ,y 1 )、(x 2 ,y 2 ) The circle center coordinate point of the circle or the circular arc in the graphic element is (x) 3 ,y 3 ) The coordinate of the center of the rectangle is (x) 0 ,y 0 ) Wherein:
the straight line 1 is parallel to the x axis of the coordinate system, and the perpendicular distance between the straight line 1 and the origin of the coordinates is D = | y 1-y 0|;
the straight line 2 is parallel to the y axis of the coordinate system, and the perpendicular distance between the straight line and the origin of the coordinates is D = | x 1-x 0|;
the distance between the center of the circle or the circular arc primitive and the center of the rectangle is as follows:
Figure 486841DEST_PATH_IMAGE011
s14: and generating a template file.
S2: acquiring an image of a workpiece to be detected;
taking the dimension of a workpiece object to be measured within 100mm as an example, and the required detection precision is 0.1mm; the minimum pixel value requirement is calculated as:
the measurement system mainly faces to a workpiece object with the size of 100mm multiplied by 100mm, the actual detection precision is required to be less than 0.1mm, and the camera resolution is calculated according to the formula (7) and needs to be achieved:
Figure 119948DEST_PATH_IMAGE012
=
Figure 299256DEST_PATH_IMAGE013
=1000000;
in the formula for the resolution of the camera,
Figure 777642DEST_PATH_IMAGE014
is the maximum length in the field of view of the camera in the x direction,
Figure 624376DEST_PATH_IMAGE015
is the maximum length within the field of view of the camera in the y-direction,
Figure 873788DEST_PATH_IMAGE006
the detection precision of the industrial camera system is improved. In order to achieve greater contrast between the workpiece features and the actual background features and thereby better identify the workpiece features, the industrial camera is selected from a GigE black and white industrial camera HT-GE130M of Van der Waals, which has 130 ten thousand pixels, a sensor type of 1/2' CMOS, a pixel size of 5.2 μ M by 5.2 μ M, a continuous acquisition mode (ERS) frame rate of 30FPS, a resolution of 1280 x 1024, and a camera target surface size of 6.4mm by 4.8mm.
When the image of the workpiece to be detected is acquired, the lens is mainly used for acting an imaging target on a photosensitive surface of the image sensor. The lens magnification can be calculated according to the pixel size of the camera and the size of the target surface of the camera through a formula:
Figure 805971DEST_PATH_IMAGE016
=
Figure 822469DEST_PATH_IMAGE017
=0.064,land v is the size of the camera target surface and the size of the camera view field.
According to the actual measurement requirement, the minimum working distance between the workpiece and the lens is set to be 150cm, and the focal length of the lens is calculated as follows:
Figure 523709DEST_PATH_IMAGE018
=
Figure 498618DEST_PATH_IMAGE019
=9.026;
in the focal length calculation formula, L is the working distance of the camera, and f is the focal length of the lens. Based on the data, the Mingyiwei HS-2812 is selected as a system lens, and the focal length of the lens is 12mm, so that the focal length requirement of the industrial camera lens can be met.
S3: pre-processing the acquired image to enhance image features:
s31: carrying out graying processing on the original image by adopting a weighted average method;
the images collected by the industrial camera are R, G and B three-channel color images, and the image graying is to convert the three-channel images into single-channel images. The size measurement of the workpiece is irrelevant to the color of the picture, and each channel of the color image respectively occupies 8 bit storage space, so that the gray processing of the color image can reduce the data volume of the image and improve the arithmetic operation speed. The method for visually measuring the sizes of the multiple types of workpieces based on DXF file import adopts a weighted average method to perform graying processing on an original image, namely, different weights are respectively given to R, G and B according to different sensitivities of human eyes to RGB colors, and a calculation formula is as follows:
Figure 652519DEST_PATH_IMAGE009
s32: adopting median filtering to inhibit noise in the image after graying processing;
the image filtering operation is mainly used for inhibiting noise in an image and facilitating extraction of image features, and the median filtering is a nonlinear filtering algorithm based on a sequencing statistic theory, the basic principle of the method is that the median of all pixels in the pixel field is used for replacing an original pixel value, and the median filtering algorithm is sensitive to an abnormal pixel value and can effectively remove impulse noise and salt and pepper noise in the image; as salt and pepper noise is easy to generate in the image acquisition process, the method selects median filtering to inhibit noise interference based on the DXF file imported multi-type workpiece dimension visual measurement method.
S4: carrying out template matching on the template image and the image processed in the S3; if the matching is successful, entering S5; otherwise, returning to S2.
In actual measurement, a non-target object may be included in the workpiece to be measured, and therefore, a target object in the image needs to be identified so as to perform measurement. Hu invariant moment is a method for realizing object matching and recognition through moment features, wherein the moment features are mainly represented as geometrical features of an image region and have the characteristics of translation, scaling and rotation invariance, so that the Hu invariant moment is also called as invariant moment.
In step S4, a method of performing template matching on the template image and the image processed in S3 is based on Hu invariant moment shape matching, the outer contour of the template image and the outer contour of the target image processed in S3 are matched by calculating invariant moment features, and when a matching coefficient is smaller than a specified threshold, it indicates that an object to be measured exists in the image processed in S3; fig. 4 is an experimental result of the measurement system matching the workpiece to be measured in the acquired image with the template image by using a shape matching method based on the Hu invariant moment.
S5: primitive identification and positioning of the workpiece to be detected:
s51: extracting the primitive to be detected in the image successfully matched with the template image in the step S4:
s511: extracting the profile characteristics of the workpiece to be detected through an LSD (linear stress detection) algorithm, and fitting the primitive characteristics by adopting a least square method;
the LSD algorithm has the basic idea that image pixels are traversed, the gradient size and the gradient direction of each pixel are calculated, pixel direction fields (level line fields) are further formed, then the pixels with strong correlation are merged and expanded into line support regions (line support regions) according to a region growing theory, finally, a straight line corresponding to each line support region is verified, and a straight line profile with the highest matching degree is screened out; the end points and line segment widths of the straight line segments can be obtained by processing with the LSD straight line detection algorithm, and fig. 5 shows the detection result of the LSD algorithm. The LSD algorithm has accurate recognition effect on the straight line outline, and the circle and circular arc primitives in the image are divided into a plurality of straight line segments.
The core idea of the least square method is to fit a straight line or a curve approximating these data points according to a given set of data points and minimize the deviation of the fitting result; the fitting results are shown in fig. 6.
S512: obtaining the minimum external right rectangle of the image processed in the step S511, obtaining the center coordinates of the rectangle and further establishing a rectangular coordinate system;
s52: matching the primitive to be detected with the primitive in the template file to realize the positioning of the geometric primitive to be detected:
s521: performing quadrant division on the to-be-detected pixels extracted in the step S51 by adopting a contour center coordinate method, and then sequencing the pixels by adopting a contour center distance method;
s522: judging whether the pixel coordinate quadrant and the serial number obtained in the step S521 are consistent with the coordinate quadrant and the serial number in the template file; if yes, successfully positioning the geometric primitive to be measured and entering the step S6; otherwise, the process returns to step S521.
S6: measuring the primitive of the workpiece to be detected, and judging whether the detection result meets the tolerance requirement; if so, the size of the workpiece to be detected is qualified; otherwise, the size of the workpiece to be measured is unqualified.
The embodiment adopts a checkerboard calibration board as shown in fig. 7 to perform system calibration work. Firstly, mounting an industrial camera at a fixed position, and collecting a plurality of calibration plate pictures at different positions; then, acquiring the pixel distance of the calibration plate in the X direction and the Y direction and calculating the average value of the pixel distances; finally, the passing formula
Figure 738286DEST_PATH_IMAGE010
And calculating a conversion relation K between the pixel point distance and the actual physical size.
The present invention is not limited to the above preferred embodiments, and any modification, equivalent replacement or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (8)

1. A visual measurement method for the sizes of multiple types of workpieces based on DXF file import is characterized by comprising the following steps:
s1: and (3) generating a template file:
s11: storing the entity data of the workpiece read from the DXF file into a corresponding container, and generating a template image of the workpiece to be detected;
s12: performing quadrant division on the to-be-detected primitive in the template image according to a contour center coordinate method;
s13: sequencing the primitives to be detected in the template image according to a contour center distance method;
s14: generating a template file;
s2: acquiring an image of a workpiece to be detected;
s3: carrying out preprocessing operation on the acquired image to enhance the image characteristics;
s4: carrying out template matching on the template image and the image processed in the S3; if the matching is successful, entering S5; otherwise, returning to the S2;
s5: identifying and positioning the primitive of the workpiece to be detected:
s51: extracting the primitive to be detected in the image successfully matched with the template image in the step S4;
s52: matching the primitive to be detected with the primitive in the template file to realize the positioning of the geometric primitive to be detected;
s6: measuring a primitive to be detected of the workpiece, and judging whether a detection result meets tolerance requirements or not; if yes, the size of the workpiece to be detected is qualified; otherwise, the size of the workpiece to be measured is unqualified.
2. The DXF file import-based visual measurement method for dimensions of a plurality of types of workpieces of claim 1, wherein the quadrant division of the primitives in the template image according to the contour center coordinate method in step S12 comprises the steps of:
s121: generating a minimum external positive rectangle of a workpiece to be detected in the template image, and establishing a rectangular coordinate system by taking a central point of the rectangle as a reference;
s122: and acquiring coordinate information of the to-be-detected pixel in the rectangular coordinate system, performing coordinate quadrant division on the to-be-detected pixel, and storing the to-be-detected pixel into an XML template file.
3. The DXF file import-based visual measurement method for sizes of multiple types of workpieces of claim 2, wherein the step S13 of sorting the primitives to be measured in the template image according to the contour center distance method comprises the following steps: and calculating the vertical distance between the primitive to be tested and the origin of coordinates of the rectangular coordinate system established in the step S121, sequencing the primitives to be tested of the same type according to the distance, and storing the sequencing result into an XML template file.
4. The method of claim 3, wherein in step S13, the step of calculating the vertical distance between the primitive to be measured and the origin of coordinates of the rectangular coordinate system established in step S121 comprises: setting the coordinates of end points at two ends of a straight line in a graphic element as (x) 1 ,y 1 )、(x 2 ,y 2 ) The circle center coordinate point of the circle or the circular arc in the graphic element is (x) 3 ,y 3 ) The coordinate of the center of the rectangle is (x) 0 ,y 0 ) (ii) a The calculation of the distance between the linear graphic primitive and the coordinate point of the center of the rectangle is divided into three conditions:
(1) when the straight line segment is parallel to the x-axis of the coordinate system, the distance is D = | y 1 -y 0 |;
(2) When a straight line segment is parallel to the y-axis of the coordinate system, the distance is D = | x 1 -x 0 |;
(3) When a straight line segment is neither parallel to the x-axis nor the y-axis, assuming that the straight line equation is Ax + Bx + C =0, the distance D is calculated by establishing a perpendicular line passing through the origin of coordinates and perpendicular to the straight line segment:
Figure 468120DEST_PATH_IMAGE001
the distance between the center of the circle or the circular arc primitive and the center of the rectangle is as follows:
Figure 207406DEST_PATH_IMAGE002
5. the DXF file import-based multi-type workpiece dimension visual measurement method of claim 1, wherein step S3 comprises:
s31: carrying out graying processing on the original image by adopting a weighted average method;
s32: and adopting median filtering to suppress noise in the image after the graying processing.
6. The DXF file import-based multi-type workpiece dimension vision measuring method of claim 1, wherein the template matching of the template image and the S3 processed image in step S4 is based on Hu invariant moment shape matching, and the matching is performed by calculating invariant moment features of the outer contour of the template image and the outer contour of the target image processed in step S3, and when the matching coefficient is smaller than a predetermined threshold, it indicates that the object to be measured exists in the S3 processed image.
7. The DXF file import-based visual measurement method of multi-type workpiece dimensions according to claim 1, wherein the step S51 of extracting the primitives to be measured from the image successfully matched with the template image in step S4 comprises the steps of:
s511: extracting the profile characteristics of the workpiece to be detected by an LSD linear detection algorithm, and fitting the primitive characteristics by adopting a least square method;
s512: and (4) solving the minimum circumscribed regular rectangle of the image processed in the step (S511), obtaining the center coordinates of the rectangle and further establishing a rectangular coordinate system.
8. The DXF file import-based visual measurement method of multi-type workpiece dimensions of claim 1, wherein the step S52 of matching primitives to be tested with primitives in the template file comprises the steps of:
s521: performing quadrant division on the to-be-detected pixels extracted in the step S51 by adopting a contour center coordinate method, and then sequencing the to-be-detected pixels by adopting a contour center distance method;
s522: judging whether the pixel coordinate quadrant and the serial number obtained in the step S521 are consistent with the coordinate quadrant and the serial number in the template file; if yes, successfully positioning the geometric primitive to be measured and entering the step S6; otherwise, the process returns to step S521.
CN202310038340.2A 2023-01-05 2023-01-05 Multi-type workpiece dimension visual measurement method based on DXF file import Active CN115760860B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310038340.2A CN115760860B (en) 2023-01-05 2023-01-05 Multi-type workpiece dimension visual measurement method based on DXF file import

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310038340.2A CN115760860B (en) 2023-01-05 2023-01-05 Multi-type workpiece dimension visual measurement method based on DXF file import

Publications (2)

Publication Number Publication Date
CN115760860A true CN115760860A (en) 2023-03-07
CN115760860B CN115760860B (en) 2023-04-11

Family

ID=85348917

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310038340.2A Active CN115760860B (en) 2023-01-05 2023-01-05 Multi-type workpiece dimension visual measurement method based on DXF file import

Country Status (1)

Country Link
CN (1) CN115760860B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118010751A (en) * 2024-04-08 2024-05-10 杭州汇萃智能科技有限公司 Machine vision detection method and system for workpiece defect detection

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2000978A2 (en) * 2007-06-05 2008-12-10 heko Tech GmbH Method for measuring a template
CN105825175A (en) * 2016-03-11 2016-08-03 上海弼智仿生高科技有限公司 Generation method for industrial vision detection scheme and industrial vision detection method
US20160371855A1 (en) * 2015-06-19 2016-12-22 Dejan Jovanovic Image based measurement system
CN107356232A (en) * 2017-07-26 2017-11-17 广东飞新达智能设备股份有限公司 A kind of vision detection system image processing method
CN111862037A (en) * 2020-07-17 2020-10-30 华中科技大学无锡研究院 Method and system for detecting geometric characteristics of precision hole type part based on machine vision
CN112686920A (en) * 2020-12-31 2021-04-20 天津理工大学 Visual measurement method and system for geometric dimension parameters of circular part
CN113689415A (en) * 2021-08-30 2021-11-23 安徽工业大学 Steel pipe wall thickness online detection method based on machine vision
CN114549408A (en) * 2022-01-12 2022-05-27 河北科技大学 Position size comparison method based on graphic image

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2000978A2 (en) * 2007-06-05 2008-12-10 heko Tech GmbH Method for measuring a template
US20160371855A1 (en) * 2015-06-19 2016-12-22 Dejan Jovanovic Image based measurement system
CN105825175A (en) * 2016-03-11 2016-08-03 上海弼智仿生高科技有限公司 Generation method for industrial vision detection scheme and industrial vision detection method
CN107356232A (en) * 2017-07-26 2017-11-17 广东飞新达智能设备股份有限公司 A kind of vision detection system image processing method
CN111862037A (en) * 2020-07-17 2020-10-30 华中科技大学无锡研究院 Method and system for detecting geometric characteristics of precision hole type part based on machine vision
CN112686920A (en) * 2020-12-31 2021-04-20 天津理工大学 Visual measurement method and system for geometric dimension parameters of circular part
CN113689415A (en) * 2021-08-30 2021-11-23 安徽工业大学 Steel pipe wall thickness online detection method based on machine vision
CN114549408A (en) * 2022-01-12 2022-05-27 河北科技大学 Position size comparison method based on graphic image

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
ALEJANDRO HERNANDEZ ET AL.: "A Machine Vision Framework for Autonomous Inspection of Drilled Holes in CFRP Panels" *
王伟: "铁塔构件制孔位置尺寸视觉检测系统研发" *
贺帅儒: "基于DXF文件指导的类板类零件特定尺寸的视觉测量方法研究" *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118010751A (en) * 2024-04-08 2024-05-10 杭州汇萃智能科技有限公司 Machine vision detection method and system for workpiece defect detection

Also Published As

Publication number Publication date
CN115760860B (en) 2023-04-11

Similar Documents

Publication Publication Date Title
CN112508826B (en) Printed matter defect detection method
CN110189314B (en) Automobile instrument panel image positioning method based on machine vision
CN103345755B (en) A kind of Chessboard angular point sub-pixel extraction based on Harris operator
CN107609451A (en) A kind of high-precision vision localization method and system based on Quick Response Code
CN106469448B (en) Automated industrial inspection with 3D vision
CN112613429B (en) Pointer type instrument reading method suitable for multi-view images based on machine vision
CN109558871B (en) Pointer instrument reading identification method and device
CN111368906B (en) Pointer type oil level meter reading identification method based on deep learning
CN108007388A (en) A kind of turntable angle high precision online measuring method based on machine vision
CN110111387B (en) Dial plate characteristic-based pointer meter positioning and reading method
CN105894521A (en) Sub-pixel edge detection method based on Gaussian fitting
CN113256729A (en) External parameter calibration method, device, equipment and storage medium for laser radar and camera
CN115760860B (en) Multi-type workpiece dimension visual measurement method based on DXF file import
CN111222507A (en) Automatic identification method of digital meter reading and computer readable storage medium
CN114005108A (en) Pointer instrument degree identification method based on coordinate transformation
CN115512381A (en) Text recognition method, text recognition device, text recognition equipment, storage medium and working machine
CN107230212B (en) Vision-based mobile phone size measuring method and system
CN117314986A (en) Unmanned aerial vehicle cross-mode power distribution equipment inspection image registration method based on semantic segmentation
CN116880353A (en) Machine tool setting method based on two-point gap
CN116596987A (en) Workpiece three-dimensional size high-precision measurement method based on binocular vision
CN116597016A (en) Optical fiber endoscope image calibration method
CN114998571B (en) Image processing and color detection method based on fixed-size markers
CN113554688B (en) O-shaped sealing ring size measurement method based on monocular vision
CN113591875B (en) High-precision pointer type instrument identification method
CN115471537A (en) Monocular camera-based moving target distance and height measuring method

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
GR01 Patent grant
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20230307

Assignee: HONGDA MACHINERY MANUFACTURING (HEYUAN) Co.,Ltd.

Assignor: GUANGDONG POLYTECHNIC NORMAL University

Contract record no.: X2024980002156

Denomination of invention: A Visual Measurement Method for Multi type Workpiece Dimensions Based on DXF File Import

Granted publication date: 20230411

License type: Common License

Record date: 20240222