Architectural planar graph extraction method and device and medium

By separating the building plan and using the mask mark information, determining the non-foreground pixels and setting the transparency, the problem of unclear boundaries and insufficient accuracy of the building plan in the existing technology is solved, and efficient and accurate building plan extraction is achieved. and display.

CN119360411AActive Publication Date: 2025-01-24JUQING NETWORK TECH (JINAN) CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411959192.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-01-24
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

When the prior art acquires indoor building plan and displays it in combination with wireless signal heat maps, there are problems such as unclear boundaries and insufficient accuracy, which affects the accuracy and reliability of wireless signal display.

Method used

By separating the building plan in the first Mat object, using the mask mark information to store it in the second Mat object, determining the non-foreground pixels in the third Mat object, and classifying the non-foreground pixels according to the maximum value of the foreground pixels. Identify the points and set their transparency to extract a clear building plan.

Benefits of technology

The efficient and accurate extraction of the building plan is removed, remove the external redundant pixels, retain the pixel information of the internal light -colored area, and improve the clarity and adaptability of the extracted building plan.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119360411A_ABST
    Figure CN119360411A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an architectural plane graph extraction method and device and a medium, relates to the technical field of image processing, and is used for solving the problem that current architectural plane graph extraction is inaccurate. The method comprises the steps of performing separation processing on an architectural plane graph in a first Mat object, and storing mask mark information corresponding to a separation result into a second Mat object; constructing a third Mat object, initializing the third Mat object into a preset pixel value, copying the foreground image area of the second Mat object into the third Mat object, and obtaining the current third Mat object; determining non-foreground pixel points in the current third Mat object based on the mask mark information; obtaining the extreme value of a foreground pixel point of the second Mat object, and determining whether a non-foreground pixel point is set to be transparent or not based on the extreme value, so as to obtain a processed third Mat object; and converting the processed third Mat object into a bitmap to obtain an extracted architectural plane graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a method, device and medium for extracting a building plan. Background Art

[0002] With the continuous development of Internet technology, especially the advancement of wireless communication technology, modern society has put forward higher requirements for the quality of wireless network coverage in buildings. Good wireless network coverage can significantly improve the user's Internet experience, especially in smart homes, offices and other environments. 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 the building is the basis for obtaining the wireless signal coverage.

[0003] At present, there are two main methods for obtaining indoor building plans: one is to draw indoor building plans through professional design software and generate a standard building drawing model. Although this method can generate relatively accurate building drawings, it usually takes a lot of manpower and time to build a building library because it relies on manual design, and it is not suitable for dynamically changing or non-standardized building drawings. Another common method is to shoot paper building plans with a camera, which usually include standard design drawings or user hand-drawn drawings. Although this method can provide building plan information to a certain extent, it has significant disadvantages: the captured pictures cannot accurately determine the boundaries of the building plan, and when the wireless signal heat map is superimposed on the plan, it may exceed the scope of the actual indoor space, thereby affecting the accuracy and reliability of the wireless signal display. Therefore, when the existing method obtains the indoor floor plan and combines it with the wireless signal heat map for display, there will be problems such as unclear boundaries and insufficient precision. Therefore, a more efficient and accurate building plan recognition and extraction technology is urgently needed to provide a more reliable basis for wireless signal coverage analysis. Summary of the invention

[0004] In order to solve the above technical problems, one or more embodiments of the present specification provide a method, device and medium for extracting a building plan.

[0005] One or more embodiments of this specification adopt the following technical solutions: One or more embodiments of this specification provide a method for extracting a building plan, the method comprising: 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; The processed third Mat object is converted into a bitmap to obtain the extracted building floor plan.

[0006] Optionally, in one or more embodiments of the present specification, 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.

[0007] Optionally, in one or more embodiments of the present specification, the building plan in the first Mat object is separated and the mask mark information corresponding to the separation result is stored in the second Mat object, which specifically includes: 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.

[0008] Optionally, in one or more embodiments of the present specification, 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.

[0009] Optionally, in one or more embodiments of the present specification, determining non-foreground pixels in the current third Mat object based on the mask mark information 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.

[0010] Optionally, in one or more embodiments of the present specification, obtaining the maximum value of the foreground pixel of the second Mat object, 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 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.

[0011] Optionally, in one or more embodiments of the present specification, 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.

[0012] Optionally, in one or more embodiments of the present specification, allocating the recognition task to a 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.

