A stone damage location extraction method based on opencv and target detection

Through opencv and object detection technology, combined with threshold mask and peripheral color screening algorithm, the problems of difficult detection, extraction and grading of stone damage are solved, and the precise positioning and automatic classification and grading of stone damage are realized, and the historical buildings are improved. Injury patrol efficiency.

CN118918400BActive Publication Date: 2024-12-06SHANGHAI CONSTRUCTION FOURTH CONSTRUCTION GROUP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411420696.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2024-12-06
Estimated Expiration
2044-10-12

AI Technical Summary

Technical Problem

The existing technology is difficult to accurately detect and classify the size and shape of stone damage, resulting in high cost and time-consuming damage inspection and recording of historical buildings, and lack of automated solutions.

Method used

Using opencv and object detection methods, through model training and object detection, combined with threshold mask extraction and peripheral color screening algorithm, the positioning, extraction and automated classification and grading of stone damage are achieved.

Benefits of technology

It realizes accurate positioning and automated classification and grading of stone damage, reduces inspection costs and time, and improves manhole quality and installation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918400B_ABST
    Figure CN118918400B_ABST
Patent Text Reader

Abstract

The present invention relates to a method for locating and extracting stone damage based on opencv and target detection, which comprises: after collecting newly added damage picture samples, firstly, obtaining detection results through target detection on the pictures, then filtering low-confidence detection results and merging adjacent damages to obtain more accurate damage frames, cutting into blocks according to the damage frames, numbering each block, and then calling different opencv algorithms to extract masks according to different types of damage; then, combining the targets in the pictures, identifying the target position and range through the opencv method, and inferring the damage size according to the target size, so as to realize the judgment of the damage level. This method realizes the effective detection of stone damage, obtains the damage type and severity level; provides a feasible solution for intelligent identification of building damage; compared with traditional damage identification, it realizes the accurate extraction of the damage area and the estimation of the actual size of the damage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of building construction, and in particular relates to a stone damage positioning and extraction method based on OpenCV and target detection. Background Art

[0002] my country has a huge stock of historical buildings with rich structures and a wide variety of types. They are an important part of historical culture and humanities. Among them, stone is widely used in historical buildings. As a natural material, it has been an important material in the field of construction since ancient times due to its high hardness and durability. During the use of historical buildings, with the passage of time, due to the deterioration of material properties and the influence of the external environment, stone materials will also suffer various degrees of damage, mainly manifested as rust spots, epiphyses, cracks and other apparent damage. In order to better protect historical buildings, it is necessary to inspect, record, archive and analyze the apparent damage. This mainly relies on manual regular photography of buildings and measurement of damage size, relying on manual experience to judge the type of damage and measure the size of damage, which is costly and time-consuming.

[0003] Although the current simple target detection method can detect the type of damage, it cannot accurately determine the size of the damage, the specific shape, and the classification of the damage.

[0004] Therefore, how to provide a stone damage location extraction method based on opencv and target detection to improve the quality of manholes and speed up installation efficiency is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention

[0005] In view of the problems that it is difficult to detect, extract and grade the surface damage of stone, the present invention proposes a stone damage positioning and extraction method based on OpenCV and target detection, which realizes the positioning and extraction of damage, and directly measures the damage area, length and width with the help of target targeting, thereby realizing the automatic classification and grading of damage, providing a practical solution for the detection of various surface damages of stone, and providing feasibility for the automatic extraction of surface damages of historical buildings.

[0006] In order to solve the above technical problems, the present invention includes the following technical solutions:

[0007] A stone damage location extraction method based on OpenCV and target detection includes the following steps:

[0008] Step S1, model training: collect a large number of stone image samples containing damage, annotate the damaged parts in the images with target boxes, and form a training data set; select a target detection model, input the annotated training data set into the target detection model for training, and generate a target detection model for stone damage;

[0009] Step S2, target detection: collect newly added damage pictures, and input the pictures into the target detection model to obtain damage intelligent recognition results, including detection type, damage location and confidence data, and mark the damage location in the form of a rectangular target frame;

[0010] Step S3, data filtering: setting a target detection threshold. When the confidence of the target detection result is less than the target detection threshold, filtering the detection results with low confidence to prevent the introduction of noise, thereby controlling the credibility of the detection result.

[0011] Step S4, target frame merging: In order to facilitate apparent damage management and analysis, the same type of damage with adjacent target frames and overlapping areas is regarded as the same damage data and its data is merged, but the target frames of attached damage are distinguished;

