Steel bar size quality detection method based on improved RTDETR
By improving the RTDETR network model, the SteelNet module and distance prompt attention mechanism were introduced, and the problems of slow and inaccurate quality detection of steel bars were solved, and efficient and real-time steel bar detection was achieved in prefabricated buildings.
Patent Information
- Application Number
- CN202510533527.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-08-05
AI Technical Summary
The existing methods of steel bar dimensional quality detection are slow and inaccurate in production environments, especially in prefabricated buildings, which are difficult to achieve efficient and real-time inspection.
The improved RTDETR network model is adopted, and the SteelNet module and distance prompt attention mechanism are introduced, combining dynamic direction perception deformable convolution blocks and distribution perception DIOU loss function to improve the model's perception ability and detection accuracy of the slender features of the steel bars.
Without increasing the system calculation burden, the accuracy and speed of steel bar detection are significantly improved, and are suitable for stable deployment under complex working conditions to meet the real-time inspection needs of prefabricated buildings.
Smart Images

Figure CN120431053A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of steel bar size detection, and in particular to a steel bar size quality detection method based on an improved RTDETR. Background Art
[0002] In recent years, prefabricated construction has rapidly developed globally as a highly efficient, environmentally friendly, and time-efficient construction method. Precast concrete (PC) components are widely used in prefabricated buildings due to their high compressive strength and excellent dimensional stability. Rebar is the key load-bearing component in PC components. PC components are interconnected by protruding rebar, enabling the coordinated operation of different components and enhancing the stability of the building structure. After the rebar is tied, the protruding rebar of the PC components must undergo dimensional quality inspection (DQI). Due to the characteristics of PC components, the dimensions of the protruding rebar only need to be inspected perpendicular to the mold. Only PC components that meet the drawing specifications can proceed to the next process. The number of rebars required for components on a production line can often reach hundreds, making manual dimensional and quality inspection within the specified production timeframe a challenging task. Therefore, the accuracy and real-time performance of rebar dimensional quality inspection are of great significance to the construction industry.
[0003] At present, steel bar size quality inspection is mainly divided into two categories: (1) laser scanning-based size inspection method, which accurately collects 3D point cloud data for size quality inspection; (2) camera-based size inspection method, which uses industrial cameras to collect 2D image data for steel bar quality inspection. Laser scanning-based size inspection method has high accuracy but high cost. The speed of detecting 3D point cloud data is slow and does not meet the needs of actual production. Relatively speaking, camera-based size inspection method can collect images faster and is more suitable for meeting the requirements of large-scale engineering projects for high efficiency and real-time feedback.
[0004] Object detection in two-dimensional images can be used to perform dimensional quality inspection using highly annotated images, and it is much faster than image segmentation. However, due to the slender nature of rebar in production environments, existing object detection methods often overlook the specificity of these slender objects and the regularity of rebar distribution. This leads to missed detections due to low recall rates, making existing dimensional quality inspection methods ineffective for real-time, high-quality inspection of rebar in production environments. Summary of the Invention
[0005] In view of the shortcomings of the existing technology, the technical problem to be solved by the present invention is to provide a steel bar size quality detection method based on improved RTDETR to overcome the problems of slow detection speed and inaccuracy in the existing technology.
[0006] The present invention solves the technical problem by adopting the following technical solutions:
[0007] A method for detecting steel bar size quality based on improved RTDETR, the method comprising the following steps:
[0008] Step 1: Obtain images of protruding steel bars from different precast concrete components, annotate the steel bar detection frames and pixel lengths, and obtain a component steel bar dataset.
[0009] Step 2: Build and improve the RTDETR network model.
[0010] In the backbone of the improved RTDETR network model, four SteelNet modules are connected in series after the maximum pooling layer. The outputs of the last three SteelNet modules are input into the CCFM module and the AIFI attention module respectively after convolution processing. After being processed by the CCFM module, they enter the decoder to obtain the detection results.
[0011] The input of the SteelNet module is subjected to P convolution to generate a mask using the image's own features, and feature calculation is performed in the effective area. On the other hand, after normalization and the output of the dynamic direction-aware deformable convolution block, it is divided into two branches. One branch is processed by a fully connected layer, and the other branch is processed by a fully connected layer and a SiLU activation function. The outputs of the two branches are multiplied element-by-element and processed by the fully connected layer, and then added element-by-element to the P convolution output to obtain the output of the SteelNet module.
[0012] The dynamic direction-aware deformable convolution block includes a direction-aware module, which randomly samples input features to obtain random sampling points. The direction-aware module includes a convolution layer, a normalization layer, and a direction-aware template. Each sampling point corresponds to a local area of the image. The convolution layer extracts features. The feature map processed by the convolution layer is normalized to learn the probability distribution of D directions for each pixel position. The probability distribution is used as a direction weight and combined with the D direction-aware templates to dynamically generate an offset direction with structural preference to obtain the output of the direction-aware module.
[0013] Then, the offset direction output by the direction perception module is concatenated with the sampling point to form a modulation factor to guide the offset size and obtain features with offset.
[0014] The features with offsets and the input are used as the input of a fully connected layer. After processing by the fully connected layer, the first feature is obtained. The results of the random sampling points after being processed by the fully connected layer and the normalization layer are aggregated with the first feature to obtain the output of the dynamic direction-aware deformable convolution block.
[0015] The self-attention mechanism in the AIFI attention module is replaced with a distance-cued attention mechanism. The distance-cued attention mechanism introduces the spacing information of the steel bar grid and uses the regularity of the steel bar arrangement to form a distance code. It can dynamically adjust the distribution of attention areas during the network learning process, so that it can adaptively strengthen the attention to specific areas when processing regular steel bar layouts.
[0016] Step 3: Model training and application
[0017] The model is trained using the component steel bar dataset, and the trained model is used to perform steel bar detection on images of protruding steel bars of the precast concrete component to be identified, to obtain the steel bar size, and to determine whether the protruding steel bars of the component are qualified based on the comparison of the steel bar size with the standard value.
[0018] Furthermore, the direction-aware template d i is defined as:
[0019]
[0020] Wherein, D is set to 8, i represents any one of the eight directions, and i=0, 1, 2, 3...7 represent the eight directions of up, down, left, right, upper left, lower left, upper right, and lower right respectively.
[0021] Furthermore, the process of the distance cue attention mechanism is:
[0022] Obtain the steel network of different types of precast concrete components, determine the number of steel bars protruding from them, and then obtain the set of pixel spacing of steel bars. N is the number of steel bars minus 1. The pixel spacing set is fitted using a Gaussian model to obtain the prior Gaussian formula P(S):
[0023]
[0024] Among them, π e 、μ e , σ e They represent the weight, mean, and standard deviation of the e-th Gaussian component respectively; P represents the probability density; S represents the pixel distance; E represents the number of Gaussian components;
[0025] The prior Gaussian formula P(S) is integrated into the attention mechanism. The result of the upper convolution processing of the AIFI attention module is used to obtain the position of each pair of query q and key k, and the spatial Euclidean distance D between the query position and the key position is calculated. qk :
[0026]
[0027] (x k ,yk ) represents the query location coordinates, (x q ,y q ) represents the position coordinates of the key;
[0028] Get D qk After that, it is restored to the pixel distance S qk , for pixel distance S qk Introduce the smoothness term ε and convert the pixel distance S between the query position and the key position into qk +ε is substituted into the prior Gaussian formula P(S) to calculate its probability P, which represents the possibility that the spacing between the two steel bars complies with the rule;
[0029] Performing a pairwise operation logP on the probability P, using logP as the distance encoding, and using the distance encoding as the bias term of the attention mechanism, the expression of the distance prompt attention mechanism is:
[0030]
[0031] Among them, K and Q are key vector and query matrix respectively, d represents vector dimension, α qk Represents the attention weight of the output of the distance-cued attention mechanism.
[0032] Furthermore, a high-resolution industrial camera is used to acquire images so as to obtain detailed features of the steel bars including edge information and surface texture, and orthogonal processing is performed with a pixel accuracy of not less than 0.5 mm, and the detection frame is close to both ends of the steel bars.
[0033] Furthermore, distribution-aware DIOU loss is used as the loss function during training.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] 1. This paper addresses the challenges of measuring the size and quality of protruding rebar during PC component fabrication, proposing a robust and highly accurate target detection method. The SteelNet module is introduced into the RTDETR architecture, effectively enhancing the model's ability to detect slender, characteristic areas of rebar. Combined with a distance-based attention mechanism, the model improves its recognition of rebar of varying specifications while maintaining real-time detection performance without increasing the system's computational burden, making it suitable for stable deployment under complex on-site conditions.
[0036] 2. The SteelNet module in this invention enhances feature expression capabilities while significantly reducing calculation time by introducing a term-by-term multiplication interaction mechanism and a residual structure combined with partial convolution (PConv). In combination with a dynamic direction-aware deformable convolution block, it effectively improves the directional modeling capability of slender targets such as steel bars, ensuring that detection accuracy and speed maintain excellent performance under complex working conditions.
[0037] 3. The distance-cued attention mechanism in the present invention uses the structural rules of steel bar arrangement to construct a priori Gaussian model to generate distance coding, and introduces it as a bias term into the attention calculation process, so that the model can automatically focus on areas with spatial consistency or repetitive distribution during the training phase, significantly improving the performance of the model in structured tasks such as target detection and arrangement recognition, and is particularly suitable for industrial scenarios such as steel bar identification and layout detection.
[0038] 4. The IOU loss is improved to DIOU loss. By introducing constraints on the center point of the target box and sensitivity to shape differences, it not only improves the positioning accuracy of steel bar targets, but also enhances the robustness of the model when dealing with targets with extreme aspect ratios, significantly improving the detection effect.
[0039] 5. Based on the calibration parameters of industrial cameras, the present invention constructs a precision mapping relationship between pixels and true lengths, and post-processes the steel bar detection results. It can accurately calculate the actual protruding length of each steel bar, realize the automated evaluation of steel bar size and quality, and provide an efficient, visual, and intelligent quality control method for the PC component processing link. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is a schematic diagram of the overall process of an embodiment of the detection method of the present invention;
[0041] Figure 2 A schematic diagram of the structure of an improved RTDETR network model according to an embodiment of the present invention;
[0042] Figure 3 Schematic diagram of the network structure of the SteelNet module in the present invention;
[0043] Figure 4 Schematic diagram of the structure of the dynamic direction-aware deformable convolution block in the present invention;
[0044] Figure 5 Schematic diagram of the distance cue attention mechanism in the present invention;
[0045] Figure 6 This is a graph showing the changes in various indicators after 100 rounds of model training in the embodiment;
[0046] Figure 7 This is a target detection effect diagram of the present invention;
[0047] Figure 8 This is a diagram showing the size measurement and detection effect of the present invention. DETAILED DESCRIPTION
[0048] The present invention is further explained below with reference to the following examples and accompanying drawings. These examples are only used to illustrate technical details and do not limit the scope of protection of this application.
[0049] The present invention is based on an improved RTDETR steel bar size quality detection method, comprising the following steps:
[0050] Step 1: Use an industrial camera to collect image data, and then have professionals perform high-precision annotation to obtain a labeling frame (detection frame) that fits the steel bars. The pixel length of the steel bars is annotated to obtain a component steel bar dataset.
[0051] Step 2: Build and improve the RTDETR network model.
[0052] In the backbone of the improved RTDETR network model, four SteelNet modules are connected in series after the maximum pooling layer. The outputs of the last three SteelNet modules are input into the CCFM module and the AIFI attention module respectively after convolution processing. After being processed by the CCFM module, they enter the decoder to obtain the detection results.
[0053] The backbone of the improved RTDETR network model replaces the original Resnet network with a SteelNet module that is more in line with the characteristics of steel bars and the production environment. It can better extract the slender features of steel bars while making the network structure lightweight. In the SteelNet module, element-by-element multiplication is used to obtain more high-dimensional latent features and better represent the features of complex background images. At the same time, in order to ensure the integrity of the features, the SteelNet module uses a residual-like structure and effectively solves problems such as gradient disappearance, while better extracting detailed information of the features. In order to solve the occlusion problem caused by the construction process, P convolution is used in the residual-like structure to generate a mask using the image's own features, and the mask mechanism is used to perform feature calculations in the effective area to solve the occlusion problem that may be caused by on-site construction. Using dynamic direction-aware deformable convolution, the direction-aware module is used to determine the offset direction and offset, improve the direction perception ability of steel bars and the adaptive adjustment ability of feature sampling of steel bars. The specific structure of the SteelNet module is as follows: Figure 3 As shown in the figure, the input of the SteelNet module is subjected to P convolution to generate a mask using the image's own features, and feature calculation is performed in the effective area; on the other hand, after normalization and the output of the dynamic direction-aware deformable convolution block, it is divided into two branches, one branch is processed by the fully connected layer, and the other branch is processed by the fully connected layer and the SiLU activation function. The outputs of the two branches are multiplied element by element, processed by the fully connected layer, and then added element by element with the P convolution output to obtain the output of the SteelNet module.
[0054] The dynamic direction-aware deformable convolution block includes a direction-aware module, which randomly samples input features to obtain random sampling points. The direction-aware module includes a convolution layer, a normalization layer, and a direction-aware template. Each sampling point corresponds to a local area of the image. The convolution layer extracts features. The feature map processed by the convolution layer is normalized to learn the probability distribution of D directions for each pixel position. The probability distribution is used as a direction weight and combined with the D direction-aware templates to dynamically generate an offset direction with structural preference to obtain the output of the direction-aware module.
[0055] Then, the offset direction output by the direction perception module is concatenated with the sampling point to form a modulation factor to guide the offset size and obtain features with offset.
[0056] The features with offsets and the input are used as the input of a fully connected layer. After processing by the fully connected layer, the first feature is obtained. The results of the random sampling points after being processed by the fully connected layer and the normalization layer are aggregated with the first feature to obtain the output of the dynamic direction-aware deformable convolution block.
[0057] Directional weights are obtained through a convolutional layer and normalized, and the offset direction is determined through multi-directional weighted fusion. Because the offset depends on the length of the rebar, the directional weights are combined with the original sampling points to form a modulation factor to guide the offset size, providing richer context and directional awareness. The dynamic direction-aware deformable convolutional block effectively improves the detection accuracy and processing speed of long objects such as rebar.
[0058] The self-attention mechanism in the AIFI attention module is replaced by a distance-cue attention mechanism. The distance-cue attention mechanism introduces the spacing information of the steel bar grid and uses the regularity of the steel bar arrangement to form distance coding. It can dynamically adjust the distribution of attention areas during the network learning process, so that it can adaptively strengthen attention to specific areas when processing regular steel bar layouts.
[0059] In the design and detection of PC components, the arrangement of protruding steel bars usually presents a regular distribution characteristic, and the spacing between the steel bars fluctuates within a certain fixed range. When dealing with a highly regular distribution of steel bars, the traditional self-attention mechanism weights the features of different positions by calculating the similarity between the input features, thereby performing information fusion. However, this mechanism does not have a strong adaptability to structured or regularized patterns (such as the row and column distribution of steel bars). In order to remedy this defect, the present invention replaces the self-attention mechanism in the AIFI model with a distance-cued attention mechanism, which can significantly enhance the model's perception of regular structures such as steel bars. The model can not only calculate the attention weight based on the input features, but also dynamically adjust the distribution of the attention area during the network learning process, so that it can adaptively strengthen its attention to specific areas when dealing with regular steel bar layouts. Specifically, it is necessary to obtain the steel bar spacing in different precast concrete components from the industry standard error range or component steel bar dataset, establish a distribution model for the steel bar spacing, and model the steel bar spacing through the probability density function of the Gaussian mixture model for the later formation of distance coding.
[0060] Step 3: Model training and application
[0061] The model is trained using the component steel bar dataset, and the trained model is used to perform steel bar detection on images of protruding steel bars of the precast concrete component to be identified, to obtain the steel bar size, and to determine whether the protruding steel bars of the component are qualified based on the comparison of the steel bar size with the standard value.
[0062] The present invention uses distribution-aware DIOU loss as the loss function during the training process, which can better adapt to the detection needs of steel bar targets. The DIOU loss function not only considers the degree of overlap (IoU) between target boxes, but also introduces the center point distance of the target box as an additional penalty term. In this way, even if the IoU value is high, if the center point of the target box is far away, the model will still be penalized, prompting the center point of the box to be closer to the center of the real target. This is especially important for targets with high aspect ratios such as steel bars, because the center position of the steel bar is often very critical, making the model more ideal in locating and identifying steel bar targets, especially when dealing with targets with extreme aspect ratios.
[0063] DIOU further improves target localization accuracy by introducing a minimum bounding box (i.e., the smallest rectangular box that contains both the predicted and true boxes). The diagonal length of the minimum bounding box is used as a measure of the difference between the two, thus preventing extreme differences in box shape from affecting the IoU calculation. By introducing the DIOU loss function and optimizing the center point and shape of the target box, the model not only improves detection accuracy for targets such as rebar, but also enhances its robustness, reducing false detections caused by irregular target shapes or large differences in aspect ratios.
[0064] The detection results are converted using the pixel accuracy of the industrial camera to obtain the actual length of the steel bar in the image, thereby completing the quality inspection. Specifically, the physical size of the industrial camera sensor is determined by its resolution and pixel size. Assume that the long side resolution of the sensor is R long , the short side resolution is R short , the physical size of each pixel is T, then the physical sizes of the long and short sides of the camera sensor can be calculated by the following formulas:
[0065] R long =R short *T
[0066] L long =L short *T
[0067] In addition, the camera's field of view (FOV) is determined by the sensor's physical size, focal length, and working distance. The size of the FOV directly affects the range of scenes that the camera can capture, which in turn affects the coverage area of image acquisition. Specifically, the long and short sides of the FOV can be calculated using the following formula:
[0068]
[0069] Among them, FOV long and FOV short Represent the long and short sides of the field of view, N is the working distance of the camera, and f is the focal length of the camera. Then, the actual size X represented by the unit pixel can be calculated:
[0070]
[0071] After obtaining X, the trained improved RTDETR network model is used for target detection to obtain the detection frame position. The coordinate information is converted into pixel information to obtain the number of pixels in the detection frame length. The steel bar size can then be obtained. By comparing it with the standard value in the drawing, it can be determined whether the protruding steel bars of the component are qualified.
[0072] Example 1
[0073] This embodiment is a steel bar size quality detection method based on improved RTDETR (see Figure 1 ) comprises the following steps:
[0074] Step 1: Use an industrial camera to collect image data, and then have professionals perform high-precision annotation to obtain a labeling frame that fits closely to the steel bars. The pixel length of the steel bars is annotated to obtain the component steel bar dataset C-Steel. Using a high-resolution industrial camera can obtain detailed steel bar features, including edge information and surface texture, and perform orthogonal processing. The pixel accuracy reaches 0.5mm, meeting the accuracy requirements of the industry. Professionals perform high-precision annotation on the collected data to ensure that the detection frame fits closely to both ends of the steel bars (see Figure 7 ), providing feasibility for steel bar size quality inspection. A total of more than 1,600 component images were collected. The resulting dataset was divided into training, validation, and test sets in a ratio of 8:1:1.
[0075] Step 2: Build an improved RTDETR network model
[0076] Improved RTDETR network model is based on the RTDETR target detection algorithm. For the specific structure, see Figure 2 The backbone replaces the original Resnet network with the SteelNet module that is more in line with the characteristics of steel bars and the production environment. The structure of the SteelNet module is as follows: Figure 3 As shown in Figure 2. Dynamic direction-aware deformable convolution blocks are used in the SteelNet module, as shown in Figure 2. Figure 4 shown.
[0077] The process of dynamic direction-aware deformable convolutional block is:
[0078] After random sampling of the input features, random sampling points are obtained. The direction perception module includes a convolution layer, a normalization layer, and a direction perception template. Eight direction perception templates d i , defined as follows:
[0079]
[0080] In order to ensure the integrity of the directions among the multiple predefined directions, D is set to 8, i represents any one of the eight directions, and i = 0, 1, 2, 3...7 represent the eight directions of up, down, left, right, upper left, lower left, upper right, and lower right respectively;
[0081] Each sampling point corresponds to a local area of the image. Features are extracted through the convolution layer. The feature map processed by the convolution layer is normalized to learn the probability distribution of eight directions for each pixel position. The probability distribution is used as the direction weight and combined with eight direction perception templates to dynamically generate offset directions with structural preferences to obtain the output of the direction perception module.
[0082] Then, the offset direction output by the direction perception module is dimensionally spliced with the sampling point to form a modulation factor to guide the offset and determine the features with offset in the offset direction;
[0083] The features with offsets and the input are used as the input of a fully connected layer. After processing by the fully connected layer, the first feature is obtained. The results of the random sampling points after being processed by the fully connected layer and the normalization layer are aggregated with the first feature to obtain the output of the dynamic direction-aware deformable convolution block.
[0084] Through the dynamic direction-aware deformable convolution block, the detection accuracy and processing speed of long objects such as steel bars can be effectively improved.
[0085] The image is input to the improved backbone network, using three ConvBN layers, one maximum pooling layer and two SteelNet modules (refer to Figure 2 ) for downsampling and feature extraction, halving the image space three times and increasing the number of channels to 128, resulting in feature map P3. When the features are input into the first SteelNet module, it further extracts features from the feature output of the maximum pooling layer and performs dynamic direction-aware deformable convolution to obtain features with directional information. This is further combined with element-wise multiplication and residual operations for feature fusion, enhancing the optimization capabilities of the deep network. After passing through the entire improved backbone network, the image passes through the next three SteelNet modules to obtain features P3, P4, and P5.
[0086] Distance hint attention mechanism, namely AIFI-DAttention, such as Figure 5 As shown, the model's perception of regular structures such as steel bars can be significantly enhanced. On the basis of traditional attention weight calculation, the spacing information of the steel bar grid is introduced, and the regularity of the steel bar arrangement is used to form distance coding to enhance the model's response to the regular structure. In this way, the model can not only calculate the attention weight based on the input features, but also dynamically adjust the distribution of the attention area during the network learning process, so that it can adaptively strengthen its attention to specific areas when dealing with regular steel bar layouts. The specific process is: obtain the steel bar network of different types of precast concrete components, determine the number of steel bars protruding, and then obtain a set of pixel spacings of steel bars. For the pixel spacing set N is the number of steel bars minus 1. The pixel spacing set is fitted using a Gaussian model to obtain the prior Gaussian formula P(S):
[0087]
[0088] Among them, π e 、μe , σ e They represent the weight, mean, and standard deviation of the e-th Gaussian component respectively; P represents the probability density; S represents the pixel distance; E represents the number of Gaussian components, which is the peak value of the distance;
[0089] The prior Gaussian formula P(S) is integrated into the attention mechanism. The result of the upper convolution processing of the AIFI attention module is used to obtain the position of each pair of query q and key k, and the spatial Euclidean distance D between the query position and the key position is calculated. qk :
[0090]
[0091] (x k ,y k ) represents the query location coordinates, (x q ,y q ) represents the position coordinates of the key;
[0092] Get D qk After that, it is restored to the pixel distance S qk , for pixel distance S qk Introduce the smoothness term ε and convert the pixel distance S between the query position and the key position into qk +ε is substituted into the prior Gaussian formula P(S) to calculate its probability P, which represents the possibility that the spacing between the two steel bars complies with the rule;
[0093] Performing a pairwise operation logP on the probability P, using logP as the distance encoding, and using the distance encoding as the bias term of the attention mechanism, the expression of the distance prompt attention mechanism is:
[0094]
[0095] Among them, K and Q are key vector and query matrix respectively, d represents vector dimension, α qk Represents the attention weight of the output of the distance-cued attention mechanism.
[0096] Distance encoding serves as an attention weight adjustment factor (i.e., a bias term). These factors dynamically adjust the model's attention mechanism based on the actual distribution and error range of rebar spacing, enabling the model to prioritize feature areas that match the expected spacing distribution, improving its perception of rebar row and column patterns. After the backbone extracts the P5 features, it undergoes feature processing to cues attention to distance. After CCFF feature fusion, it enters the decoder and outputs the detection results.
[0097] Step 3: Model training and application
[0098] The loss function constructed based on the target detection task is used to guide model training. The training process uses the back propagation algorithm to optimize the network parameters and uses the distribution-aware DIOU loss as the loss function to obtain a trained model for completing the target detection task. The detection results are as follows: Figure 8 shown.
[0099] The detection results are converted using the pixel accuracy of the industrial camera to obtain the actual length of the steel bar in the image, thereby completing the quality inspection. Specifically, the physical size of the industrial camera sensor is determined by its resolution and pixel size. Assume that the long side resolution of the sensor is R long , the short side resolution is R short , the physical size of each pixel is T, then the physical sizes of the long and short sides of the camera sensor can be calculated by the following formulas:
[0100] R long =R short *T
[0101] L long =L short *T
[0102] In addition, the camera's field of view (FOV) is determined by the sensor's physical size, focal length, and working distance. The size of the FOV directly affects the range of scenes that the camera can capture, which in turn affects the coverage area of image acquisition. Specifically, the long and short sides of the FOV can be calculated using the following formula:
[0103]
[0104] Among them, FOV long and FOV short Represent the long and short sides of the field of view, N is the working distance of the camera, and f is the focal length of the camera. Then, the actual size X represented by the unit pixel can be calculated:
[0105]
[0106] After obtaining X, the detection frame position is obtained through target detection. The coordinate information is converted into pixel information to obtain the number of pixels in the detection frame length. Then, the steel bar size can be obtained. By comparing it with the standard value in the drawing, it can be determined whether the protruding steel bars of the component are qualified.
[0107] The change curves of various indicators of the improved RTDETR network model during 100 rounds of training are as follows: Figure 6As shown in the figure, the loss function curve steadily and rapidly decreases during training, verifying the stability of the model. Evaluation metrics such as FPS, precision, recall, and mean and mean absolute error (MAE) rapidly improve, demonstrating the model's strong learning ability and significant training results. Overall, the model achieved high performance in a short period of time, with rapid convergence and efficient training. This demonstrates that under the current training configuration, the model has good convergence and generalization capabilities.
[0108] The mean absolute error (MAE) is calculated as follows:
[0109] The actual size of the steel bar is measured and tested. i (i∈(0…N)), N is the number of steel bars in the test set, and the true size C' of the corresponding steel bar is calculated by pixel conversion i , the calculation formula is:
[0110]
[0111] The operating environment of this embodiment is the Linux system, and uses the NVIDIA4070Ti graphics card, the deep learning framework is Pytorch, and the specific hardware configuration is shown in Table 1:
[0112] Table 1
[0113]
[0114] Evaluation indicators: The real-time performance of the algorithm is evaluated by calculating the frame rate (fps). From Table 2, it can be seen that the inference speed of the proposed model reaches 33 FPS, which is 3.13%, 50.00%, 22.22% and 17.86% higher than RTDETR (32), YOLOv5 (22), YOLOv8 (27) and YOLOv11 (28), respectively. This shows that the proposed method has good real-time performance advantages while maintaining higher detection accuracy.
[0115] The proposed model achieved a higher precision (0.964) than RTDETR (0.953), and a similar recall (0.915) compared to RTDETR (0.914), demonstrating that the proposed model improves detection accuracy while maintaining high recall. The proposed model achieved a MAE of 3.1 mm, meeting the measurement error specification and significantly lower than RTDETR's 4.5 mm, representing a 28.9% reduction in error. This demonstrates more accurate detection results, greater sensitivity to slender objects, and improved error control.
[0116] Table 2 shows the comparison of evaluation results of different models
[0117]
[0118] Any matters not described in the present invention are applicable to the prior art.
Claims
1. A steel bar size quality detection method based on improved RTDETR, characterized by: The detection method comprises the following steps: Step 1: Obtain images of protruding steel bars from different precast concrete components, annotate the steel bar detection frames and pixel lengths, and obtain a component steel bar dataset. Step 2: Build an improved RTDETR network model. In the backbone of the improved RTDETR network model, four SteelNet modules are connected in series after the maximum pooling layer. The outputs of the last three SteelNet modules are input into the CCFM module and the AIFI attention module respectively after convolution processing. After being processed by the CCFM module, they enter the decoder to obtain the detection results. The input of the SteelNet module is subjected to P convolution to generate a mask using the image's own features, and feature calculation is performed in the effective area. On the other hand, after normalization and the output of the dynamic direction-aware deformable convolution block, it is divided into two branches. One branch is processed by a fully connected layer, and the other branch is processed by a fully connected layer and a SiLU activation function. The outputs of the two branches are multiplied element-by-element and processed by the fully connected layer, and then added element-by-element to the P convolution output to obtain the output of the SteelNet module. The dynamic direction-aware deformable convolution block includes a direction-aware module, which randomly samples input features to obtain random sampling points. The direction-aware module includes a convolution layer, a normalization layer, and a direction-aware template. Each sampling point corresponds to a local area of the image. The convolution layer extracts features. The feature map processed by the convolution layer is normalized to learn the probability distribution of D directions for each pixel position. The probability distribution is used as a direction weight and combined with the D direction-aware templates to dynamically generate an offset direction with structural preference to obtain the output of the direction-aware module. Then, the offset direction output by the direction perception module is concatenated with the sampling point to form a modulation factor to guide the offset size and obtain features with offset. The features with offsets and the input are used as the input of a fully connected layer. After processing by the fully connected layer, the first feature is obtained. The results of the random sampling points processed by the fully connected layer and the normalization layer are aggregated with the first feature to obtain the output of the dynamic direction-aware deformable convolution block. The self-attention mechanism in the AIFI attention module is replaced with a distance-cued attention mechanism. The distance-cued attention mechanism introduces the spacing information of the steel bar grid and uses the regularity of the steel bar arrangement to form a distance code. It can dynamically adjust the distribution of attention areas during the network learning process, so that it can adaptively strengthen the attention to specific areas when processing regular steel bar layouts. Step 3: Model training and application The model is trained using the component steel bar dataset, and the trained model is used to perform steel bar detection on images of protruding steel bars of the precast concrete component to be identified to obtain steel bar sizes.
2. The detection method according to claim 1, wherein The direction-aware template d i is defined as: Wherein, D is set to 8, i represents any one of the eight directions, and i=0, 1, 2, 3...7 represent the eight directions of up, down, left, right, upper left, lower left, upper right, and lower right respectively.
3. The detection method according to claim 1, wherein The process of the distance-cue attention mechanism is: Obtain the steel network of different types of precast concrete components, determine the number of steel bars protruding from them, and then obtain the set of pixel spacing of steel bars. N is the number of steel bars minus 1. The pixel spacing set is fitted using a Gaussian model to obtain the prior Gaussian formula P(S): Among them, π e 、μ e , σ e They represent the weight, mean, and standard deviation of the e-th Gaussian component respectively; P represents the probability density; S represents the pixel distance; E represents the number of Gaussian components; The prior Gaussian formula P(S) is integrated into the attention mechanism. The result of the upper convolution processing of the AIFI attention module is used to obtain the position of each pair of query q and key k, and the spatial Euclidean distance D between the query position and the key position is calculated. qk : (x k ,y k ) represents the query location coordinates, (x q ,y q ) represents the position coordinates of the key; Get D qk After that, it is restored to the pixel distance S qk , for pixel distance S qk The smoothing term ε is introduced, and the pixel distance S between the query position and the key position is qk +ε is substituted into the prior Gaussian formula P(S) to calculate its probability P, which represents the possibility that the spacing between the two steel bars complies with the rule; Performing a pairwise operation logP on the probability P, using logP as the distance encoding, and using the distance encoding as the bias term of the attention mechanism, the expression of the distance prompt attention mechanism is: Among them, K and Q are key vector and query matrix respectively, d represents vector dimension, α qk Represents the attention weight of the output of the distance-cued attention mechanism.
4. The detection method according to claim 1, wherein Use a high-resolution industrial camera to acquire images, so as to obtain the detailed features of the steel bars including edge information and surface texture, and perform orthogonal processing. The pixel accuracy is not less than 0.5mm, and the detection frame is close to both ends of the steel bars.
5. The detection method according to claim 1, wherein Distribution-aware DIOU loss is used as the loss function during training.