[0013] One or more embodiments of the present specification provide a device for extracting a building plan, the device comprising: 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 to enable the at least one processor to: execute any of the above-mentioned methods.

[0014] One or more embodiments of the present specification provide a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured to be able to: execute any of the above-described methods.

[0015] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects: Based on the separation processing and the use of mask mark information, it is possible to mark whether the pixel belongs to the foreground or the background, which facilitates the subsequent discrimination of the pixel. After determining the non-foreground pixel in the current third Mat object based on the mask mark information, the non-foreground pixel of the third Mat object is discriminated by obtaining the maximum value of the foreground pixel of the second Mat object, and its transparency is flexibly set. This processing method not only retains the pixel information of the light-colored area inside the building plan, but also effectively removes the redundant pixels outside the building plan, making the extracted building plan clearer, and enabling the extracted building plan to be applied to the overlay scene, improving the adaptability of the building plan application scenario. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings: Figure 1 A schematic diagram of a method for extracting a building plan view provided in an embodiment of this specification; Figure 2 A schematic diagram of the structure of a building plan extraction device provided in an embodiment of this specification; Figure 3 A schematic diagram of the structure of a non-volatile storage medium provided in an embodiment of this specification. DETAILED DESCRIPTION

[0017] The embodiments of this specification provide a method, device and medium for extracting a building plan.

[0018] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0019] like Figure 1 As shown, a schematic diagram of a method for extracting a building plan is provided in an embodiment of this specification. Figure 1 It can be seen that in one or more embodiments of this specification, a method for extracting a building plan view specifically includes the following process: S101: 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.

[0020] In order to avoid the problem that the light-colored area inside the building plan is mistakenly identified as the background during the recognition process, the internal area of ​​the building plan is also set to transparent during the extraction process of the building plan, thereby affecting the integrity and practicality of the building plan. In the embodiment of this specification, the building plan in the first Mat object is separated and the mask mark information corresponding to the separation result is stored in the second Mat object. By storing the mask mark information in the second Mat object, it is helpful to determine whether each pixel belongs to the foreground or the background based on the mask mark information of the second Mat object.

[0021] Furthermore, in one or more embodiments of the present specification, before separating the building plan in the first Mat object, the method further includes the following process: First, in order to make full use of the computing power of multi-core processors, realize parallel processing of tasks and improve the speed and efficiency of image processing, in the embodiment of this specification, the initial building plan in the current scene will be obtained according to the acquisition device to construct a recognition task corresponding to the initial building plan, and the recognition task will be assigned to the corresponding sub-thread. By assigning the recognition task to the sub-thread with sufficient resources, the computing resources and storage space can be maximized. Then, according to the preset threshold, the initial building plan corresponding to the recognition task of each sub-thread is compressed to obtain the compressed initial building plan, which can effectively reduce the time consumption of image processing. That is to say, since the recognition and extraction process of the building plan is a time-consuming task, the time consumption of image processing mainly comes from the one-by-one processing of each pixel in the picture, so before recognition and extraction, the house type map needs to be compressed. The compression process is to determine whether the size of the picture is greater than the set threshold, assuming that the threshold is 500KB. At this time, if the picture size exceeds 500KB, the picture width and height are divided by 2 for compression, and this process is repeated until the picture size is less than 500KB.

[0022] Then, 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. That is, after the compression processing is performed based on the above steps, two bitmap objects will be created in the embodiment of this specification: BitmapCompress is used to store the compressed image, and BitmapCut is used to store the area selected by the subsequent recognition box. Then, OpenCV is used to convert BitmapCompress into a Mat object (Mat_1) unique to OpenCV, and the first Mat object is processed to convert the image from RGBA format including transparent channel to RGB format, and remove the transparent channel. In this process, by removing the transparent channel, the data volume of the image is reduced, the computational burden of the subsequent processing steps is reduced, and the recognition interference problem caused by the change of transparency in the transparent channel is avoided, thereby improving the accuracy and reliability of subsequent image extraction.

