Component Edge Detection Method Based on Matrix Color Point Recognition
By setting matrix color points in the camera, taking images from different focal lengths and identifying edge points, the problems of inconvenient operation and high light intensity in the prior art are solved, and automated measurement of component size and speed improvement are achieved.
Patent Information
- Application Number
- CN202210836492.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-15
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2042-07-15
AI Technical Summary
When existing machines visually measure the size of steel or concrete components, they are inconvenient to operate, have high requirements for light intensity, and have large amounts of image analysis and calculation, so they cannot realize automated recording.
The matrix color points are set in the camera to take two images at different focal lengths, and the matrix color points are identified by the processor and edge points are calculated to form component contour lines, reducing the lighting intensity requirements and reducing the amount of image analysis and calculation.
Automatic measurement of component size is realized, reducing the lighting intensity requirements and greatly improving the measurement speed.
Smart Images

Figure CN115147388B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a machine vision measurement method, and particularly to a component edge detection method based on matrix color point recognition. Background Art
[0002] In construction engineering, the measurement of the dimensions of steel components or concrete components is often involved. In the past, manual measurement was mostly carried out using traditional measuring tapes, total stations and other equipment. The efficiency of this measurement method is relatively low, and automatic recording of measurement data cannot be formed, and manual recording must be used.
[0003] Using machine vision to measure the structural dimensions is a new automated measurement method. However, at present, most machine vision measurements require a standard scale or a target to be placed near the structure to be measured as a reference object in order to identify the actual dimensions of the structure to be measured. This method also has the problem of inconvenient operation. And most of this method detects edges by recognizing the grayscale value or RGB value of the structure to be measured, which not only has high requirements for the light intensity, but also has a relatively large amount of calculation for image analysis. Summary of the Invention
[0004] In view of the problems of inconvenient operation, high requirements for light intensity, and large amount of calculation for image analysis existing in the existing use of machine vision for structural dimension measurement, the present invention provides a component edge detection method based on matrix color point recognition.
[0005] To solve the above technical problems, the present invention includes the following technical solutions:
[0006] A component edge detection method based on matrix color point recognition, comprising:
[0007] Step 1: Establish a standard coordinate system for the matrix color points of the camera. The matrix color points are built into the camera and are located on the path of light to the photosensitive component. The matrix color points are m rows and n columns, and the row and column spacings are both d. The standard coordinate system marks the point (1,1) at the upper left corner of the matrix color points as the origin O, the point (1,n) at the upper right corner as the x-axis control point K1, and the point (m,1) at the lower left corner as the y-axis control point K2. The points of the matrix color points form a two-dimensional array S 1 ; the standard coordinate values of the points form a two-dimensional array T, T ij =(T ijx ,T ijy )=((j - 1)d, (i - 1)d), where i = 1, 2,..., m, j = i = 1, 2,..., n;
[0008] Step 2: Obtain a first image of the component to be measured through the camera, and measure the focal length x1 of the lens at this moment through the displacement sensor built into the camera.
[0009] Step 3: Adjust the lens focal length to capture the second image of the component to be measured, and measure the focal length x2 of the lens at this moment through the displacement sensor built in the camera;
[0010] Step 4: The processor respectively identifies the first image and the second image as pixel coordinates, and based on the RGB values, identifies the pixel coordinates (X, Y) of the visible matrix color points in the first image and the second image, and converts the pixel coordinates (X, Y) of the visible matrix color points into standard coordinates (MX kl , MY kl ), matches the standard coordinates (MX kl , MY kl ) with the elements in the two-dimensional array T to find the corresponding points, and forms a two-dimensional array S 2 ;
[0011] Step 5: According to the two-dimensional array S 1 , S 2 , obtain the two-dimensional array S 3 composed of the points of the matrix color points overlapping with the component to be measured. Take the points adjacent to the elements in S 3 in S 2 as the edge points, connect the edge points together to form the contour line of the component to be measured, and record the edge points as
[0012] Step 6: According to the contour line of the component to be measured, calculate the value Z1 of the characteristic length of the component to be measured in the first image in the standard coordinate system, calculate the value Z2 of the corresponding characteristic length of the component to be measured in the second image in the standard coordinate system, then calculate the actual characteristic length Z of the component to be measured, and convert the standard coordinates T of the edge points of the component to be measured ij into actual coordinates W ij ; The characteristic length of the component to be measured is the width, height or perimeter of the component to be measured; where
[0013]
[0014] Furthermore, in Step 4, the conversion of the pixel coordinates (X, Y) of the visible matrix color points into standard coordinates (MX kl , MY kl ) includes the following steps:
[0015] A1. Establish an image pixel coordinate system, with the first pixel point in the upper left corner of the image as the origin, the pixel point in the upper right corner as the x-axis control point, and the pixel point in the lower left corner as the y-axis control point;
[0016] A2. Identify the matrix color points according to the RGB values, where the matrix color points in the upper left corner, upper right corner, and lower left corner are the origin O and the control points K1 and K2 in the standard coordinate system respectively, and the pixel coordinates are (X O , Y O ), (X K1 , Y K1 ), (X K2 , Y K2 );
[0017] A3. The pixel coordinates of the matrix color points identified by the processor. The pixel coordinates of any point of the matrix color point are denoted as (X kl , Y kl ), and convert it to (MX kl , MY kl ), satisfying:
[0018]
[0019] Further, when a matrix color point is displayed as multiple adjacent pixel points, take the coordinates of the pixel point at the center or near the center as the pixel coordinates of the matrix color point.
[0020] Further, the RGB values of the color points in the upper left corner, upper right corner, and lower left corner of the matrix color point are (255, 255, 0), (0, 255, 0), (0, 255, 255) respectively, and the RGB values of other color points are (255, 0, 0).
[0021] Further, in step four, the determination rule for matching the standard coordinates (MX kl , MY kl ) with the elements in the two-dimensional array T is:
[0022] When |MX kl - T ijx | ≤ Δd, and |MY kl - T ijy | ≤ Δd, it is determined that the two match, where Δd is a preset value, and Δd << d.
[0023] Further, Δd = 0.1d.
[0024] Further, in step five, the determination of the edge points includes the following method:
[0025] B1. Assign 1 to the matrix color points at the positions in the two-dimensional array S 2 , and assign 0 to the matrix color points at the positions in the two-dimensional array S 3 , to obtain the assigned two-dimensional array
[0026] B2. For the two-dimensional array The row vectors are subtracted from the adjacent row vectors upward and downward respectively, and the column vectors are subtracted from the adjacent column vectors leftward and rightward respectively. The points with a value of -1 are recorded as index points, and all the index points form an index vector J. The index points in the index vector J are all edge points.
[0027] Since the present invention adopts the above technical solutions, compared with the prior art, it has the following advantages and positive effects: The component edge detection method based on matrix color point recognition provided by the present invention sets matrix color points in the camera, then takes two images in which the matrix color points overlap with the component image at different focal lengths, and then uses the processor to perform pixel recognition and identify the control points according to the matrix color points, find out the matrix color points that do not overlap with the component, so as to obtain the matrix color points that overlap with the component, and then find out the edge points to form the component contour line. According to the two focal lengths and the corresponding contour line feature lengths, the actual contour line feature length and the actual coordinates of the edge points are calculated. According to the actual coordinates of the edge points, data such as the required component length, height, perimeter, and area can be obtained. This method reduces the requirement for light intensity, and the calculation amount of image analysis is greatly reduced, and the measurement speed is greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a flowchart of the component edge detection method based on matrix color point recognition in an embodiment of the present invention;
[0029] Figure 2 is a schematic diagram of matrix color points and the origin, control points K1, and K2 in an embodiment of the present invention;
[0030] Figure 3 is a schematic diagram of partial overlap between matrix color points and a component to be measured in an embodiment of the present invention;
[0031] Figure 4 is a schematic diagram of the contour line of the component to be measured in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0032] The following further describes in detail the component edge detection method based on matrix color point recognition provided by the present invention in conjunction with the accompanying drawings and specific embodiments. In combination with the following description, the advantages and features of the present invention will be clearer. It should be noted that the accompanying drawings are all in a very simplified form and use non-precise scales, only for the purpose of facilitating and clearly assisting in explaining the purpose of the embodiments of the present invention.
[0033] Combined with Figures 1 to 4 shown, the component edge detection method based on matrix color point recognition provided in this embodiment includes the following methods:
[0034] Step 1. Establish a standard coordinate system for the matrix color points of the camera (see Figure 2) The matrix color dots are built into the camera and are located on the path of light to the photosensitive component; the matrix color dots are arranged in m rows and n columns, with a row pitch and a column pitch both being d; in the standard coordinate system, the point position (1, 1) at the upper left corner of the matrix color dots is marked as the origin O, the point position (1, n) at the upper right corner is used as the x-axis control point K1, and the point position (m, 1) at the lower left corner is used as the y-axis control point K2; the point positions of the matrix color dots form a two-dimensional array S 1 ; the standard coordinate values of the point positions form a two-dimensional array T, T ij = (T ijx , T ijy ) = ((j - 1)d, (i - 1)d), where i = 1, 2, …, m, j = i = 1, 2, …, n.
[0035] The matrix color dots can be arranged on a flat lens, and can be arranged on the camera lens or at a position between the lens and the camera lens and the focal length. The matrix color dots can be completed by using existing laser engraving or laser marking.
[0036] Step 2: Obtain a first image of the component to be measured through the camera, and measure the focal length x1 of the lens at this moment through the displacement sensor built into the camera. The first image is an image in which the matrix color dot image overlaps with the component image when the focal length is x1. See Figure 3 .
[0037] Step 3: Adjust the lens focal length to take a second image of the component to be measured, and measure the focal length x2 of the lens at this moment through the displacement sensor built into the camera. The second image is an image in which the matrix color dot image overlaps with the component image when the focal length is x2.
[0038] Step 4: The processor respectively identifies the first image and the second image as pixel coordinates, and identifies the pixel coordinates (X, Y) of the visible matrix color dots in the first image and the second image according to the RGB values, and converts the pixel coordinates (X, Y) of the visible matrix color dots into standard coordinates (MX kl , MY kl ), and matches the standard coordinates (MX kl , MY kl ) with the elements in the two-dimensional array T to find the corresponding point positions, and form a two-dimensional array S 2 .
[0039] The processor can automatically identify the pixels of the picture, and represent the width and height of the picture in terms of pixel points. The processor can identify the required pixel points and represent the pixel point positions. Therefore, a pixel coordinate system can be established based on the pixels in the processor.
[0040] Step 5: According to the two-dimensional array S 1 , S 2, obtain a two-dimensional array S composed of the positions of the matrix color points overlapping with the component to be measured 3 , take S 3 in S 2 the positions adjacent to the elements in S
[0041] as the edge positions, connect the edge positions together to form the contour line of the component to be measured, and record the edge positions as the standard coordinates T ij of the edge positions of the component to be measured ij into actual coordinates W
[0042]
[0043] In this embodiment, the component edge detection method based on matrix color point recognition sets matrix color points in the camera, then takes two images of the matrix color points overlapping with the component image at different focal lengths, and then uses the processor to perform pixel recognition and identify the control points according to the matrix color points, find out the matrix color points that do not overlap with the component, so as to obtain the matrix color points overlapping with the component, and then find out the edge positions to form the component contour line. Calculate the actual contour line feature length and the actual coordinates of the edge positions according to the two focal lengths and the corresponding contour line feature lengths. According to the actual coordinates of the edge positions, data such as the length, height, perimeter, and area of the required component can be obtained.
[0044] Further, in step four, the conversion of the pixel coordinates (X, Y) of the visible matrix color points into standard coordinates (MX kl , MY kl ) includes the following steps:
[0045] A1. Establish an image pixel coordinate system, with the first pixel point in the upper left corner of the image as the origin, the pixel point in the upper right corner as the x-axis control point, and the pixel point in the lower left corner as the y-axis control point;
[0046] A2. Identify the matrix color points according to the RGB values. Among them, the matrix color points in the upper left corner, upper right corner, and lower left corner are the origin O and the control points K1, K2 in the standard coordinate system respectively. The pixel point coordinates are (X O , Y O ), (X K1 , Y K1 ), (X K2 , Y K2 );
[0047] A3. The pixel coordinates of the matrix color dots recognized by the processor, and the pixel coordinates of any point of the matrix color dots are denoted as (X kl , Y kl ), which are converted into (MX kl , MY kl ), satisfying:
[0048]
[0049] When a matrix color dot is displayed as multiple pixel dots, multiple adjacent pixel dots may be recognized through the RGB values, and the coordinates of the pixel dot at the center or near the center are taken as the pixel coordinates of the matrix color dot.
[0050] Furthermore, the RGB values of the color dots at the upper left corner, upper right corner, and lower left corner of the matrix color dot are (255, 255, 0), (0, 255, 0), and (0, 255, 255) respectively, and the RGB values of other color dots are (255, 0, 0). That is to say, in the standard coordinate system, the RGB values of the origin O and the control points K1 and K2 are yellow, green, and cyan, and the RGB values of other color dots are red. The processor can directly recognize the pixel coordinates of the color dots that do not overlap with the component. After converting the pixel coordinates into standard coordinates, the position information of the color dots that do not overlap with the component can be determined.
[0051] Furthermore, in step four, the determination rule for matching the standard coordinates (MX kl , MY kl ) with the elements in the two-dimensional array T is as follows:
[0052] When |MX kl - T ijx | ≤ Δd, and |MY kl - T ijy | ≤ Δd, it is determined that the two match, where Δd is a preset value, and Δd << d. This embodiment is to prevent the problem of incorrect determination caused by the error between the pixel coordinates and the standard coordinates, thereby improving the accuracy of the matching. As an example: Δd = 0.1d, 0.05d, or 0.02d.
[0053] Furthermore, in step five, the determination of the edge positions includes the following methods:
[0054] B1. Assign 1 to the matrix color dots at the positions in the two-dimensional array S 2 , and assign 0 to the matrix color dots at the positions in the two-dimensional array S 3 to obtain the assigned two-dimensional array
[0055] B2. For the two-dimensional array The row vectors are subtracted from the adjacent row vectors upward and downward respectively, and the column vectors are subtracted from the adjacent column vectors leftward and rightward respectively. The points with a value of -1 are recorded as index points. All the index points form an index vector J. The index points in the index vector J are all edge points. See Figure 4 . As an example, when the feature length Z1 is the perimeter of the contour line, taking the point with the smallest coordinate modulus as the starting point q1, the point with the shortest distance is queried as its adjacent point q2, and the length z1 of the line connecting the two is calculated; then, taking q2 as a reference, the point with the shortest distance is queried backward as its next adjacent point q3, and the length z2 of the line connecting the two is calculated; and so on until the last point q J , and the length z of the last connection is calculated J ; By accumulating z1, z2,..., z J , the perimeter Z1 of the component edge can be obtained.
[0056] Of course, the determination of the edge points can also be based on the color difference determination of adjacent pixels, or by the relationship between the minimum distance between the elements in the two-dimensional array S 3 and the elements in the two-dimensional array S 2 and the spacing d.
[0057] The technical features of the above-described embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0058] The above-described embodiments only represent several implementation manners of the present invention. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several deformations and improvements can still be made, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention patent should be subject to the appended claims.
Claims
1. A component edge detection method based on matrix color point recognition, characterized in that Including: Step 1: Establish a standard coordinate system for the matrix color points of the camera. The matrix color points are built into the camera and located on the path of light to the photosensitive component. The matrix color points are m rows and n columns, with a row-column spacing of d. The standard coordinate system marks the point (1, 1) in the upper left corner of the matrix color points as the origin O, the point (1, n) in the upper right corner as the x-axis control point K1, and the point (m, 1) in the lower left corner as the y-axis control point K2. The points of the matrix color points form a two-dimensional array S 1 ; The standard coordinate values of the points form a two-dimensional array T, T ij =(T ijx , T ijy ) = ((j - 1)d, (i - 1)d), where i = 1, 2, …, m, j = i = 1, 2, …, n; Step 2: Obtain the first image of the component to be measured through a camera, and measure the focal length x1 of the lens at this moment through the displacement sensor built in the camera; Step 3: Adjust the lens focal length to take the second image of the component to be measured, and measure the focal length x2 of the lens at this moment through the displacement sensor built in the camera; Step 4: The processor recognizes the first image and the second image as pixel coordinates respectively, and based on the RGB values, recognizes the pixel coordinates (X, Y) of the visible matrix color points in the first image and the second image, and converts the pixel coordinates (X, Y) of the visible matrix color points into standard coordinates (MX kl , MY kl ). It matches the standard coordinates (MX kl , MY kl ) with the elements in the two-dimensional array T to find the corresponding points, and forms a two-dimensional array S 2 ; Step Five: According to the two-dimensional array S 1 , S 2 , obtain the two-dimensional array S 3 composed of the positions of the matrix color points overlapping with the component to be measured. Take the positions adjacent to the elements in S 3 as the edge positions in S 2 , connect the edge positions together to form the contour line of the component to be measured, and record the edge positions as Step 6: According to the contour line of the component to be measured, calculate the value Z1 of the characteristic length of the component to be measured in the first image in the standard coordinate system, calculate the value Z2 of the corresponding characteristic length of the component to be measured in the second image in the standard coordinate system, then calculate the actual characteristic length Z of the component to be measured, and convert the standard coordinates T of the edge points ij of the component to be measured into actual coordinates W ij ; The characteristic length of the component to be measured is the width, height or perimeter of the component to be measured; where 2. The component edge detection method based on matrix color point recognition according to claim 1, characterized in that In Step 4, converting the pixel coordinates (X, Y) of the visible matrix color dots into standard coordinates (MX kl , MY kl ) includes the following steps: A1. Establish an image pixel coordinate system, with the first pixel point in the upper left corner of the image as the origin, the pixel point in the upper right corner as the x-axis control point, and the pixel point in the lower left corner as the y-axis control point; A2. Identify matrix color points according to RGB values, where the matrix color points in the upper left corner, upper right corner, and lower left corner are the origin O and control points K1, K2 in the standard coordinate system, and the pixel point coordinates are (X O , Y O ), (X K1 , Y K1 ), (X K2 , Y K2 ); A3. The pixel coordinates of the matrix color dots recognized by the processor. The pixel coordinates of any point of the matrix color dots are denoted as (X kl , Y kl ), which are converted into (MX kl , MY kl ), satisfying:
3. The component edge detection method based on matrix color point recognition according to claim 2, characterized in that When a matrix color point is displayed as multiple adjacent pixel points, take the coordinates of the pixel point at the center or near the center as the pixel coordinates of the matrix color point.
4. The component edge detection method based on matrix color point recognition according to claim 1 or 2, characterized in that The RGB values of the color points in the upper left corner, upper right corner, and lower left corner of the matrix color point are (255, 255, 0), (0, 255, 0), and (0, 255, 255) respectively, and the RGB values of other color points are (255, 0, 0).
5. The component edge detection method based on matrix color point recognition according to claim 1 or 2, characterized in that In Step 4, the determination rule for matching the standard coordinates (MX kl , MY kl ) with the elements in the two-dimensional array T is as follows: When |MX kl -T ijx | ≤ Δd, and when |MY kl -T ijy | ≤ Δd, it is determined that the two match, where Δd is a preset value and Δd << d.
6. The method for detecting the edge of a component based on matrix color dot recognition according to claim 5, wherein △d = 0.1d.
7. The component edge detection method based on matrix color point recognition according to claim 1 or 2, characterized in that In step 5, the determination of the edge points includes the following method: B1. Assign the matrix color points at the midpoints of the two-dimensional array S 2 to 1, and assign the matrix color points at the midpoints of the two-dimensional array S 3 to 0 to obtain the two-dimensional array after assignment B2. Subtract the adjacent row vectors of the two-dimensional array from the row vectors upward and downward respectively, subtract the adjacent column vectors from the column vectors to the left and right respectively, mark the points with a value of -1 as index points, all the index points form an index vector J, and the index points in the index vector J are all edge points.
Citation Information
Patent Citations
Height measurement method based on monocular machine vision
WO2018076977A1
Photographing equipment control method, photographing equipment control device and photographing equipment
WO2020124517A1