Building floor recognition method based on feature clustering
By processing building images using the YOLO detection network and clustering algorithm, the problem of reliance on remote sensing images is solved, and high-accuracy building floor identification without the need for remote sensing images is achieved.
Patent Information
- Application Number
- CN202510861341.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-25
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-06-25
AI Technical Summary
Existing technologies rely on remote sensing imagery for inferring the number of floors in a building. However, this imagery is prone to errors and is difficult to obtain, leading to inaccurate identification.
The YOLO detection network is used to segment building images, generate candidate boxes and crop the main building area. Clustering algorithm is used to analyze the bounding boxes of external features and establish a mapping relationship between the number of floors and the number of feature columns.
It can accurately identify the number of floors in a building without the need for remote sensing imagery, improving the accuracy and ease of use of the identification.
Smart Images

Figure CN120726360B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method for identifying building floors based on feature clustering. Background Technology
[0002] With the acceleration of urbanization and the booming development of the real estate industry, the intelligent collection and management of housing information has gradually become an important requirement in fields such as urban planning, disaster assessment, real estate transactions, and urban governance. Among these, the number of floors in a building is a core indicator for measuring building scale, estimating population density, assessing fire risks, and formulating urban planning schemes, and its accurate acquisition has significant practical implications.
[0003] Geometric methods for estimating the number of building floors are commonly used. They typically combine remote sensing information such as UAV and satellite imagery to obtain the total height of the building, and then divide this total height by a preset floor height to determine the number of floors. However, this method has limitations. First, the floor count depends on the preset floor heights, which can lead to inaccuracies in some cases. Furthermore, remote sensing imagery is often inconvenient to obtain for most groups. Therefore, further improvements to existing technologies are needed. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a building floor identification method based on feature clustering that does not require remote sensing images and has a high recognition accuracy, in contrast to the above-mentioned prior art.
[0005] The technical solution adopted by this invention to solve the above-mentioned technical problems is: a building floor identification method based on feature clustering, characterized by the following steps:
[0006] Step 1: Obtain an image of the building to be identified;
[0007] Step 2: Input the image of the building to be identified into the YOLO detection network to generate a set of building candidate boxes. Calculate the Euclidean distance between the center point of each detection box in the set and the geometric center of the building image to be identified. Select the minimum value among all Euclidean distances and use the detection box corresponding to the minimum value as the main building detection area.
[0008] Step 3: Crop the image of the building to be identified according to the main building detection area to obtain the main building image. Input the main building image into the YOLO detection network to obtain the bounding box set S of the external features of the main building.
[0009] Step 4: Perform cluster analysis on the set of bounding boxes S of the external features of the main building to obtain the cluster set C;
[0010] The specific process of cluster analysis is as follows:
[0011] Step 4-1: Sort all bounding boxes in the set S of bounding boxes of the main building's external features in descending order of the ordinate of the center point of the bounding boxes, select the first bounding box after sorting as bounding box w, delete the selected bounding box w from the set S of bounding boxes of the main building's external features, and add the bounding box w to the current column family D. Initially, the current column family D is an empty set.
[0012] Step 4-2: Determine whether the set of bounding boxes S of the current main building's external features is empty. If so, obtain the cluster set C and proceed to step 5. If not, use the set of bounding boxes S of the current main building's external features to generate an adjacent bounding box set A for the selected bounding box w. This adjacent bounding box set A is a set of bounding boxes in the set of bounding boxes S of the current main building's external features that are adjacent to the selected bounding box w. Proceed to step 4-3.
[0013] Step 4-3: Determine if the adjacent bounding box set A is empty. If so, add the current column cluster D to the cluster set C to form a new cluster set C, and proceed to step 4-1. If not, sort all bounding boxes in the adjacent bounding box set A according to the descending order of the ordinate of the center point of the bounding boxes, update the bounding box w with the first bounding box after sorting, add the updated bounding box w to the current column cluster D, update the current column cluster D, and proceed to step 4-4.
[0014] Step 4-4: Delete the updated bounding box w from the bounding box set S of the main building's external features, and proceed to step 4-2;
[0015] Step 5: Calculate the number of bounding boxes in each column of the cluster set C, and take the maximum number of bounding boxes as the number of floors of the building to be identified.
[0016] As an improvement, the specific process of generating the adjacent bounding box set A in step 4-2 is as follows:
[0017] Let A denote the adjacency relationship between bounding box i and bounding box w in the set S of bounding boxes representing the external features of the main building. w,i , i∈S, and i≠w, A w,i The calculation formula is:
[0018]
[0019] Where, r w,i Let w be the overlap between bounding box w and bounding box i in the set of bounding boxes S of the external features of the main building. min(r i ,r w ) is to take ri and r w The minimum value in, max(l) i ,l w ) is to take l i and l w The maximum value in; (l i ,r i () represents the feature projection of bounding box i onto the X-axis of the coordinate system. x i w is the x-coordinate of the center point of bounding box i. i The width of bounding box i; (l w ,r w ) represents the feature projection of the bounding box w onto the X-axis of the coordinate system. x w Let w be the x-coordinate of the center point of the bounding box w. w θ is the width of the bounding box w; θ is the preset overlap threshold.
[0020] If A w,i If the value is 1, then the bounding box i is added to the set of adjacent bounding boxes A.
[0021] Preferably, in step 2, the geometric center Euclidean distance d between the center point of the j-th detection box in the building candidate box set and the image of the building to be identified is... j The calculation formula is:
[0022]
[0023] Among them, (x j ,y j ) represents the coordinates of the center point of the j-th detection box, W represents the image width of the building image to be identified, and H represents the image height of the building image to be identified.
[0024] Preferably, step 5 is followed by the following steps:
[0025] Step 6: Take the average number of bounding boxes in each column of the cluster set C to obtain the average height h;
[0026]
[0027] Where m is the total number of columns in the cluster set C, h i Let be the total number of bounding boxes in the i-th column of the cluster set C;
[0028] Then, the center point y-coordinates of each bounding box in the cluster set C are sorted in descending order. The difference Δy between the center point y-coordinates of each bounding box and the previous bounding box is calculated, and it is determined whether Δy is greater than 1. α is a preset constant. If so, it is determined that there are missing features, and the number of floors of the building to be identified in step 5 is increased by 1 to obtain the final number of floors.
[0029] Preferably, in step 6, only the difference in the ordinate of the center point of the first bounding box and the second bounding box in each column of the cluster set C is calculated.
[0030] Compared with existing technologies, the advantages of this invention are as follows: It employs a YOLO object detection model to segment building instances from the input image, generates background-free building body regions through adaptive cropping, and then uses the YOLO network again to extract external features. A clustering algorithm is then introduced to perform column-based clustering analysis on the point set of external features, establishing a mapping function between the number of feature columns and the number of floors. Therefore, this method does not require remote sensing imagery; it only needs to process the image of the building to be identified to obtain the number of floors. This method is easy to implement and has high recognition accuracy. Attached Figure Description
[0031] Figure 1 This is a block diagram of a building floor identification method based on feature clustering in an embodiment of the present invention. Detailed Implementation
[0032] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0033] like Figure 1 As shown, the building floor identification method based on feature clustering in this embodiment includes the following steps:
[0034] Step 1: Obtain an image of the building to be identified;
[0035] Step 2: Input the image of the building to be identified into the YOLO detection network to generate a set of building candidate boxes. Calculate the Euclidean distance between the center point of each detection box in the set and the geometric center of the building image to be identified. Select the minimum value among all Euclidean distances and use the detection box corresponding to the minimum value as the main building detection area.
[0036] In this embodiment, the YOLO detection network is preferably the YOLOv11 detection network; in this embodiment, the geometric center Euclidean distance d between the center point of the j-th detection box in the building candidate box set and the image of the building to be identified is... j The calculation formula is:
[0037]
[0038] Among them, (x j ,y j Let ) be the coordinates of the center point of the j-th detection box, W be the image width of the building image to be identified, and H be the image height of the building image to be identified;
[0039] Step 3: Crop the image of the building to be identified according to the main building detection area to obtain the main building image. Input the main building image into the YOLO detection network to obtain the bounding box set S of the external features of the main building.
[0040] In this embodiment, the YOLO detection network is preferably the YOLOv11 detection network;
[0041] The external features of the main building include windows, doors, floor lines, etc. For the sake of the versatility of external features, this embodiment only selects doors and windows, the two most prominent external features; for example... Figure 1 As shown, X_center and Y_center are the coordinates of the center point of a bounding box, respectively, and width and height are the width and height of the bounding box.
[0042] Step 4: Perform cluster analysis on the set of bounding boxes S of the external features of the main building to obtain the cluster set C;
[0043] The specific process of cluster analysis is as follows:
[0044] Step 4-1: Sort all bounding boxes in the set S of bounding boxes of the main building's external features in descending order of the ordinate of the center point of the bounding boxes, select the first bounding box after sorting as bounding box w, delete the selected bounding box w from the set S of bounding boxes of the main building's external features, and add the bounding box w to the current column family D. Initially, the current column family D is an empty set.
[0045] Step 4-2: Determine whether the set of bounding boxes S of the current main building's external features is empty. If so, obtain the cluster set C and proceed to step 5. If not, use the set of bounding boxes S of the current main building's external features to generate an adjacent bounding box set A for the selected bounding box w. This adjacent bounding box set A is a set of bounding boxes in the set of bounding boxes S of the current main building's external features that are adjacent to the selected bounding box w. Proceed to step 4-3.
[0046] In this embodiment, the specific process of generating the adjacent bounding box set A is as follows:
[0047] Let A denote the adjacency relationship between bounding box i and bounding box w in the set S of bounding boxes representing the external features of the main building. w,i , i∈S, and i≠w, A w,i The calculation formula is:
[0048]
[0049] Where, r w,iLet w be the overlap between bounding box w and bounding box i in the set of bounding boxes S of the external features of the main building. c w,i =max(min(r) i ,r w )-max(l i ,l w ),0),min(r i ,r w ) is to take r i and r w The minimum value in, max(l) i ,l w ) is to take l i and l w The maximum value in; (l i ,r i () represents the feature projection of bounding box i onto the X-axis of the coordinate system. x i w is the x-coordinate of the center point of bounding box i. i The width of bounding box i; (l w ,r w ) represents the feature projection of the bounding box w onto the X-axis of the coordinate system. x w Let w be the x-coordinate of the center point of the bounding box w. w θ is the width of the bounding box w; θ is the preset overlap threshold.
[0050] If A w,i If the value is 1, then the bounding box i is added to the set of adjacent bounding boxes A;
[0051] The bounding box that is adjacent to the selected bounding box w is the bounding box that has at least local overlap with the bounding box w on the horizontal coordinate.
[0052] Step 4-3: Determine if the adjacent bounding box set A is empty. If so, add the current column cluster D to the cluster set C to form a new cluster set C, and proceed to step 4-1. If not, sort all bounding boxes in the adjacent bounding box set A according to the descending order of the ordinate of the center point of the bounding boxes, update the bounding box w with the first bounding box after sorting, add the updated bounding box w to the current column cluster D, update the current column cluster D, and proceed to step 4-4.
[0053] Step 4-4: Delete the updated bounding box w from the bounding box set S of the main building's external features, and proceed to step 4-2;
[0054] Step 5: Calculate the number of bounding boxes in each column of the cluster set C, and take the maximum number of bounding boxes as the number of floors of the building to be identified.
[0055] After clustering the external feature bounding boxes, the number of floors can be obtained by calculating the number of bounding boxes for these column classes and taking the maximum value. However, since most buildings in the sample are occluded, it is necessary to correct these results. Therefore, the following steps are added after step 5:
[0056] Step 6: Take the average number of bounding boxes in each column of the cluster set C to obtain the average height. ;
[0057]
[0058] Where m is the total number of columns in the cluster set C, h i Let be the total number of bounding boxes in the i-th column of the cluster set C;
[0059] Then, the center point y-coordinates of each bounding box in the cluster set C are sorted in descending order. The difference Δy between the center point y-coordinates of each bounding box and the previous bounding box is calculated, and it is determined whether Δy is greater than 1. α is a preset constant. If so, it is determined that there are missing features, and the number of floors of the building to be identified in step 5 is increased by 1 to obtain the final number of floors.
[0060] In practical applications, considering the spacing changes caused by perspective transformation, directly applying step 6 is not effective. Therefore, in step 6, only the difference in the ordinate of the center point of the first bounding box and the second bounding box after sorting in each column of the cluster set C is calculated.
[0061] This embodiment also relates to a computer-readable storage medium storing a computer program that can be read and executed by a processor. When the computer program is executed by the processor, it implements the building floor identification method based on feature clustering as described above.
[0062] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A building floor identification method based on feature clustering, characterized in that... Includes the following steps: Step 1: Obtain an image of the building to be identified; Step 2: Input the image of the building to be identified into the YOLO detection network to generate a set of building candidate boxes. Calculate the Euclidean distance between the center point of each detection box in the set and the geometric center of the building image to be identified. Select the minimum value among all Euclidean distances and use the detection box corresponding to the minimum value as the main building detection area. Step 3: Crop the image of the building to be identified according to the main building detection area to obtain the main building image. Input the main building image into the YOLO detection network to obtain the bounding box set S of the external features of the main building. Step 4: Perform cluster analysis on the set of bounding boxes S of the external features of the main building to obtain the cluster set C; The specific process of cluster analysis is as follows: Step 4-1: Sort all bounding boxes in the set S of bounding boxes of the main building's external features in descending order of the ordinate of the center point of the bounding boxes, select the first bounding box after sorting as bounding box w, delete the selected bounding box w from the set S of bounding boxes of the main building's external features, and add the bounding box w to the current column family D. Initially, the current column family D is an empty set. Step 4-2: Determine whether the set of bounding boxes S of the current main building's external features is empty. If so, obtain the cluster set C and proceed to step 5. If not, use the set of bounding boxes S of the current main building's external features to generate an adjacent bounding box set A for the selected bounding box w. This adjacent bounding box set A is a set of bounding boxes in the set of bounding boxes S of the current main building's external features that are adjacent to the selected bounding box w. Proceed to step 4-3. Step 4-3: Determine whether the adjacent bounding box set A is empty. If so, add the current column cluster D to the cluster set C to form a new cluster set C, and proceed to step 4-1. If not, sort all the bounding boxes in the adjacent bounding box set A according to the y-coordinate of the center point of the bounding boxes in descending order, update the bounding box w with the first bounding box after sorting, add the updated bounding box w to the current column cluster D, update the current column cluster D, and proceed to step 4-4. Step 4-4: Delete the updated bounding box w from the bounding box set S of the main building's external features, and proceed to step 4-2; Step 5: Calculate the number of bounding boxes in each column of the cluster set C, and take the maximum number of bounding boxes as the number of floors of the building to be identified.
2. The building floor identification method according to claim 1, characterized in that: The specific process for generating the set of adjacent bounding boxes A in step 4-2 is as follows: Let A denote the adjacency relationship between bounding box i and bounding box w in the set S of bounding boxes representing the external features of the main building. w,i , i∈S, and i≠w, A w,i The calculation formula is: Where, r w,i Let w be the overlap between bounding box w and bounding box i in the set of bounding boxes S of the external features of the main building. c w,i =max(min(r) i ,r w )-max(l i ,l w ),0),min(r i ,r w ) is to take r i and r w The minimum value in, max(l) i ,l w ) is to take l i and l w The maximum value in; (l i ,r i () represents the feature projection of bounding box i onto the X-axis of the coordinate system. x i w is the x-coordinate of the center point of bounding box i. i The width of bounding box i; (l w ,r w ) represents the feature projection of the bounding box w onto the X-axis of the coordinate system. x w Let w be the x-coordinate of the center point of the bounding box w. w θ is the width of the bounding box w; θ is the preset overlap threshold. If A w,i If the value is 1, then the bounding box i is added to the set of adjacent bounding boxes A.
3. The building floor identification method according to claim 1, characterized in that: In step 2, the geometric center Euclidean distance d between the center point of the j-th detection box in the building candidate box set and the image of the building to be identified is... j The calculation formula is: Among them, (x j ,y j ) represents the coordinates of the center point of the j-th detection box, W represents the image width of the building image to be identified, and H represents the image height of the building image to be identified.
4. The building floor identification method according to any one of claims 1 to 3, characterized in that: The following steps are included after step 5: Step 6: Take the average number of bounding boxes in each column of the cluster set C to obtain the average height. Where m is the total number of columns in the cluster set C, h i Let be the total number of bounding boxes in the i-th column of the cluster set C; Then, the center point y-coordinates of each bounding box in the cluster set C are sorted in descending order. The difference Δy between the center point y-coordinates of each bounding box and the previous bounding box is calculated, and it is determined whether Δy is greater than 1. α is a preset constant. If so, it is determined that there are missing features, and the number of floors of the building to be identified in step 5 is increased by 1 to obtain the final number of floors.
5. The building floor identification method according to claim 4, characterized in that: In step 6, only the difference in the ordinate of the center point of the first bounding box and the second bounding box in each column of the cluster set C is calculated.
Citation Information
Patent Citations
Orchard environment pedestrian detection method based on improved YOLOv3
CN111626128A
Intelligent monitoring method for number change of construction site beams and slabs based on tower crane video data
CN118279238A