Image recognition method for steel bars
By combining target detection, morphological processing, and OCR recognition methods, the problem of low efficiency in steel bar drawing recognition in highway engineering was solved. It achieved automated and integrated recognition of steel bar shape and parameters, improved recognition efficiency and accuracy, and output structured data.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NINGBO HIGHWAY CONSTR MANAGEMENT CENT
- Filing Date
- 2026-05-06
- Publication Date
- 2026-06-02
AI Technical Summary
In the current technology, the identification and input of steel reinforcement drawings in the design and construction of highway engineering mainly rely on manual methods, which are inefficient and prone to errors. Existing OCR technology is difficult to effectively extract the shape and parameter information of steel reinforcement and lacks geometric relationship capabilities.
This method combines target detection, morphological processing, and OCR recognition. By identifying parameter annotations and contours in rebar images, and utilizing the GIoU loss function to enhance target detection capabilities, it enables automated recognition of rebar shape and parameters, including contour dilation and connected component analysis, ensuring the accuracy and completeness of the recognition.
It achieves automated and integrated identification of rebar shape and parameters, improves identification efficiency and accuracy, reduces the rate of missed detection and false identification, reduces manual intervention, and outputs structured data.
Smart Images

Figure CN122135374A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image recognition technology, and specifically relates to an image recognition method for reinforcing bars. Background Technology
[0002] In the design, construction, and review of highway engineering drawings, the rebar numbering, length, and diameter information are key parameters. Currently, these data are typically identified and entered manually, a process that is tedious, error-prone, and inefficient. Although some OCR-based image-text recognition methods have been applied to drawing recognition, the complex structural relationships between highway rebar information ("graphics-numbering-parameters," etc.) make effective extraction difficult using only OCR. Current drawing recognition systems on the market mostly focus on text recognition, lacking geometric relationship capabilities. Therefore, there is an urgent need for an automated extraction technology that combines object detection, connected component analysis, and OCR recognition to achieve integrated identification of the shape of highway rebar and its numbering and parameters, thereby improving automation, accuracy, and reducing manual data entry time. Summary of the Invention
[0003] To address the shortcomings of existing technologies and achieve integrated identification of rebar shape extraction, rebar numbering, and its parameters, thereby improving identification efficiency and accuracy, this invention adopts the following technical solution:
[0004] An image recognition method for reinforcing bars;
[0005] Acquire images of reinforcing bars with parameter annotations, identify the parameter annotations of the reinforcing bars in the images, and expand the range of the parameter annotations based on the pixel density around the parameter annotations;
[0006] The steel bar outline in the steel bar image is identified. Based on the overlap relationship between the steel bar outline and the extended parameter annotation, the steel bar outline and parameter annotation are matched to obtain the main outline containing the steel bar outline and parameter annotation.
[0007] Contour expansion is performed on the main contour to retrieve candidate influence regions from other parameter annotations;
[0008] Based on the overlap between the main contour and the candidate influence domain, other parameters falling into the candidate response domain are labeled and matched with the rebar contour.
[0009] Furthermore, parameter annotations are identified in the form of parameter boxes. The parameter boxes are expanded based on the pixel density around them to obtain a local analysis region containing annotation lines. The identified rebar contours contain annotation lines connected to the rebar structure. Based on the overlap between the rebar contours and the parameter boxes, a main contour containing the rebars and parameter annotations is obtained. The main contour is expanded to retrieve other parameter boxes that may belong to the current rebar, ensuring complete coverage of local rebar parameter boxes while avoiding noise interference, thus obtaining a candidate influence domain.
[0010] Furthermore, the categories of parameter annotation include the rebar number. The rebar image is identified by the trained target detection model to obtain a set of parameter boxes. Based on the confidence of the parameter boxes, the parameter box with the highest confidence of category number is selected as the main control region. Based on the pixel density of the neighboring pixels around the main control region, the region of the main control region is expanded to obtain the local analysis region. The analysis range is limited by the density index of the neighboring rebars to ensure complete coverage of the rebar target and reduce noise interference, thereby improving the model's generalization ability and making it applicable to all rebar categories and rebar shapes that meet the current characteristics.
[0011] Furthermore, the categories of the parameter annotations include the number and size of the reinforcing bars. The candidate influence domain is generated by using the parameter annotations categorized as number and the reinforcing bar outline. Valid size parameter annotations are identified from the candidate influence domains and matched with the reinforcing bar outline. Based on the combination of number parameter annotations and size parameter annotations, the consistency of the reinforcing bar outline parameter annotations is verified.
[0012] Furthermore, parameter annotations are identified in the form of numbered boxes, and dimension parameter annotations are identified in the form of dimension boxes. Based on preset values, the dimension parameter boxes are filtered by shape, area, and boundary trimming, and the dimension boxes with a preset distance from the numbered boxes are retained.
[0013] Furthermore, the identification of the rebar contour involves sequentially converting the rebar image to grayscale and then to binarization, and then identifying the rebar contour based on the obtained binary image. The overlapping relationship between the contour and the area where the parameter annotation is located is determined, and the main contour containing the rebar and parameter annotation is selected and simplified to reduce redundant contour points, improve the efficiency of subsequent expansion and overlap calculations, and ensure accurate and complete identification of the rebar shape.
[0014] Furthermore, the contour dilation is performed by setting the elliptical kernel and the dilation radius to morphologically dilate the main contour, so as to obtain a candidate influence domain that may contain other parameter annotations.
[0015] Furthermore, the images of the reinforcing bars and the parameter annotations of the reinforcing bars in the images are obtained to construct a target reinforcing bar annotation dataset. Based on the target reinforcing bar annotation dataset, a target detection model is constructed and trained for the recognition of parameter boxes in the reinforcing bar images. The trained target detection model is used to identify the parameter boxes in the reinforcing bar images.
[0016] Furthermore, a loss function is constructed to train the object detection model. The loss function divides the difference between the union of the predicted parameter box area and the true parameter box area and the minimum closed area by the minimum closed area, and then the difference between the result and the intersection-union ratio of the predicted parameter box area and the true parameter box area is used to construct the generalized intersection-union ratio (GIoU) loss function. This uses GIoU to solve the problem that IoU cannot accurately reflect the degree of overlap, thereby enhancing the high-precision object detection capability of rebar images.
[0017] Furthermore, text recognition is performed on the parameter annotations, and structured rebar parameter data is generated based on the matching of rebar outlines and parameter annotations for subsequent topology modeling and parameter statistics.
[0018] The advantages and beneficial effects of this invention are as follows:
[0019] This invention provides an image recognition method that combines target detection, morphological processing, and OCR recognition, solving the problem of difficulty in extracting the shape and parameters of steel bars in highway engineering in the prior art. By establishing a mapping between geometric topology analysis and semantic text extraction, the image analysis is endowed with geometric cognitive ability, thereby automatically recognizing the shape, number, length, diameter and other parameter information of steel bars in highway engineering images, maintaining data correlation, and finally outputting structured data, thus improving recognition efficiency and accuracy. Attached Figure Description
[0020] Figure 1 This is a flowchart of the method in an embodiment of the present invention.
[0021] Figure 2 This is the main number box corresponding to the number in the embodiment of the present invention.
[0022] Figure 3 This is an expanded main numbering frame in this embodiment of the invention, which includes the partial connection between the numbers and the reinforcing bars. Detailed Implementation
[0023] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0024] like Figure 1 As shown, an image recognition method for reinforcing bars, based on the Python programming language and using Flask as the backend framework to encapsulate image upload and recognition API services, specifically includes the following steps:
[0025] Step S1: Identify and prepare sample data for steel reinforcement.
[0026] Input: Original project image I, with dimensions of 1632×1152 px, including reinforcement pattern drawings and related engineering annotations.
[0027] deal with:
[0028] 1. Use the Labelme annotation tool to annotate the image. Taking cylindrical steel bars as an example, set the label categories to: "Number", "Diameter", and "Length".
[0029] 2. Generate a labeled dataset D for each rebar target. label Each data entry contains:
[0030] Number box information points (x i , y i , w i , h i ), (x i , y i ) represents the coordinates of the center point of the number box, w i h represents the width of the number box. i Indicates the height of the number box;
[0031] The corresponding category label ∈ {number, diameter, length}, for example: number is 101, length is 250 mm, diameter is 12 mm).
[0032] Output: Annotated dataset D label ;
[0033] Function: To generate training data to ensure that subsequent model training can learn the relationship between the features of the steel structure and the annotation.
[0034] Step S2: Training and deployment of the object detection model.
[0035] Input: Labeled dataset D label ;
[0036] deal with:
[0037] 1. Using the PicoDet network structure in the PaddlePaddle framework, combined with the lightweight optimization scheme of PP-YOLOE Lite, the dataset D was optimized. label Conduct training;
[0038] 2. The Anchor-free framework combines the GIoUoss loss function to optimize the accuracy of small object detection. GIoU is defined as follows:
[0039]
[0040] Where: A and B represent the areas of the predicted box and the ground truth box, respectively, and C represents the area of the smallest closed rectangle between A and B.
[0041] Improvement: Use GIoU to solve the problem that IoU cannot accurately reflect the degree of overlap;
[0042] 3. After training, export the object detection model as a PaddleInference format using FastDeploy and deploy it as a service interface in a Docker container;
[0043] Output: Object detection service interface available for inference;
[0044] Function: This step enhances the ability to detect high-precision targets in rebar images compared to existing technologies.
[0045] Step S3: Image recognition and main control region extraction.
[0046] Input: User-uploaded image I upload ;
[0047] deal with:
[0048] 1. Input the image into the deployment model, perform forward inference, and obtain the set of bounding boxes R = {(x i ,y i ,w i ,h i C i ,conf i )}, C i The category label indicates which category the detection box predicts the target belongs to;
[0049] 2. Assign confidence levels to the bounding box using the `conf` parameter. i Sort in descending order and select the highest confidence box for category "Number" as the main control area (main number box). m ,y m ,w m ,h m );
[0050] 3. Since the selected main numbering box only contains the numbered digits, and the numbering labels often do not have a direct connection with the reinforcing bars, it is necessary to expand the main numbering box to obtain the local analysis area R. local Size can be adjusted automatically:
[0051] R local = k1·w m + k2·h m + k3·σ near
[0052] Where, σ nearThis represents the pixel density index surrounding the main numbered frame. k1, k2, and k3 are empirical coefficients, and the local analysis region R... local Not only from the width of the main number box w m and length h m The angular expansion also considers the pixel density around the main numbering frame, that is, the partial connection between the numbered digits and the reinforcing bars, such as... Figure 2 , Figure 3 As shown;
[0053] 4. Reduce interference in local areas to improve the accuracy of subsequent contour extraction;
[0054] Output: Local analysis region R local ;
[0055] Function: It limits the scope of analysis, ensures complete coverage of the rebar targets and reduces noise interference; it improves the generalization ability of the model, and is applicable to all rebar categories and shapes that meet the current characteristics.
[0056] Step S4: Connectivity analysis and reinforcement profile extraction.
[0057] Input: Local analysis region R local ;
[0058] deal with:
[0059] 1. Convert the rebar image to grayscale:
[0060] I gray =0.299R + 0.587G + 0.114B
[0061] 2. Calculate the binarization threshold T using the Otsu algorithm. otsu The binary image I is obtained. bin ;
[0062] 3. Using OpenCV findContours(I bin Extracting the rebar profile set C using RETR_EXTERNAL and CHAIN_APPROX_SIMPLE) all ;
[0063] 4. Determine the overlap between the outline and the numbered frame, and select the main outline C that may contain reinforcing bars. main ;
[0064] 5. Simplify the main outline:
[0065] C simplified =approxPolyDP(C mian ε=0.01·circumference(C) mian ))
[0066] Output: Precise rebar profile set C simplified ;
[0067] Function: Reduce redundant contour points, improve the efficiency of subsequent expansion and overlap calculations, and ensure accurate and complete identification of rebar shape.
[0068] Step S5: Contour morphological dilation (calculate candidate influence regions).
[0069] Input: Reinforcement profile set C simplified ;
[0070] deal with:
[0071] 1. Perform morphological dilation on each contour using a 5×5 elliptical kernel with a dilation radius R. dil Adaptive:
[0072]
[0073] α∈[0.2,0.3]
[0074] Automatically adjusts according to image DPI, for example, when DPI = 300, R... dil = 10~15 px;
[0075] 2. The influence domain E is obtained after expansion. influence This is used to retrieve other parameter annotation boxes that may belong to this rebar.
[0076] Output: Candidate Influence Domain E influence ;
[0077] Function: To ensure complete coverage of the local reinforcement parameter frame, while avoiding noise interference, and to find other parameters within the current reinforcement range.
[0078] Step S6: Candidate box extraction and boundary filtering logic.
[0079] Objective: To extract valid diameter / length bounding boxes from the influence domain, eliminate noise and invalid targets, and maintain their association with rebar numbers;
[0080] Step S6.1: Candidate box retrieval;
[0081] Select detection boxes with the category "diameter" or "length" from the influence domain to serve as the initial candidate set for subsequent filtering and attribution.
[0082] Step S6.2: Candidate box filtering logic;
[0083] Aspect ratio judgment: Exclude frames that are extremely long or flat, or that do not conform to the conventional annotation shape;
[0084] Area filtering: Removes boxes that are too large (e.g., falsely detected as title bars) or too small (e.g., noise points);
[0085] Boundary clipping judgment: If the edge of the box is less than 5px away from the image boundary, it is judged as abnormal and removed;
[0086] Number distance filtering: Only retain targets whose distance from the center point of the nearest number box is less than 100px;
[0087] Category combination consistency check: Only when a combination of "number + diameter" or "number + length" is detected can the identification be considered valid.
[0088] Step S6.3: Parameter classification logic;
[0089] Based on IoU overlap, the outline of the rebar shape in step S4 is matched with the outline of the parameter range extracted in step S5.
[0090] The parameter annotations that fall within the shape outline of the rebar are categorized into the corresponding rebar objects.
[0091] Explanation of the synergistic effect of steps S1 to S6:
[0092] The main number box positioning → local region extraction → connected component analysis → contour dilation are used in conjunction to achieve the following:
[0093] 1. The false negative rate decreased by approximately 10%;
[0094] 2. The accuracy of rebar outline detection is improved by approximately 15%;
[0095] 3. Automatically filter misaligned labels to reduce manual intervention;
[0096] 4. Automatically obtain parameters other than number, diameter, and length.
[0097] Step S7: OCR text recognition and data structure mapping.
[0098] Objective: To convert the retained parameter annotation boxes into standardized text and map them to structural reinforcement parameter data;
[0099] Step S7.1: OCR recognition process;
[0100] 1. Input the retained parameter annotation boxes into PaddleOCR;
[0101] 2. A multi-stage identification process is adopted:
[0102] 3. Direction Classification (Correcting Slanted / Rotated Text);
[0103] 4. Text detection (locating text regions);
[0104] 5. Text recognition (extracting text content).
[0105] Step S7.2: Post-processing of recognition results;
[0106] 1. String cleaning: Remove noise and invalid characters;
[0107] 2. Unit standardization: Unify different representations (such as "Φ25", "φ25") into the standard format "25mm";
[0108] 3. Misspelling correction: Correction based on common confusing logic (such as replacing misidentified "Ø" with "0").
[0109] Step S7.3: Data Structure Mapping
[0110] 1. Associate the cleaned parameter text with the steel bar objects categorized in step S6;
[0111] 2. The output is a structured reinforcement parameter data table, which is used for subsequent topology modeling and parameter statistics.
[0112] Step S8: Structured output.
[0113] Objective: To unify and encapsulate the results of preliminary identification and classification, outputting them as a standardized JSON data structure, facilitating integration with engineering management platforms or drawing review systems, and supporting result traceability and manual review;
[0114] Step S8.1: Output format;
[0115] 1. The output uses a JSON structure;
[0116] 2. Each rebar is treated as a master object (rebar), containing its own category and image coordinate range;
[0117] 3. Its associated parameters such as number, diameter, and length are treated as child objects, and the corresponding confidence level is stored.
[0118] Step S8.2: Coordinates and Origin Tracing;
[0119] 1. The JSON should retain the four boundary coordinate values: xmin, ymin, xmax, and ymax.
[0120] 2. It can be matched one-to-one with the original image, which is convenient for manual verification or subsequent visualization.
[0121] The final identification results are output in JSON format for use by engineering management platforms and drawing review systems. The results can be bound to image coordinates for easy traceability and manual verification.
[0122] Step S8.3: Features and Applications;
[0123] 1. Standardized interface: Adaptable to engineering management platforms and drawing review systems for direct access;
[0124] 2. Traceability: The coordinate and score information supports the interpretation and manual verification of the results;
[0125] 3. Extensibility: Other attribute fields (such as the thickness of the concrete cover and the anchorage method) can be flexibly added.
[0126] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image recognition method for reinforcing bars, characterized in that: Acquire images of reinforcing bars with parameter annotations, identify the parameter annotations of the reinforcing bars in the images, and expand the range of the parameter annotations based on the pixel density around the parameter annotations; The steel bar outline in the steel bar image is identified. Based on the overlap relationship between the steel bar outline and the extended parameter annotation, the steel bar outline and parameter annotation are matched to obtain the main outline containing the steel bar outline and parameter annotation. Contour expansion is performed on the main contour to retrieve candidate influence regions from other parameter annotations; Based on the overlap between the main contour and the candidate influence domain, other parameters falling into the candidate response domain are labeled and matched with the rebar contour.
2. The image recognition method for reinforcing bars according to claim 1, characterized in that: Parameter annotations are identified in the form of parameter boxes. The parameter boxes are expanded based on the pixel density around them to obtain a local analysis region containing the annotation lines. The identified rebar contours contain the annotation lines connected to the rebar structure. Based on the overlap between the rebar contours and the parameter boxes, a main contour containing the rebars and parameter annotations is obtained. The main contour is expanded to retrieve other parameter boxes that may belong to the current rebar, resulting in candidate influence regions.
3. The image recognition method for reinforcing bars according to claim 1, characterized in that: The categories of the parameter annotations include the rebar numbers. The rebar images are identified by a trained target detection model to obtain a set of parameter boxes. Based on the confidence of the parameter boxes, the parameter box with the highest confidence in category number is selected as the main control region. Based on the pixel density of the neighboring pixels around the main control region, the region of the main control region is expanded to obtain the local analysis region.
4. The image recognition method for reinforcing bars according to claim 1, characterized in that: The parameter annotation categories include the rebar number and size. The candidate influence domain is generated by the parameter annotation with the number as the category and the rebar outline. The size parameter annotation is identified from the candidate influence domain and matched with the rebar outline. The consistency of the rebar outline parameter annotation is checked based on the combination of the number parameter annotation and the size parameter annotation.
5. The image recognition method for reinforcing bars according to claim 4, characterized in that: Parameter annotations are identified in the form of numbered boxes, and dimension parameter annotations are identified in the form of dimension boxes. The dimension parameter boxes are filtered by shape, area, and boundary trimming based on preset values, and the dimension boxes with a preset distance from the numbered boxes are retained.
6. The image recognition method for reinforcing bars according to claim 1, characterized in that: The identification of the rebar outline involves sequentially converting the rebar image to grayscale and then to binarization, identifying the rebar outline based on the resulting binary image, determining the overlap between the outline and the area containing the parameter annotations, selecting the main outline containing both the rebar and the parameter annotations, and simplifying it.
7. The image recognition method for reinforcing bars according to claim 1, characterized in that: The contour dilation is performed by setting the elliptical kernel and dilation radius to morphologically dilate the main contour in order to obtain a candidate influence domain that may contain annotations of other parameters.
8. The image recognition method for reinforcing bars according to claim 1, characterized in that: Obtain images of reinforcing bars and their parameter annotations to construct a target reinforcing bar annotation dataset. Based on this dataset, construct and train a target detection model for recognizing bounding boxes in the reinforcing bar images. The trained target detection model then identifies the bounding boxes in the reinforcing bar images.
9. The image recognition method for reinforcing bars according to claim 2, characterized in that: A loss function is constructed to train the object detection model. The loss function is the difference between the union of the predicted parameter box area and the true parameter box area and the minimum closed area, divided by the minimum closed area, and then the difference between the result and the intersection-union ratio of the predicted parameter box area and the true parameter box area is used to construct the generalized intersection-union ratio (GIoU) loss function.
10. The image recognition method for reinforcing bars according to claim 1, characterized in that: Text recognition is performed on the parameter annotations, and structured rebar parameter data is generated based on the matching of rebar outlines and parameter annotations for subsequent topology modeling and parameter statistics.