A labeled steel bar parameter measurement method based on image processing
Through the method based on image processing, the problem of label morphology diversity and perspective error in the measurement of tagged steel bar parameters is solved, the accurate measurement of the length and diameter of the steel bar is achieved, and higher measurement accuracy and applicability are provided.
Patent Information
- Application Number
- CN202111528314.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-12-14
AI Technical Summary
It is difficult to accurately measure the parameters of tagged steel bars with the existing technology, especially the perspective error caused by the diversity of labels and the thickness of the steel bars, which affects the measurement accuracy of the length and diameter of the steel bars.
Using a method based on image processing, the steel bar image is collected and binarized and opened and closed to remove burrs, filter the area of interest, calculate the minimum circumscribed rectangle and rectangular corner points, determine the same steel bar, and rotate the steel bar area to generate equally spaced rectangular measurement frames , fit the edge of the steel bar through the average gray value and Gaussian filtering, calculate the pixel length and diameter, and perform physical size conversion in conjunction with the calibration parameters, and perform error correction to reduce perspective errors.
It achieves accurate measurement of the parameters of labeled steel bars, completely avoids the influence of labels, improves measurement accuracy, and is suitable for parameter measurement of curved and other obstructed steel bars.
Smart Images

Figure CN114332198B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of construction engineering, and in particular to a labeled steel bar parameter measurement method based on image processing. Background Art
[0002] Rebar refers to steel used for reinforced concrete and prestressed reinforced concrete. Its cross section is round, sometimes square with rounded corners. It includes plain round steel bars, ribbed steel bars, and torsion steel bars. Rebars mainly bear tensile stress in concrete. They are widely used in various building structures, especially large, heavy, light thin-walled and high-rise building structures. Only by understanding the relevant parameters of rebars can we better utilize them. How to better and more accurately measure rebars is of great significance in the field of construction.
[0003] Rebar parameters generally include length and diameter. Patent application CN 111103018A discloses a device and method for measuring rebar parameters based on machine vision. Although the machine vision method is used in the application to measure rebar parameters including length and diameter, in actual application, most rebars are labeled or there are obstructions on the rebars that affect their measurement. When the rebars are labeled, the rebars in the captured image will be cut into several sections. The label area needs to be removed in the algorithm, but it is very difficult to achieve due to the various shapes of the labels. Therefore, the method in the existing application cannot effectively measure the parameters of the rebar. At the same time, for the measurement of the diameter and length of the rebar, a measurement system design with the camera and lens on top and the calibration surface on the bottom is generally used. However, due to the thickness of the rebar itself, the rebar and the calibration surface are not on the same surface. During the measurement process, there will be perspective errors, resulting in the inability of the existing measurement method to accurately measure. Summary of the invention
[0004] In order to solve the deficiencies of the prior art, the present invention provides a labeled steel bar parameter measurement method based on image processing.
[0005] The purpose of the present invention is achieved through the following technical solutions:
[0006] A method for measuring steel bar parameters with labels based on image processing, wherein the steel bar parameters include the length and diameter of the steel bar, comprises the following steps:
[0007] S1. Collect images of several steel bars at the same time, binarize the collected images, and use opening and closing operations to remove burrs during the segmentation process; select the region of interest of the steel bars according to the area, length and rectangularity of the region, and calculate the minimum circumscribed rectangle of each region of interest and the coordinates of the four corners of the rectangle;
[0008] S2. Based on each collected steel bar area, calculate the distance between it and other steel bar areas, and determine whether they are the same steel bar: find the center point, midline and half width of the minimum circumscribed rectangle of each steel bar area, calculate the distance from the center point of other steel bar interest areas to the center line of the basic steel bar area, and determine whether they are the same steel bar;
[0009] S3, rotating the same steel bar area into a horizontal direction, generating a number of rectangular measurement frames with fixed widths and lengths and equal intervals on the two long sides of the area and the two ends of the steel bar, calculating the average gray value of the rectangular measurement frames, finding the edge of the steel bar and the contour points at both ends, and fitting them into straight lines, calculating the final distance to obtain the final required steel bar pixel distance and pixel length;
[0010] S4. Combined with the calibration parameters, the pixel size is converted into the physical size, that is, the physical length and diameter of the steel bar.
[0011] Preferably, the measuring method further comprises a step for performing error correction on the pixel length in S3, S31, by the following formula: The actual pixel length of the steel bar is corrected again, where H is the camera height and L is 0 is the pixel length of the steel bar itself, L 1 is the projection of the steel bar to be measured along the optical axis on the calibration plane, and d is the actual measured pixel diameter.
[0012] Preferably, the judgment method in S2 comprises the following steps: when the distance between the center point of the other steel bar region of interest and the center line of the region is less than the half width of the minimum circumscribed rectangle, the two regions are recorded as the same steel bar;
[0013] When the collected steel bars are bent steel bars, if the distance from different regions of interest of the same steel bar to the center line is greater than the half-width, a value of 30 to 100 pixels needs to be added to the half-width for judgment.
[0014] Preferably, the calculation of the pixel diameter of the steel bar in S3 comprises the following steps:
[0015] The same steel bar area is rotated horizontally, and several equally spaced rectangular measurement frames with fixed width and length are generated on the two long sides of the area. The average grayscale value on each slice on the contour line perpendicular to each rectangular measurement frame is calculated first, and the average grayscale value is Gaussian filtered and the first-order derivative is calculated to find the edge contour points of the steel bar. Then the thread points are eliminated and the remaining points are fitted into a straight line. The distance between the two long sides is calculated as the pixel diameter of the steel bar.
[0016] Preferably, the calculation of the pixel length of the steel bar in S3 includes the following steps: rotating the same steel bar area into a horizontal direction, generating a number of equally spaced rectangular measurement frames with fixed width and length at both ends of the steel bar, calculating the average gray value on each slice on the contour line perpendicular to each rectangle, performing Gaussian filtering on the average gray value and then obtaining the first-order derivative, finding the contour points at both ends of the steel bar, eliminating the points on the arc edges at both ends of the steel bar, fitting the remaining points into a straight line, and calculating the distance between the two short sides as the pixel length of the steel bar.
[0017] Preferably, the coordinates of the minimum circumscribed rectangle of the steel bar region of interest in S1 are calculated according to the following formula, wherein phi is the angle between the rectangle and the horizontal direction, DE is the long half length length1, and AF is the short half length length2;
[0018] Point A coordinate formula:
[0019] ax=x-(-length1*sin(phi)+lenth2*cos(phi))
[0020] ay=y+(-length1*cos(phi)-length2*sin(phi))
[0021] Point B coordinate formula:
[0022] bx=x-(-length1*sin(phi)+lenth2*cos(phi))
[0023] by=y+(-length1*cos(phi)+lenth2*sin(phi))
[0024] Point C coordinate formula:
[0025] cx=x-(length1*sin(phi)-length2*cos(phi))
[0026] cy=y+(length1*cos(phi)+lenth2*sin(phi))
[0027] Point D coordinate formula:
[0028] dx=x-(length1*sin(phi)+lenth2*cos(phi))
[0029] dy=y+(length1*cos(phi)-length2*sin(phi)).
[0030] The beneficial effects of the present invention are embodied in that the measuring method of the present invention can completely avoid labels, accurately and effectively calculate the parameters of steel bars with labels, and provide a basis for better application of steel bars. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 : Schematic diagram of the minimum bounding rectangle of the region of interest in an embodiment of the present invention.
[0032] Figure 2 : A schematic diagram of determining whether the steel bars are the same in an embodiment of the present invention.
[0033] Figure 3 : Schematic diagram of a measurement frame structure in which a plurality of equally spaced steel bars are generated during measurement in an embodiment of the present invention.
[0034] Figure 4 : Schematic diagram of the camera optical path used for error correction of the present invention. DETAILED DESCRIPTION
[0035] The following is combined with the embodiments and Figure 1-Figure 3 The technical solution of the present invention is described. The present invention discloses a method for measuring steel bar parameters with labels based on image processing, wherein the steel bar parameters include the length of the steel bar and the diameter of the steel bar. Specifically, the method comprises the following steps:
[0036] The algorithm proposed in the present invention can completely avoid labels, and only needs to extract the area of interest of the steel bar, and combine several sections of steel bars belonging to the same steel bar into one steel bar for measurement.
[0037] S1. Collect images, binarize them, and use open and close operations to remove burrs during segmentation. Filter out the regions of interest of the steel bars according to the area, length, and rectangularity, and calculate the minimum circumscribed rectangle of each region of interest and the coordinates of the four corners of the rectangle. Figure 1 The figure shows the minimum circumscribed rectangle of the steel bar region of interest, phi is the angle between the rectangle and the horizontal direction, DE is the long half length length1, and AF is the short half length length2.
[0038] Calculate the coordinates of point A according to the following formula:
[0039] ax=x-(-length1*sin(phi)+length2*cos(phi))
[0040] ay=y+(-length1*cos(phi)-length2*sin(phi))
[0041] Calculate the coordinates of point B according to the following formula:
[0042] bx=x-(-length1*sin(phi)-length2*cos(phi))
[0043] by=y+(-length1*cos(phi)+length2*sin(phi))
[0044] Calculate the coordinates of point C according to the following formula:
[0045] cx=x-(length1*sin(phi)-length2*cos(phi))
[0046] cy=y+(length1*cos(phi)+length2*sin(phi))
[0047] Calculate the coordinates of point D according to the following formula:
[0048] dx=x-(length1*sin(phi)+length2*cos(phi))
[0049] dy=y+(length1*cos(phi)-length2*sin(phi))
[0050] S2. Find the center point, midline and half width of the minimum circumscribed rectangle of each steel bar area, calculate the distance from the center point of the other steel bar area of interest to the center line of the area, and when the distance is less than the half width of the minimum circumscribed rectangle, the two areas are recorded as the same steel bar. For bent steel bars, when the distance from different areas of interest to the center line of the same steel bar is greater than the half width, an appropriate value needs to be added to the half width for judgment.
[0051] Specifically, Figure 2 As shown, straight line AB is the midline of area 1, O 1 is the center of region 1, O 2 is the center line of area 2. Calculate O 2 To the distance between AB, when the distance is less than l, area 1 and area 2 are the same steel bar.
[0052] S3. Combination Figure 3 As shown in the figure, the same steel bar area is rotated horizontally, and several rectangular measurement frames with fixed width and length are generated on the two long sides of the area. The average gray value on each slice on the contour line perpendicular to each rectangle is calculated first, and the average gray value is Gaussian filtered and the first-order derivative is calculated to find the edge contour points of the steel bar. Then the thread points are eliminated and the remaining points are fitted into a straight line. The distance between the two long sides is calculated as the pixel diameter of the steel bar.
[0053] S4. Generate several equally spaced rectangular measurement frames with fixed width and length at both ends of the steel bar. Calculate the average gray value on each slice perpendicular to the contour line of each rectangle, perform Gaussian filtering on the average gray value and then take the first-order derivative to find the contour points at both ends of the steel bar. Eliminate the points on the arc edges at both ends of the steel bar and fit the remaining points into a straight line. The distance between the two short sides is calculated as the pixel length of the steel bar.
[0054] S5. Combined with the calibration parameters, the pixel size is converted into the physical size, which is the physical length and diameter of the steel bar.
[0055] Combination Figure 4 As shown in the figure, due to the thickness of the steel bar itself during the imaging process, the imaging plane of the steel bar and the calibration plane are not at the same height. In the process of converting the three-dimensional space into the two-dimensional plane information, the depth information in the optical axis direction will be compressed, resulting in a perspective error where the near is larger and the far is smaller. That is, the pixel size of the steel bar contour on the imaging plane is larger than the pixel size of the steel bar contour on the calibration plane. In order to measure the steel bar length more accurately, it is necessary to perform an error correction step on the pixel length in S3, that is, through the following formula The actual pixel length of the steel bar is corrected again. H is the camera height, L 0 is the pixel length of the steel bar itself, L 1 is the projection of the steel bar to be measured along the optical axis on the calibration plane, and d is the actual measured pixel diameter.
[0056] Specific, combined Figure 4 It can be seen from the optical path that α is half of the field of view, H is the camera height, and L 0 is the pixel length of the steel bar itself, L 1 is the projection of the steel bar to be measured along the optical axis on the calibration plane. Among them, the actual length of the steel bar and the camera height and the diameter of the steel bar have the following relationship: Right now In actual calculations, it is found that even without error compensation, the measurement error of the steel bar diameter is within 1 mm. Therefore, the actual pixel length of the steel bar can be calculated by substituting the actually measured steel bar pixel diameter into formula (1).
[0057] The measurement method disclosed in the present invention is simple and effective, the algorithm is easy to implement, and the steel bar area can be effectively segmented and the required parameters can be measured. Moreover, the method is not limited to steel bars with labels, but is also applicable to the measurement of steel bar parameters with other obstructions.
[0058] Of course, there are many specific implementations of the present invention, which are not listed here one by one. All technical solutions formed by equivalent replacement or equivalent transformation fall within the scope of protection required by the present invention.
Claims
1. A method for measuring steel bar parameters with labels based on image processing, wherein the steel bar parameters include the length of the steel bar and the diameter of the steel bar, characterized in that: The steps include: S1. Collect images of several steel bars at the same time, binarize the collected images, and use opening and closing operations to remove burrs during the segmentation process; select the region of interest of the steel bars according to the area, length and rectangularity of the region, and calculate the minimum circumscribed rectangle of each region of interest and the coordinates of the four corners of the rectangle; S2. Based on each collected steel bar area, calculate the distance between it and other steel bar areas, and determine whether they are the same steel bar: find the center point, midline and half width of the minimum circumscribed rectangle of each steel bar area, calculate the distance from the center point of other steel bar interest areas to the center line of the basic steel bar area, and determine whether they are the same steel bar; S3, rotating the same steel bar area into a horizontal direction, generating a number of rectangular measurement frames with fixed widths and lengths and equal intervals on the two long sides of the area and the two ends of the steel bar, calculating the average gray value of the rectangular measurement frames, finding the edge of the steel bar and the contour points at both ends, and fitting them into straight lines, calculating the final distance to obtain the final required steel bar pixel diameter and pixel length; S4, combining the calibration parameters, converting the pixel size into a physical size, i.e., the physical length and diameter of the steel bar; The calculation of the pixel diameter of the steel bar in S3 includes the following steps: The same steel bar area is rotated horizontally, and several rectangular measurement frames with fixed width and length are generated on the two long sides of the area at equal intervals. The average gray value on each slice on the contour line perpendicular to each rectangular measurement frame is calculated first, and the average gray value is Gaussian filtered and the first-order derivative is calculated to find the edge contour points of the steel bar. Then the thread points are eliminated and the remaining points are fitted into a straight line. The distance between the two long sides is calculated as the pixel diameter of the steel bar. The calculation of the pixel length of the steel bar in S3 includes the following steps: rotating the same steel bar area into a horizontal direction, generating a number of equally spaced rectangular measurement frames with fixed width and length at both ends of the steel bar, calculating the average gray value on each slice on the contour line perpendicular to each rectangle, performing Gaussian filtering on the average gray value and then obtaining the first-order derivative, finding the contour points at both ends of the steel bar, eliminating the points on the arc edges at both ends of the steel bar, fitting the remaining points into a straight line, and calculating the distance between the two short sides as the pixel length of the steel bar.
2. The method for measuring steel bar parameters with labels based on image processing according to claim 1, characterized in that: The measuring method further comprises a step for performing error correction on the pixel length in S3, S31, by the following formula The actual pixel length of the steel bar is corrected and calculated again, where H is the camera height, L0 is the pixel length of the steel bar itself, L1 is the projection of the steel bar to be measured along the optical axis on the calibration plane, and d is the actual measured pixel diameter.
3. The method for measuring steel bar parameters with labels based on image processing according to claim 1, characterized in that: The judgment method in S2 comprises the following steps: when the distance between the center point of the other steel bar region of interest and the center line of the steel bar region of the foundation is less than the half width of the minimum circumscribed rectangle, the two regions are recorded as the same steel bar; When the collected steel bars are bent steel bars, if the distance from different regions of interest of the same steel bar to the center line is greater than the half-width, a value of 30 to 100 pixels needs to be added to the half-width for judgment.
4. The method for measuring steel bar parameters with labels based on image processing according to claim 1, characterized in that: The coordinates of the minimum circumscribed rectangle of the steel bar region of interest in S1 are calculated according to the following formula, wherein phi is the angle between the rectangle and the horizontal direction, DE is the long half length length1, and AP is the short half length length2; Point A coordinate formula: ax=x-(-length1*sin(phi)+length2*cos(phi)) ay=y+(-length1*cos(phi)-length2*sin(phi)) Point B coordinate formula: bx=x-(-length1*sin(pli)-length2*cos(phi)) by=y+(-length1*cos(phhi)+length2*sin(phi)) Point C coordinate formula: cx=x-(length1*sin(phi)-length2*cos(phi)) cy=y+(length1*cos(phi)+length2*sin(phi)) Point D coordinate formula: dx=x-(length1*sin(phi)+length2*cos(phi)) dy=y+(length1*cos(phi)-length2*sin(phi)).