[0012] Step S5, damage morphology extraction: on the basis of obtaining the target detection frame, according to the characteristics of different damage categories, two methods, namely threshold mask extraction and peripheral color screening, are used to extract the damage morphology area;

[0013] Step S6, target acquisition: based on the threshold mask extraction method, the recognition target is acquired. Targets of different shapes correspond to different sizes. The ratio of the pixel point and the actual size, i.e., the pixel resolution, is inferred from the size of the target.

[0014] Step S7, index calculation: Calculate the number of pixels in the damage range based on the damage morphology mask, and then convert it into the actual size of the damage in combination with the pixel size ratio of the target, and grade the damage according to the actual size.

[0015] Furthermore, in step S1, the damaged part in the image is labeled with a target frame using the labelImg tool.

[0016] Furthermore, the target detection model selected in step S1 is yolov8.

[0017] Furthermore, in step S4, the target frame merging process includes:

[0018] The first step is to detect the target and obtain the target frame;

[0019] Step 2: Group target boxes by category;

[0020] Step 3: Determine the intersection of the target frame boundaries;

[0021] Step 4: merging the same damaged target frames; and

[0022] Step 5: Reconstruct the test results.

[0023] Furthermore, step S5 includes: for damage with obvious color characteristics, including rust spots and overgrowth, a threshold mask extraction algorithm is used; for damage with unclear color characteristics, including cracks and improper repairs, a peripheral color screening algorithm is used to finally obtain a damage morphology mask.

[0024] Furthermore, the threshold mask extraction algorithm includes:

[0025] The first step is to collect samples larger than 50 photos;

[0026] Step 2: Analyze samples to extract RGB / HSV;

[0027] Step 3: Remove abnormal values ​​or false contacts;

[0028] Step 4: Extract the mask, i.e. the loss shape mask;

[0029] Step 5: Open the calculation to denoise.

[0030] Furthermore, the surrounding color screening algorithm includes:

[0031] The first step is to obtain the target frame coordinates;

[0032] Step 2: Extract the average RGB / HSV around the target box;

[0033] Step 3: Calculate the color difference between the target library point and the environment;

[0034] Step 4: Extract RGB and HSV masks, i.e. lossy morphological masks, and merge them;

[0035] Step 5: Open the calculation to denoise.

[0036] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0037] The present invention provides a method based on target detection and opencv. After collecting newly added damage picture samples, the picture is first subjected to target detection to obtain detection results, and then low-confidence detection results are filtered and adjacent damages are merged to obtain a more accurate damage frame. The damage frame is cut into pieces, and each piece is numbered. Then, different opencv algorithms are called to extract masks according to different types of damage. Then, the target position and range are identified by the opencv method in combination with the target in the picture, and the damage size is inferred according to the target size, so that the damage level can be judged. The stone damage location extraction method based on opencv and target detection realizes effective detection of stone damage, obtains damage type and severity level, provides a feasible solution for intelligent identification of building damage, and realizes accurate extraction of damage area and estimation of actual damage size compared with traditional damage identification. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 This is a flow chart of a method for locating and extracting stone damage based on opencv and target detection according to an embodiment of the present invention;

[0039] Figure 2 It is a schematic diagram of target detection in a stone damage location extraction method based on opencv and target detection according to an embodiment of the present invention;

[0040] Figure 3 It is a schematic diagram of target frame merging in a stone damage location extraction method based on opencv and target detection according to an embodiment of the present invention;

[0041] Figure 4 This is a flow chart of target frame merging in a method for locating and extracting stone damage based on opencv and target detection according to an embodiment of the present invention;

[0042] Figure 5 It is a schematic diagram of damage morphology extraction in a stone damage location extraction method based on opencv and target detection according to an embodiment of the present invention;

[0043] Figure 6 It is a schematic diagram of a threshold mask extraction algorithm in a stone damage location extraction method based on opencv and target detection according to an embodiment of the present invention;

[0044] Figure 7 This is a schematic diagram of a peripheral color screening algorithm in a stone damage location extraction method based on opencv and target detection in one embodiment of the present invention;

[0045] Figure 8 This is a sample image of a target example in a stone damage location extraction method based on opencv and target detection according to an embodiment of the present invention. DETAILED DESCRIPTION

