A method, device and medium for extracting an architectural floor plan
By separating the building plan and using mask marking information, the problems of unclear boundaries and insufficient accuracy of building plan in the prior art are solved, efficient and accurate building plan extraction is achieved, and the accuracy and reliability of wireless signal coverage analysis is improved.
Patent Information
- Application Number
- CN202411959192.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2044-12-30
AI Technical Summary
The prior art has problems of unclear boundaries and insufficient accuracy when acquiring indoor building floor plans, which affects the accuracy and reliability of wireless signal coverage analysis.
By separating the building plan, the mask marking information is used to determine whether the pixel point belongs to the foreground or background, and the non-foreground pixel point is judged based on the maximum value of the foreground pixel point, and its transparency is set to extract a clear building plan.
It realizes efficient and accurate extraction of building floor plans, removes external redundant pixel points, retains pixel information in light-colored areas inside, and improves the clarity and adaptability of the extracted building floor plans.
Smart Images

Figure CN119360411B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the technical field of image processing, and particularly to a method, device, and medium for extracting building floor plans. Background Art
[0002] With the continuous development of Internet technology, especially the progress of wireless communication technology, modern society has put forward higher requirements for the quality of wireless network coverage within buildings. Good wireless network coverage can significantly improve the user's Internet experience, especially in environments such as smart homes and office spaces. In order to more intuitively display the wireless signal coverage, it is usually necessary to combine the distribution of wireless signals with the building floor plan. Therefore, accurately obtaining the building floor plan of a building is the basis for obtaining the wireless signal coverage.
[0003] Currently, there are mainly two methods for obtaining indoor building floor plans: One is to draw indoor building floor plans through professional design software to generate a standard building drawing model. Although this method can generate relatively accurate building drawings, due to its dependence on manual design, it usually requires a large amount of manpower and time to establish a building drawing library, and it is not applicable to dynamically changing or non-standard building drawings. Another common method is to photograph paper building floor plans with a camera. Paper building floor plans usually include standard design drawings or user-drawn drawings. Although this method can provide building floor plan information to a certain extent, it has significant drawbacks: The boundaries of the building floor plan cannot be accurately determined from the photographed pictures, and when superimposing the wireless signal heat map on the floor plan, it may exceed the actual indoor space range, thus affecting the accuracy and reliability of the wireless signal display. Therefore, when the existing methods are used to obtain indoor house type plans and combine them with the wireless signal heat map for display, there will be problems such as unclear boundaries and insufficient accuracy. Therefore, there is an urgent need for a more efficient and accurate technology for identifying and extracting building floor plans to provide a more reliable basis for wireless signal coverage analysis. Summary of the Invention
[0004] To solve the above technical problems, one or more embodiments of this specification provide a method, device, and medium for extracting building floor plans.
[0005] One or more embodiments of this specification adopt the following technical solutions:
[0006] One or more embodiments of this specification provide a method for extracting a building floor plan, the method comprising:
[0007] Separating the building floor plan in the first Mat object, and storing the mask marking information corresponding to the separation result in the second Mat object;
[0008] Construct a third Mat object according to the size of the first Mat object, initialize it with preset pixel values, copy the foreground map area of the second Mat object into the third Mat object to obtain the current third Mat object;
[0009] Based on the mask marking information, determine the non-foreground pixel points in the current third Mat object;
[0010] Obtain the maximum and minimum values of the foreground pixel points of the second Mat object, and based on the maximum and minimum values, discriminate the non-foreground pixel points of the third Mat object to determine whether to set the non-foreground pixel points to transparent to obtain the processed third Mat object;
[0011] Convert the processed third Mat object into a bitmap to obtain the extracted building floor plan.
[0012] Optionally, in one or more embodiments of this specification, before separating the building floor plan in the first Mat object, the method further includes:
[0013] Based on the acquisition device shooting, obtain the initial building floor plan in the current scene, construct an identification task corresponding to the initial building floor plan, and assign the identification task to the corresponding sub-thread;
[0014] Based on a preset threshold, perform image compression on the initial building floor plan corresponding to the identification task of each sub-thread to obtain the compressed initial building floor plan;
[0015] Store the compressed initial building floor plan into the first Mat object, and remove the transparent channel of each compressed initial building floor plan in the first Mat object to obtain the building floor plan in the first Mat object.
[0016] Optionally, in one or more embodiments of this specification, separating the building floor plan in the first Mat object and storing the mask marking information corresponding to the separation result into the second Mat object specifically includes:
[0017] Perform initialization processing on a preset Mat object; wherein, the preset Mat object includes: a second Mat object, a background object, and a foreground object;
[0018] Use a recognition frame to frame the building floor plan input by the first Mat object to determine the initial foreground map area and the initial background map area corresponding to the building floor plan;
[0019] Store the initial foreground image region into the foreground object, store the initial background image region into the background object, and store the labels corresponding to each pixel of the initial foreground image region and the initial background image region into the second Mat object;
[0020] Estimate the pixel probabilities for the initial background image region and the initial foreground image region based on a preset segmentation algorithm, and iteratively adjust the labels corresponding to each pixel in the second Mat object according to the estimation results;
[0021] Determine the separation results corresponding to each pixel point according to the labels corresponding to each pixel in the second Mat object, and determine the corresponding mask marking information based on the correspondence between the separation results and the preset mask values; wherein, the separation results include: pixels belonging to the foreground and pixels belonging to the background.
[0022] Optionally, in one or more embodiments of this specification, construct a third Mat object according to the size of the first Mat object, initialize it with a preset pixel value, and copy the foreground image region of the second Mat object into the third Mat object to obtain the current third Mat object, specifically including:
[0023] Obtain the size of the first Mat object, and construct the third Mat object that is the same size as the first Mat object based on the size of the first Mat object;
[0024] Initialize the third Mat object based on a preset pixel value; wherein, the preset pixel value is the pixel value corresponding to white;
[0025] Determine the foreground image region of the second Mat object according to the mask marking information of the second Mat object, and copy the foreground image region into the initialized third Mat object to obtain the current third Mat object.
[0026] Optionally, in one or more embodiments of this specification, determine the non-foreground pixel points in the current third Mat object based on the mask marking information, specifically including:
[0027] Map the current third Mat object to the corresponding pixel coordinates of the first Mat object based on the coordinates of each pixel point in the current third Mat object;
[0028] Determine whether the pixel points of the current third Mat object belong to the foreground image region based on the mapping relationship and the mask marking information of the second Mat object, so as to identify the non-foreground pixel points in the current third Mat object.
[0029] Optionally, in one or more embodiments of this specification, obtain the maximum and minimum values of the foreground pixel points of the second Mat object, and based on the maximum and minimum values, discriminate the non-foreground pixel points of the third Mat object to determine whether to set the non-foreground pixel points to be transparent, so as to obtain the processed third Mat object. Specifically, it includes:
[0030] According to the mask marking information of the second Mat object, perform binarization processing on the building floor plan to obtain the binary image corresponding to the building floor plan;
[0031] Based on a preset interface, identify the binary image to determine the contour information of the building floor plan;
[0032] Traverse the contour information to determine the maximum and minimum values of each foreground pixel point in the building floor plan in the vertical axis direction; wherein, the maximum and minimum values include: the maximum value and the minimum value;
[0033] Judge whether the non-foreground pixel point is within the range of the maximum and minimum values. If not, set the non-foreground pixel point to be transparent;
[0034] If the non-foreground pixel point is within the range of the maximum and minimum values, create a ray along the horizontal axis direction for the current pixel point to calculate the number of intersection points of the ray and the contour of the foreground image area, and determine whether to set the non-foreground pixel point to be transparent according to the number of intersection points of the contour.
[0035] Optionally, in one or more embodiments of this specification, convert the processed third Mat object into a bitmap to obtain the extracted building floor plan. Specifically, it includes:
[0036] Create a bitmap object in the target environment corresponding to the building floor plan based on a preset tool;
[0037] Encode the processed third Mat object according to a preset function to obtain the byte stream corresponding to the processed third Mat object;
[0038] Copy the byte stream to the pixel buffer according to the interface of the bitmap object to convert the byte stream into the data format of the bitmap object, and obtain the converted bitmap as the extracted building floor plan.
[0039] Optionally, in one or more embodiments of this specification, allocate the recognition task to the corresponding sub-threads. Specifically, it includes:
[0040] Determine the resource information of each sub-thread; wherein, the resource information includes: the remaining resource type and the remaining resource quantity;
[0041] Obtain the size of the building floor plan to determine a historical recognition task corresponding to the size of the building floor plan based on historical extraction data, and determine the necessary resource information for the recognition task according to the historical recognition task;
[0042] Match the necessary resource information with the resource information of each sub-thread to determine the assignable sub-thread corresponding to the recognition task;
[0043] Determine the priority of the assignable sub-thread according to the remaining resource quantity of the assignable sub-thread, and allocate the recognition task to the corresponding sub-thread based on the priority.
[0044] One or more embodiments of this specification provide an extraction device for a building floor plan. The device includes:
[0045] At least one processor; and,
[0046] A memory communicatively connected to the at least one processor; wherein,
[0047] The memory stores instructions executable by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to: execute any one of the above methods.
[0048] A non-volatile computer storage medium provided by one or more embodiments of this specification stores computer-executable instructions, and the computer-executable instructions are set to be able to: execute any one of the above methods.
[0049] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:
[0050] Based on the use of separation processing and mask marking information, it is possible to achieve the annotation of whether a pixel point belongs to the foreground or the background, which facilitates the subsequent discrimination of pixel points. After determining the non-foreground pixel points in the current third Mat object based on the mask marking information, the non-foreground pixel points of the third Mat object are discriminated by obtaining the maximum and minimum values of the foreground pixel points of the second Mat object, and its transparency is flexibly set. This processing method not only retains the pixel information of the light-colored areas inside the building floor plan, but also effectively removes the redundant pixel points outside the building floor plan, making the extracted building floor plan clearer and enabling the extracted building floor plan to be applied to the overlay scene, improving the adaptability of the application scenario of the building floor plan. Description of the Drawings
[0051] To more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in this specification. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings. In the drawings:
[0052] Figure 1 It is a schematic flowchart of a method for extracting an architectural floor plan provided by an embodiment of this specification;
[0053] Figure 2 It is a schematic structural diagram of a device for extracting an architectural floor plan provided by an embodiment of this specification;
[0054] Figure 3 It is a schematic structural diagram of a non - volatile storage medium provided by an embodiment of this specification. Detailed implementation manners
[0055] The embodiments of this specification provide a method, a device, and a medium for extracting an architectural floor plan.
[0056] In order to enable those skilled in the art to better understand the technical solutions in this specification, the following will clearly and completely describe the technical solutions in the embodiments of this specification in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all of them. Based on the embodiments of this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this specification.
[0057] As Figure 1 shown, a schematic flowchart of a method for extracting an architectural floor plan is provided in the embodiments of this specification. It can be seen from Figure 1 that in one or more embodiments of this specification, a method for extracting an architectural floor plan specifically includes the following process:
[0058] S101: Separate the architectural floor plan in the first Mat object, and store the mask marking information corresponding to the separation result in the second Mat object.
[0059] In order to avoid the problem that during the recognition process, the light-colored areas inside the architectural floor plan are misrecognized as the background, resulting in the internal areas being set to transparent during the extraction of the architectural floor plan, thereby affecting the integrity and usability of the architectural floor plan. In the embodiments of this specification, the architectural floor plan in the first Mat object will be separated, and the mask marking information corresponding to the separation result will be stored in the second Mat object. By storing the mask marking information in the second Mat object, it helps to determine whether each pixel belongs to the foreground or the background based on the mask marking information of the second Mat object in the subsequent process.
[0060] Further, in one or more embodiments of this specification, before separating the architectural floor plan in the first Mat object, the method further includes the following process:
[0061] First, in order to make full use of the computing power of the multi-core processor to achieve parallel processing of tasks and improve the speed and efficiency of image processing, in the embodiments of this specification, the initial architectural floor plan in the current scene is obtained by shooting with the acquisition device to construct an identification task corresponding to the initial architectural floor plan, and the identification task is assigned to the corresponding sub-thread. By assigning the identification task to a sub-thread with sufficient resources, the computing resources and storage space can be maximally utilized. Then, according to the preset threshold, the initial architectural floor plan corresponding to the identification task of each sub-thread is subjected to image compression to obtain the compressed initial architectural floor plan, which can effectively reduce the time-consuming of image processing. That is to say, since the recognition and extraction process of the architectural floor plan is a time-consuming task, the time-consuming of image processing mainly comes from processing each pixel in the picture one by one. Therefore, before recognition and extraction, the house type diagram needs to be compressed first. The compression process is to judge whether the size of the picture is greater than the set threshold (assuming the threshold is 500KB). At this time, if the picture size exceeds 500KB, the picture is compressed by dividing the width and height of the picture by 2 respectively, and this process is repeated until the picture size is less than 500KB.
[0062] Then, store the compressed initial building floor plan into the first Mat object, and remove the alpha channel of each compressed initial building floor plan in the first Mat object to obtain the building floor plan in the first Mat object. That is, after the compression process based on the above steps, two bitmap objects will be created in the embodiments of this specification: BitmapCompress for storing the compressed image, and BitmapCut for storing the area selected by the subsequent recognition frame. Then, use OpenCV to convert BitmapCompress into a Mat object (Mat_1) unique to OpenCV, and process this first Mat object to convert the image from the RGBA format including the alpha channel to the RGB format, removing the alpha channel. In this process, by removing the alpha channel, the data volume of the image is reduced, the computational burden of subsequent processing steps is reduced, and the recognition interference problem caused by the change of transparency in the alpha channel is avoided, improving the accuracy and reliability of subsequent image extraction.
[0063] Further, since the recognition of the building floor plan is a time-consuming task, in one or more embodiments of this specification, to improve efficiency, the recognition task is assigned to the corresponding sub-threads for processing. At this time, the process of assigning the recognition task to the corresponding sub-threads specifically includes the following process:
[0064] First, determine the resource information of each sub-thread. It should be noted that the resource information includes: remaining resource type and remaining resource quantity. Then, obtain the size of the building floor plan to determine the historical recognition task corresponding to the size of the building floor plan based on historical extraction data, and thus determine the necessary resource information of the recognition task according to the historical recognition task. Then, match the necessary resource information with the resource information of each sub-thread to determine the assignable sub-thread corresponding to the recognition task. According to the remaining resource quantity of each assignable sub-thread, determine the priority of the assignable sub-thread. It can be understood that the more the remaining resource quantity, the higher the priority. Therefore, according to the priority, the recognition task can be assigned to the corresponding sub-thread. In this process, by accurately matching the necessary resource information of the recognition task with the resource information of each sub-thread, the optimal utilization of resources can be ensured and resource waste can be avoided. And by determining the priority according to the remaining resource quantity of the sub-thread, the sub-thread with sufficient resources can be preferentially assigned, thus accelerating the execution speed of the recognition task.
[0065] For example: In a certain scenario, it is assumed that multiple building floor plan recognition tasks of different sizes need to be processed. At this time, there are three child threads A, B, and C in the background. The resource information of each child thread is as follows: Child thread A: Remaining resource types: CPU, memory; remaining resource quantities: CPU 80%, memory 60%. Child thread B: Remaining resource types: CPU, memory; remaining resource quantities: CPU 50%, memory 80%. Child thread C: Remaining resource types: CPU, memory; remaining resource quantities: CPU 70%, memory 70%. Now, the system receives a medium-sized building floor plan recognition task, and the necessary resource information required for this task is: at least 60% CPU and at least 70% memory. Then, according to the requirements of this task, first, the child threads that meet the resource requirements can be filtered out, namely child thread A and child thread C. Then, the priority is determined according to the remaining resource quantities: For child thread A, the remaining CPU is 80% and the remaining memory is 60%. However, since the memory is less than 70%, although its priority is high, it cannot meet the task requirements. For child thread C, the remaining CPU is 70% and the remaining memory is 70%, which fully meets the task requirements and the remaining resource quantity is relatively large. Therefore, the system finally assigns the recognition task to child thread C.
[0066] Specifically, in one or more embodiments of this specification, the building floor plan in the first Mat object is separated, and the mask marking information corresponding to the separation result is stored in the second Mat object, which specifically includes the following processes:
[0067] First, initialize the preset Mat object; wherein, the preset Mat object includes: the second Mat object, the background object, and the foreground object. Then, use the recognition frame to frame the building floor plan input in the first Mat object to determine the initial foreground map area and the initial background map area corresponding to the building floor plan. It should be noted that the recognition frame is default to be rectangular, and the range of the recognition frame can be determined based on the maximum values of the horizontal and vertical coordinate axes of the foreground object and the preset boundary distance, that is, based on the maximum values of the horizontal and vertical coordinate axes of the foreground object, the coordinates of the upper left corner and the lower right corner of the foreground object in the image can be found, and the minimum circumscribed rectangle of all pixel points of the foreground object is used as the initial recognition frame range, and then the preset boundary distance is superimposed on this initial recognition frame range to determine the framed range of the recognition frame. In addition, the size of the recognition frame can also be changed by manual dragging to determine the framed range of the recognition frame. Then, store the initial foreground map area in the foreground object, store the initial background map area in the background object, and store the labels corresponding to each pixel of the initial foreground map area and the initial background map area in the second Mat object.
[0068] Then, in order to separate the foreground and background in the image to facilitate the extraction of the building floor plan, in the embodiments of this specification, the pixel probabilities of the initial background image region and the initial foreground image region will be estimated according to a preset segmentation algorithm, and the labels corresponding to each pixel in the second Mat object will be iteratively adjusted according to the estimation results. Then, according to the labels corresponding to each pixel in the second Mat object, the separation results corresponding to each pixel point will be determined, and the corresponding mask marking information will be determined based on the correspondence between the separation results and the preset mask values. The separation results include: pixels belonging to the foreground and pixels belonging to the background.
[0069] In this process, by estimating the pixel probabilities of the initial foreground and background regions through a preset segmentation algorithm and iteratively adjusting the labels corresponding to each pixel in the second Mat object, the analysis of the foreground and background can be achieved. Then, the mask marking information corresponding to the separation results is stored in the second Mat object, which facilitates quickly determining whether each pixel point belongs to the foreground based on the mask information in the subsequent process, helps further filter the external images in the building floor plan, and improves the extraction accuracy of the building floor plan.
[0070] Specifically, in a certain scenario, the process of estimating the pixel probabilities of the initial foreground and background regions based on a preset segmentation algorithm and iteratively adjusting the labels corresponding to each pixel in the second Mat object to determine the separation results corresponding to each pixel point is as follows:
[0071] First, initialize three Mat objects: the second Mat object Mat_2, the background object bgModel, and the foreground object fgModel. It can be understood that Mat_2 stores the preliminary mask, which is used to mark each pixel as belonging to the foreground, background, or possible foreground / background. bgModel and fgModel are used to optimize the segmentation results of the preset segmentation algorithm and will be gradually updated during the algorithm operation. Then, create a 1x1 Mat object source, set it to 8-bit single-channel (CV_8UC1), and its value is Imgproc.GC_PR_FGD, indicating that this pixel belongs to the "possible foreground" area. Then, call the OpenCV API for separating foreground and background to execute the GrabCut algorithm. Compare the values in Mat_2 and source through the API: Core.compare(Mat_2, source, Mat_2, Core.CMP_EQ), and store the result back into Mat_2. Core.CMP_EQ represents performing an equality comparison, comparing the values at the corresponding positions of the two matrices. If they are equal, the value at the corresponding position of the result matrix is 1 (True), otherwise it is 0 (False). 1 represents belonging to the foreground, and 2 represents belonging to the background. Based on the comparison result, the second Mat object Mat_2 will be further corrected to obtain an iteratively optimized separation result, and determine whether each pixel belongs to the foreground or background based on the separation result.
[0072] S102: Construct a third Mat object according to the size of the first Mat object, initialize it with a preset pixel value, and copy the foreground map area of the second Mat object into the third Mat object to obtain the current third Mat object.
[0073] To facilitate the identification of interfering pixel points in the foreground pixel points and thus improve the extraction accuracy of the building floor plan. In the embodiments of this specification, a third Mat object is constructed according to the size of the first Mat object. In order to identify the non-foreground pixel points in the third Mat object, it will be initialized with a preset pixel value, and then the foreground map area of the second Mat object is copied into the third Mat object to obtain the current third Mat object.
[0074] Specifically, in one or more embodiments of this specification, constructing a third Mat object according to the size of the first Mat object, initializing it with a preset pixel value, and copying the foreground map area of the second Mat object into the third Mat object to obtain the current third Mat object specifically includes the following process:
[0075] First, obtain the size of the first Mat object, and then construct a third Mat object that is the same size as the first Mat object according to the size of the first Mat object. Then, initialize the third Mat object according to the preset pixel value. It should be noted that the preset pixel value corresponds to the pixel value of white. Then, according to the mask marking information of the second Mat object, the foreground image area of the second Mat object belonging to the foreground pixel points can be determined, and the foreground image area is copied to the initialized third Mat object to obtain the current third Mat object. By obtaining the size of the first Mat object to construct the third Mat object, it is ensured that the third Mat object is the same size as the first Mat object, which helps to avoid the problem of pixel point information loss caused by size mismatch. In addition, initializing the third Mat object according to the preset pixel value and setting it to the same pixel value makes the third Mat object have a unified background before copying the foreground image area, which helps to identify the pixel points that do not belong to the foreground in the light-colored area subsequently. And using the mask marking information of the second Mat object to determine the foreground image area of the foreground pixel points can avoid introducing unnecessary background information.
[0076] S103: Based on the mask marking information, determine the non-foreground pixel points in the current third Mat object.
[0077] After copying the foreground image area of the second Mat object to the third Mat object according to the above step S102 to obtain the current third Mat object, in order to be able to set the area outside the building floor plan to be transparent while ensuring that the light-colored areas inside the building floor plan are not judged to be transparent. In the embodiments of this specification, the pixel points of the current third Mat object will be matched according to the determined mask marking information above, so as to determine the non-foreground pixel points in the current third Mat object.
[0078] Specifically, in one or more embodiments of this specification, based on the mask marking information, determining the non-foreground pixel points in the current third Mat object specifically includes the following process:
[0079] First, according to the coordinates of each pixel point in the current third Mat object, map the current third Mat object to the corresponding pixel coordinates of the first Mat object. Then, based on the determined mapping relationship and the mask marking information of the second Mat object, determine whether the pixel points of the current third Mat object belong to the foreground image area to identify the non-foreground pixel points in the current third Mat object. That is, in the second Mat object, through the mask marking information, marked as 1 is the foreground, marked as 0 is the background, and it can be identified whether the pixel point is a foreground pixel point. For example: For a certain pixel point (x1, y1) in the third Mat object, by calling this pixel point (x1, y1) through the second Mat object, it can be known whether the mask marking information of this pixel point is 1, that is, based on this, it can be judged which of the current third Mat object belong to non-foreground pixel points.
[0080] S104: Obtain the maximum and minimum values of the foreground pixel points of the second Mat object, and based on the maximum and minimum values, discriminate the non-foreground pixel points of the third Mat object to determine whether to set the non-foreground pixel points to be transparent, so as to obtain the processed third Mat object.
[0081] In order to be able to set non-foreground pixel points to be transparent, so as to facilitate the superposition of building floor plans in scenarios such as wireless signal coverage analysis and visualization display, it is necessary to set the interference area outside the building floor plan to be transparent while ensuring that the area close to white inside the building floor plan is not made transparent. Therefore, in the embodiments of this specification, the maximum and minimum values of the foreground pixel points of the second Mat object will be obtained, and then based on the maximum and minimum values, the non-foreground pixel points of the third Mat object will be discriminated to determine whether to set the non-foreground pixel points to be transparent, so as to obtain the processed third Mat object.
[0082] Specifically, in one or more embodiments of this specification, obtaining the maximum and minimum values of the foreground pixel points of the second Mat object, and based on the maximum and minimum values, discriminating the non-foreground pixel points of the third Mat object to determine whether to set the non-foreground pixel points to be transparent, so as to obtain the processed third Mat object, specifically includes the following processes:
[0083] First, according to the mask marking information of the second Mat object, the architectural floor plan is binarized to obtain the corresponding binary image of the architectural floor plan. Then, the binary image is recognized according to the preset interface to determine the contour information of the architectural floor plan. That is, since contour detection can only work accurately when the contrast between the foreground and the background is obvious, the architectural floor plan will be binarized, and each pixel in the image is mapped to two values, 0 and 1. Among them, 0 is black representing the background, and 1 is white representing the foreground. Then, the contour information is obtained through the preset interface. The contour information is composed of a list of points formed. Then, traverse the contour information to determine the maximum and minimum values of each foreground pixel point in the architectural floor plan in the vertical axis direction; among them, it can be understood that the maximum and minimum values include: the maximum value and the minimum value. That is, obtain the minimum value ymin and the maximum value ymax of the foreground pixel points in the y-axis direction. Determine whether the non-foreground pixel points are within the range of the maximum and minimum values. If not, set the non-foreground pixel points to be transparent. And if the non-foreground pixel points are within the range of the maximum and minimum values, then in order to realize the recognition and extraction of the light-colored areas in the architectural floor plan, a ray will be created along the horizontal axis direction according to the current pixel point to calculate the number of intersection points of the ray and the contour of the foreground image area, and determine whether to set the non-foreground pixel points to be transparent according to the number of intersection points of the contour. That is to say, a ray is created along the x-axis from the current pixel point to calculate the number of intersection points of the ray and the contour of the foreground area. If the number of intersection points of the contour is odd, it means that the pixel point is inside the area of the architectural floor plan. And if the number of intersection points of the contour is even, it means that the pixel point is outside the architectural floor plan and needs to be set to be transparent.
[0084] In this process, through binarization, the pixels in the image are simplified into the foreground (white) and the background (black), making the contrast between the foreground pixel points and the background pixel points more distinct, and making the subsequent contour detection and the calculation of the maximum and minimum values of the foreground pixel points more accurate and efficient. The non-foreground pixel points are discriminated according to the maximum and minimum values of the foreground pixel points. If the non-foreground pixel points are not within the range of the maximum and minimum values, they are directly set to be transparent. This strategy can effectively remove the irrelevant background in the image. At the same time, for the non-foreground pixel points within the range of the maximum and minimum values, by calculating the number of intersection points of the ray and the contour of the foreground area to further determine whether they should be set to be transparent, it not only improves the flexibility of image processing, but also can accurately identify and extract the light-colored areas in the architectural floor plan.
[0085] S105: Convert the processed third Mat object into a bitmap to obtain the extracted architectural floor plan.
[0086] In order to obtain the recognized architectural floor plan. In the embodiments of this specification, the processed third Mat object will be converted into a bitmap, so as to obtain the extracted architectural floor plan. Specifically, in one or more embodiments of this specification, converting the processed third Mat object into a bitmap to obtain the extracted architectural floor plan specifically includes the following process:
[0087] First, create a bitmap object in the target environment corresponding to the architectural floor plan based on the preset tool. Then, encode the processed third Mat object according to the preset function to obtain the byte stream corresponding to the processed third Mat object. Copy the byte stream into the pixel buffer according to the interface of the bitmap object, so as to convert the byte stream into the data format of the bitmap object, and obtain the converted bitmap as the extracted architectural floor plan.
[0088] As Figure 2 shown, the embodiments of this specification provide a structural schematic diagram of a device for extracting an architectural floor plan. As can be seen from Figure 2 this, in one or more embodiments of this specification, a device for extracting an architectural floor plan, the device includes:
[0089] At least one processor; and,
[0090] A memory communicatively connected to the at least one processor; wherein,
[0091] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: execute any of the above-mentioned methods.
[0092] As Figure 3 shown, the embodiments of this specification provide a structural schematic diagram of a non-volatile storage medium. As can be seen from Figure 3 this, in one or more embodiments of this specification, a non-volatile storage medium stores computer-executable instructions 301, and the computer-executable instructions 301 can: execute any of the above-mentioned methods.
[0093] The embodiments in this specification are all described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the device, equipment, and non-volatile computer storage medium, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments.
[0094] The specific embodiments of the present specification have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0095] The above description is only for one or more embodiments of the present specification and is not intended to limit the present specification. For those skilled in the art, various changes and modifications can be made to one or more embodiments of the present specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of one or more embodiments of the present specification shall be included within the scope of the claims of the present specification.
Claims
1. A method for extracting a building plan, characterized in that: The method comprises: Separate the building plan in the first Mat object, and store the mask mark information corresponding to the separation result in the second Mat object; Constructing a third Mat object according to the size of the first Mat object, and initializing it to a preset pixel value, and copying the foreground image area of the second Mat object to the third Mat object to obtain the current third Mat object; Based on the mask mark information, determining non-foreground pixel points in the current third Mat object; Obtaining the maximum value of the foreground pixel of the second Mat object, and discriminating the non-foreground pixel of the third Mat object based on the maximum value, and determining whether to set the non-foreground pixel to be transparent, so as to obtain the processed third Mat object; Convert the processed third Mat object into a bitmap to obtain the extracted building plan; The building plan in the first Mat object is separated and processed, and the mask mark information corresponding to the separation result is stored in the second Mat object, specifically including: Initialize the preset Mat object; wherein the preset Mat object includes: a second Mat object, a background object, and a foreground object; Selecting the building plane input by the first Mat object through an identification frame, and determining an initial foreground image area and an initial background image area corresponding to the building plane; The initial foreground image area is stored in the foreground object, the initial background image area is stored in the background object, and the labels corresponding to the pixels in the initial foreground image area and the initial background image area are stored in the second Mat object; Based on a preset segmentation algorithm, pixel probabilities are estimated for the initial background image region and the initial foreground image region, so as to iteratively adjust the labels corresponding to the pixels in the second Mat object according to the estimation results; According to the label corresponding to each pixel in the second Mat object, the separation result corresponding to each pixel point is determined, so as to determine the corresponding mask marking information based on the correspondence between the separation result and the preset mask value; wherein the separation result includes: the pixel belongs to the foreground and the pixel belongs to the background.
2. The method for extracting a building plan according to claim 1, characterized in that: Before separating the building plan in the first Mat object, the method further includes: An initial building plan view of the current scene is acquired based on the acquisition device, so as to construct a recognition task corresponding to the initial building plan view, and assign the recognition task to a corresponding sub-thread; Based on a preset threshold, the initial building floor plan corresponding to the recognition task of each sub-thread is compressed to obtain a compressed initial building floor plan; The compressed initial building plan is stored in the first Mat object, and the transparent channel of each compressed initial building plan in the first Mat object is removed to obtain the building plan in the first Mat object.
3. The method for extracting a building plan according to claim 1, characterized in that: Constructing a third Mat object according to the size of the first Mat object and initializing it to a preset pixel value, copying the foreground image area of the second Mat object to the third Mat object, and obtaining the current third Mat object, specifically includes: Acquire the size of the first Mat object, so as to construct the third Mat object having the same size as the first Mat object based on the size of the first Mat object; Initializing the third Mat object based on a preset pixel value; wherein the preset pixel value is a pixel value corresponding to white; According to the mask mark information of the second Mat object, a foreground image area of the second Mat object is determined, so as to copy the foreground image area to the initialized third Mat object to obtain a current third Mat object.
4. The method for extracting a building plan according to claim 1, characterized in that: Based on the mask mark information, determining non-foreground pixel points in the current third Mat object specifically includes: Based on the coordinates of each pixel point in the current third Mat object, mapping the current third Mat object to the corresponding pixel coordinates of the first Mat object; Based on the mapping relationship and the mask mark information of the second Mat object, it is determined whether the pixel point of the current third Mat object belongs to the foreground image area, so as to identify the non-foreground pixel points in the current third Mat object.
5. The method for extracting a building plan according to claim 1, characterized in that: Obtaining the maximum value of the foreground pixel of the second Mat object, and discriminating the non-foreground pixel of the third Mat object based on the maximum value, and determining whether to set the non-foreground pixel to be transparent, so as to obtain the processed third Mat object, specifically includes: Binarize the building plan according to the mask mark information of the second Mat object to obtain a binary image corresponding to the building plan; Identify the binary image based on a preset interface to determine contour information of the building plan; Traversing the outline information to determine the maximum value of each foreground pixel point in the building plan in the direction of the vertical coordinate axis; wherein the maximum value includes: a maximum value and a minimum value; Determine whether the non-foreground pixel is within the maximum value range, and if not, set the non-foreground pixel to be transparent; If the non-foreground pixel point is within the range of the maximum value, the current pixel point creates a ray along the horizontal axis direction to calculate the number of intersections between the ray and the contour of the foreground image area, so as to determine whether to set the non-foreground pixel point to transparent based on the number of intersections of the contour.
6. The method for extracting a building plan according to claim 1, characterized in that: Converting the processed third Mat object into a bitmap to obtain the extracted building plan view specifically includes: Creating a bitmap object in a target environment corresponding to the building plan based on a preset tool; Encode the processed third Mat object according to a preset function to obtain a byte stream corresponding to the processed third Mat object; The byte stream is copied to a pixel buffer according to the interface of the bitmap object to convert the byte stream into a data format of the bitmap object, and a converted bitmap is obtained as the extracted building plan.
7. The method for extracting a building plan according to claim 2, characterized in that: Allocating the recognition task to the corresponding sub-thread specifically includes: Determine resource information of each sub-thread; wherein the resource information includes: remaining resource type and remaining resource quantity; Acquire the size of the building plan to determine a historical recognition task corresponding to the size of the building plan based on historical extraction data, and determine necessary resource information of the recognition task according to the historical recognition task; Matching the necessary resource information with the resource information of each of the sub-threads to determine the allocatable sub-thread corresponding to the identified task; The priority of the allocatable sub-thread is determined according to the remaining resource quantity of the allocatable sub-thread, so as to allocate the identification task to the corresponding sub-thread based on the priority.
8. A device for extracting a building plan, characterized in that: The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: execute any of the methods described in claims 1-7.
9. A non-volatile storage medium storing computer executable instructions, characterized in that: The computer executable instructions can: execute the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Image processing method, image synthesis method and related device
CN111080656A
Building contour extraction method and system, computer equipment and storage medium
CN114529837A