[0023] Furthermore, since the recognition of the building plan is a time-consuming task, in order to improve efficiency, in one or more embodiments of this specification, the recognition task is assigned to the corresponding sub-thread for processing. At this time, the process of assigning the recognition task to the corresponding sub-thread specifically includes the following process: First, the resource information of each sub-thread is determined. It should be noted that the resource information includes: the type of remaining resources and the number of remaining resources. Then, the size of the building plan is obtained to determine the historical recognition task corresponding to the size of the building plan based on the historical extraction data, so as to determine the necessary resource information of the recognition task according to the historical recognition task. Then, the necessary resource information is matched with the resource information of each sub-thread to determine the assignable sub-thread corresponding to the recognition task. According to the number of remaining resources of each assignable sub-thread, the priority of the assignable sub-thread is determined. It can be understood that the more the number of remaining resources, 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, it can be ensured that the resources are optimally utilized and the waste of resources is avoided. By determining the priority according to the number of remaining resources of the sub-thread, the sub-thread with sufficient resources can be assigned first, thereby speeding up the execution speed of the recognition task.

[0024] 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 sub-threads A, B, and C in the background, and the resource information of each sub-thread is as follows: Sub-thread A: Remaining resource types: CPU, memory, remaining resource quantity CPU: 80%, memory: 60%; Sub-thread B: Remaining resource types CPU, memory, remaining resource quantity CPU: 50%, memory: 80%; Sub-thread C: Remaining resource types CPU, memory, remaining resource quantity 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, the sub-threads that meet the resource requirements can be first screened out, namely sub-thread A and sub-thread C. Then, the priority is determined according to the remaining resource quantity: Sub-thread A: Remaining CPU 80%, remaining memory 60%, but because the memory is less than 70%, its priority is high but cannot meet the task requirements. Sub-thread C: Remaining CPU 70%, remaining memory 70%, fully meet the task requirements, and the remaining resource quantity is large. Therefore, the system finally assigns the recognition task to sub-thread C.

[0025] Specifically, in one or more embodiments of the present specification, 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, which specifically includes the following process: First, the preset Mat object is initialized; wherein the preset Mat object includes: a second Mat object, a background object, and a foreground object. Then, the building plane input by the first Mat object is framed by an identification frame to determine the initial foreground image area and the initial background image area corresponding to the building plane. It should be noted that the identification frame is a rectangle by default, and the identification frame range can be determined based on the maximum value of the horizontal and vertical axes of the foreground object and the preset boundary distance, that is, based on the maximum value of the horizontal and vertical 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 to obtain the minimum circumscribed rectangle of all pixels of the foreground object as the initial identification frame range, and then the preset boundary distance is superimposed on the initial identification frame range to determine the frame selection range of the identification frame. In addition, the size of the identification frame can be changed by manually dragging to determine the frame selection range of the identification frame. Then, 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 each pixel of the initial foreground image area and the initial background image area are stored in the second Mat object.

[0026] Then, in order to separate the foreground and background in the image, thereby facilitating the extraction of the building plan, the embodiment of this specification will estimate the pixel probability of the initial background image area and the initial foreground image area according to the preset segmentation algorithm, so as to iteratively adjust the label corresponding to each pixel in the second Mat object according to the estimation result. Then, 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 mark information based on the correspondence between the separation result and the preset mask value. Among them, the separation result includes: the pixel belongs to the foreground and the pixel belongs to the background.

[0027] In this process, the pixel probabilities of the initial foreground and background areas are estimated through a preset segmentation algorithm, and the labels corresponding to each pixel in the second Mat object are iteratively adjusted to realize foreground and background analysis. Then, the mask marking information corresponding to the separation result is stored in the second Mat object, which facilitates the subsequent rapid determination of whether each pixel belongs to the foreground based on the mask information, helps to further filter the external images in the building plan, and improves the extraction accuracy of the building plan.

[0028] Specifically, in a certain scene, the pixel probabilities of the initial foreground and background areas are estimated based on the preset segmentation algorithm, and the label corresponding to each pixel in the second Mat object is iteratively adjusted to determine the separation result corresponding to each pixel point. The process is as follows: First, initialize three Mat objects: the second Mat object Mat_2, the background object bgModel, and the foreground object fgMode. 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. Then create a 1x1 Mat object source, set it to 8-bit single channel (CV_8UC1), and the value is Imgproc.GC_PR_FGD, indicating that the pixel belongs to the "possible foreground" area. Then call the OpenCV API to separate the foreground and background to execute the GrabCut algorithm, and 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 to Mat_2. Core.CMP_EQ means to perform an equal comparison, comparing the values ​​of the corresponding positions of the two matrices. If they are equal, the value of the corresponding position in the result matrix is ​​1 (True), otherwise it is 0 (False). 1 represents belonging to the foreground, and 2 represents belonging to the background. The second Mat object Mat_2 will be further corrected through the comparison result to obtain the iteratively optimized separation result to determine whether each pixel belongs to the foreground or background based on the separation result.