[0046] The following is a further detailed description of a stone damage location extraction method based on OpenCV and target detection provided by the present invention in conjunction with the accompanying drawings and specific embodiments. According to the following description, the advantages and features of the present invention will become clearer. It should be noted that the accompanying drawings are all in a very simplified form and use non-precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention. For the convenience of description, the "upper" and "lower" described below are consistent with the upper and lower directions of the accompanying drawings, but this cannot be a limitation of the technical solution of the present invention. Embodiment 1

[0047] Combine the following Figures 1 to 8 , the stone damage location and extraction method based on OpenCV and target detection of the present invention is described in detail.

[0048] Main idea: Based on target detection and opencv methods, after collecting the newly added damaged images, the image samples are first subjected to target detection to obtain the detection results, and then the low-confidence detection results are filtered and the adjacent damages are merged to obtain a more accurate damage frame. The damage frame is cut into pieces, and each piece is numbered. Then different opencv algorithms are called to extract masks according to different types of damage. Finally, combined with the targets in the image, the target position and range are identified through the opencv method, and the damage size is inferred based on the target size, so that the damage level can be judged.

[0049] A stone damage location extraction method based on OpenCV and target detection includes the following steps:

[0050] Step S1, model training: collect a large number of stone image samples containing damage, annotate the damaged parts in the images with target boxes, and form a training data set; select a target detection model, input the annotated training data set into the target detection model for training, and generate a target detection model for stone damage;

[0051] Step S2, target detection: collect newly added damage pictures, and input the pictures into the target detection model to obtain the damage intelligent recognition results, including the detection type, damage location and confidence data, and mark the damage location in the form of a rectangular target frame, such as Figure 2 As shown;

[0052] Step S3, data filtering: setting a target detection threshold. When the confidence of the target detection result is less than the target detection threshold, filtering the detection results with low confidence to prevent the introduction of noise, thereby controlling the credibility of the detection result.

[0053] Step S4, target frame merging: In order to facilitate apparent damage management and analysis, the same type of damage with adjacent target frames and overlapping areas is regarded as the same damage data and its data is merged, but the epitaxial damage target frame is distinguished; the adjacent crack damage target frames are merged to form a final Figure 3 The yellow target box in the right figure represents the crack, and the target box for the attached damage is distinguished, such as Figure 3 The green target box in the right image represents epiphytes.

[0054] Step S5, damage morphology extraction: on the basis of obtaining the target detection frame, according to the characteristics of different damage categories, the two methods of threshold mask extraction and peripheral color screening are comprehensively applied to extract the damage morphology area; for damage with obvious color characteristics, such as rust spots, overgrowth, etc., the threshold mask extraction algorithm is used, and for damage with unclear color characteristics, such as cracks and improper repairs, the peripheral color screening algorithm is used to finally obtain the damage morphology mask, that is, the damage morphology range is as follows Figure 5As shown in Figure 2, the damage morphology extraction algorithm logic is as follows: Figure 6 , Figure 7 shown.

[0055] Step S6, target acquisition: In order to adapt to the on-site mobile equipment collection, the actual size of the damage is converted by the target. Figure 8 As shown, the recognition target is obtained based on the threshold mask extraction method. Targets of different shapes correspond to different sizes. The ratio of the pixel point and the actual size, i.e., the pixel resolution, is inferred from the size of the target.

[0056] Step S7, index calculation: Calculate the number of pixels in the damage range based on the damage morphology mask, and then convert it into the actual size of the damage in combination with the pixel size ratio of the target, and grade the damage according to the actual size.

[0057] Furthermore, in step S1, the damaged part in the image is labeled with a target frame using the labelImg tool.

[0058] Furthermore, the target detection model selected in step S1 is yolov8.

[0059] Furthermore, in step S4, the target frame merging process includes:

[0060] The first step is to detect the target and obtain the target frame;

[0061] Step 2: Group target boxes by category;

[0062] Step 3: Determine the intersection of the target frame boundaries;

[0063] Step 4: merging the same damaged target frames; and

[0064] Step 5: Reconstruct the test results.

[0065] Furthermore, step S5 includes: for damage with obvious color characteristics, including rust spots and overgrowth, a threshold mask extraction algorithm is used; for damage with unclear color characteristics, including cracks and improper repairs, a peripheral color screening algorithm is used to finally obtain a damage morphology mask.

[0066] Furthermore, the threshold mask extraction algorithm includes:

[0067] The first step is to collect samples larger than 50 photos;

[0068] Step 2: Analyze samples to extract RGB / HSV;

[0069] Step 3: Remove abnormal values ​​or false contacts;

[0070] Step 4: Extract the mask, i.e. the loss shape mask;

[0071] Step 5: Open the calculation to denoise.

[0072] Furthermore, the surrounding color screening algorithm includes:

[0073] The first step is to obtain the target frame coordinates;

[0074] Step 2: Extract the average RGB / HSV around the target box;

[0075] Step 3: Calculate the color difference between the target library point and the environment;

[0076] Step 4: Extract RGB and HSV masks, i.e. lossy morphological masks, and merge them;

[0077] Step 5: Open the calculation to denoise.

[0078] This stone damage location and extraction method based on OpenCV and target detection solves the problems of difficult detection, extraction and classification of stone surface damage, realizes the location and extraction of damage, and directly measures the damage area, length and width with the help of target targeting, realizes the automatic classification and grading of damage, provides a practical solution for the detection of various surface damages of stone, and provides feasibility for the automatic extraction of surface damage of historical buildings.

[0079] The above examples are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. The above embodiments only express several embodiments of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for those of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A stone damage location extraction method based on OpenCV and target detection, characterized in that: The steps include: Step S1, model training: collect a large number of stone image samples containing damage, mark the damaged parts in the images with target boxes, and form a training data set; Select a target detection model, input the labeled training data set into the target detection model for training, and generate a target detection model for stone damage; Step S2, target detection: Collect newly added damage images and input them into the target detection model to obtain intelligent damage recognition results, including detection type, damage location, and confidence data. The damage location is marked in the form of a rectangular target frame. Step S3, data filtering: set the target detection threshold. When the confidence level of the target detection result is less than the target detection threshold, filter the detection results with low confidence level to prevent the introduction of noise. Step S4, target frame merging: To facilitate apparent damage management and analysis, adjacent target frames with overlapping areas of the same type of damage are considered as the same damage data and their data are merged, but target frames of attached damage are distinguished; Step S5, Damage Morphology Extraction: Based on the target detection frame, the damage morphology area is extracted by combining threshold mask extraction and peripheral color screening according to the characteristics of different damage categories. For damages with obvious color characteristics, the threshold mask extraction algorithm is used; for damages with unclear color characteristics, the peripheral color screening algorithm is used to finally obtain the damage morphology mask. Step S6, target acquisition: The recognition target is acquired based on the threshold mask extraction method. Targets of different shapes correspond to different sizes. The ratio of the pixel points to the actual size, i.e., the pixel resolution, is inferred from the size of the target. Step S7, index calculation: Calculate the number of pixels in the damage range based on the damage morphology mask, and then convert it into the actual size of the damage in combination with the pixel size ratio of the target, and grade the damage according to the actual size.

2. The method according to claim 1, characterized in that In step S1, the damaged part in the image is marked with a target frame using the labelImg tool.

3. The method according to claim 1, characterized in that The target detection model selected in step S1 is yolov8.

4. The method according to claim 1, wherein In step S4, the target frame merging process includes: The first step is target detection to obtain the target frame; Step 2: Group target boxes by category; Step 3: Determine the intersection of the target frame boundary; Step 4: Merge the same damage target frames; and Step 5: Reconstruct the test results.

5. The method according to claim 1, wherein The step S5 includes: for damage with obvious color characteristics, including rust spots and overgrowth, using a threshold mask extraction algorithm; for damage with unclear color characteristics, including cracks and improper repairs, using a peripheral color screening algorithm, and finally obtaining a damage morphology mask.

6. The method according to claim 5, characterized in that The threshold mask extraction algorithm includes: The first step is to collect more than 50 samples; Step 2: Analyze samples and extract RGB / HSV; Step 3: Remove abnormal values ​​or false contacts; The fourth step is to extract the mask, that is, the loss shape mask; Step 5: Start denoising.

7. The method according to claim 5, characterized in that The peripheral color screening algorithm includes: The first step is to obtain the target frame coordinates; Step 2: Extract the average RGB / HSV around the target box; Step 3: Calculate the color difference between the target points and the environment; Step 4: Extract the RGB and HSV masks, i.e. the lossy morphological masks, and merge them; Step 5: Start denoising.

Citation Information

Patent Citations

  • Method for measuring rock damage degree under blasting disturbance

    CN114324483A

  • Method for quantitative calculation of rock aging damage based on image recognition technology

    CN118706601A