[0029] S102: construct a third Mat object according to the size of the first Mat object, and initialize it to a preset pixel value, copy the foreground image area of ​​the second Mat object to the third Mat object, and obtain the current third Mat object.

[0030] In order to facilitate the identification of interference pixels in foreground pixels and thus improve the extraction accuracy of the building plan, in the embodiment of this specification, a third Mat object is constructed according to the size of the first Mat object, and in order to identify non-foreground pixels in the third Mat object, it will be initialized to a preset pixel value, and then the foreground image area of ​​the second Mat object is copied to the third Mat object to obtain the current third Mat object.

[0031] Specifically, in one or more embodiments of the present specification, a third Mat object is constructed according to the size of the first Mat object, and initialized to a preset pixel value, and a foreground image area of ​​the second Mat object is copied to the third Mat object to obtain the current third Mat object, which specifically includes the following process: First, the size of the first Mat object is obtained, so as to construct a third Mat object of the same size as the first Mat object according to the size of the first Mat object. Then, the third Mat object is initialized according to the preset pixel value. It should be noted that the preset pixel value is the pixel value corresponding to white. Then, according to the mask mark information of the second Mat object, it can be determined that the second Mat object belongs to the foreground image area of ​​the foreground pixel point, so as to copy the foreground image area 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 size of the third Mat object is consistent with that of the first Mat object, which helps to avoid the problem of pixel point information loss caused by size mismatch. In addition, the third Mat object is initialized according to the preset pixel value and set to the same pixel value, so that the third Mat object has a unified background before copying the foreground image area, which helps to identify the pixels that do not belong to the foreground in the light-colored area in the subsequent identification. And using the mask mark information of the second Mat object to determine the foreground image area of ​​the foreground pixel point can avoid introducing unnecessary background information.

[0032] S103: Determine non-foreground pixel points in the current third Mat object based on the mask mark information.

[0033] According to the above step S102, the foreground image area of ​​the second Mat object is copied to the third Mat object. After the current third Mat object is obtained, in order to set the area outside the building plan to be transparent while ensuring that the light-colored area in the building plan is not judged as transparent. In the embodiment of this specification, the pixel points of the current third Mat object are matched according to the above-determined mask mark information, so as to determine the non-foreground pixel points in the current third Mat object.

[0034] Specifically, in one or more embodiments of the present specification, based on the mask mark information, determining the non-foreground pixel points in the current third Mat object specifically includes the following process: First, according to the coordinates of each pixel in the current third Mat object, the current third Mat object is mapped to the corresponding pixel coordinates of the first Mat object. Then, according to the determined mapping relationship and the mask mark information of the second Mat object, it is determined whether the pixel of the current third Mat object belongs to the foreground image area to identify the non-foreground pixel in the current third Mat object. That is, through the mask mark information in the second Mat object, the pixel marked as 1 is the foreground and the pixel marked as 0 is the background, and it can be identified whether the pixel is a foreground pixel. For example: a pixel (x1, y1) in the third Mat object, through the second Mat object calling the pixel (x1, y1), it can be known whether the mask mark information of the pixel is 1, that is, based on this, it can be determined which pixels in the current third Mat object belong to non-foreground pixels.

[0035] S104: Obtain the maximum value of the foreground pixel of the second Mat object, and discriminate the non-foreground pixel of the third Mat object based on the maximum value to determine whether to set the non-foreground pixel to be transparent, so as to obtain the processed third Mat object.

[0036] In order to set non-foreground pixels to be transparent, so as to facilitate the superposition of building plans in scenarios such as wireless signal coverage analysis and visual display, it is necessary to set the interference area outside the building plan to be transparent while ensuring that the area close to white inside the building plan is not transparent. Therefore, in the embodiment of this specification, the maximum value of the foreground pixel of the second Mat object is obtained, and the non-foreground pixel of the third Mat object is judged according to the maximum value to determine whether to set the non-foreground pixel to be transparent, thereby obtaining the processed third Mat object.

[0037] Specifically, in one or more embodiments of the present specification, obtaining the maximum value of the foreground pixel of the second Mat object, 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 the following process: First, according to the mask mark information of the second Mat object, the building plan is binarized to obtain the binarized image corresponding to the building plan. Then, the binarized image is identified according to the preset interface to determine the contour information of the building plan. That is, since the contour detection can only work accurately when the contrast between the foreground and the background is obvious, the building plan is binarized to map each pixel in the image to two values ​​0 and 1. Among them, 0 is black for background, and 1 is white for foreground. Then, the contour information is obtained through the preset interface, and the contour information is a list formed by a series of points. Then, the contour information is traversed to determine the maximum value of each foreground pixel in the building plan in the vertical axis direction; among them, it can be understood that the maximum value includes: maximum value and minimum value. That is, the minimum value ymin and the maximum value ymax of the foreground pixel in the y-axis direction are obtained. It is judged whether the non-foreground pixel is within the range of the maximum value. If it is not within the range, the non-foreground pixel is set to transparent. If the non-foreground pixel is within the range of the maximum value, then in order to realize the recognition and extraction of the light-colored area in the building plan, a ray will be created along the horizontal axis according to the current pixel to calculate the number of intersections between the ray and the contour of the foreground area, and determine whether to set the non-foreground pixel to transparent according to the number of contour intersections. In other words, a ray is created along the x-axis from the current pixel, and the number of intersections between the ray and the contour of the foreground area is calculated. If the number of contour intersections is an odd number, it means that the pixel is located within the area of ​​the building plan. If the number of contour intersections is an even number, it means that the pixel is located outside the building plan and needs to be set to transparent.

[0038] In this process, the pixels in the image are simplified into foreground (white) and background (black) through binarization, making the contrast between foreground pixels and background pixels more distinct, making the subsequent contour detection and foreground pixel maximum value calculation more accurate and efficient. Non-foreground pixels are judged according to the maximum value of the foreground pixel. If the non-foreground pixel is not within the maximum value range, it is directly set to transparent. This strategy can effectively remove irrelevant background in the image. At the same time, for non-foreground pixels within the maximum value range, the number of intersections between the ray and the foreground area contour is calculated to further determine whether it should be set to transparent, which not only improves the flexibility of image processing, but also can accurately identify and extract the light-colored area in the building plan.

[0039] S105: Convert the processed third Mat object into a bitmap to obtain the extracted building plan.

[0040] In order to obtain the recognized building plan. In the embodiment of this specification, the processed third Mat object is converted into a bitmap to obtain the extracted building plan. Specifically, in one or more embodiments of this specification, the processed third Mat object is converted into a bitmap to obtain the extracted building plan, which specifically includes the following process: First, a bitmap object is created in the target environment corresponding to the building plan based on the preset tool. Then, the processed third Mat object is encoded according to the preset function to obtain the byte stream corresponding to the processed third Mat object. The byte stream is copied to the pixel buffer according to the interface of the bitmap object, thereby converting the byte stream into the data format of the bitmap object, and obtaining the converted bitmap as the extracted building plan.

[0041] like Figure 2 As shown, the present specification embodiment provides a schematic diagram of the structure of a device for extracting a building plan. Figure 2 It can be seen that in one or more embodiments of this specification, a device for extracting a building plan includes: 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 to enable the at least one processor to: execute any of the above-mentioned methods.

[0042] like Figure 3 As shown, the present specification provides a schematic diagram of the structure of a non-volatile storage medium. Figure 3 It can be seen that in one or more embodiments of the present specification, a non-volatile storage medium stores computer executable instructions 301, and the computer executable instructions 301 can: execute any of the methods described above.

[0043] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0044] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0045] The above description is only one or more embodiments of this specification and is not intended to limit this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included in the scope of the claims of this 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; The processed third Mat object is converted into a bitmap to obtain the extracted building floor plan.

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: 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.

4. 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.

5. 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.

6. 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.

7. 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.

8. 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.

9. 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-8.

10. 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 8.

Citation Information

Patent Citations

  • Light field foreground segmentation method and device based on K-means clustering

    CN107862698A

  • Image processing method, image synthesis method and related device

    CN111080656A

  • Building contour extraction method and system, computer equipment and storage medium

    CN114529837A

  • Method, device and equipment for positioning design area of drawing

    CN116935426A

  • Background matting method and device, equipment and storage medium

    CN117911450A