3D map building object annotation method based on candidate label evaluation
Technical Field
The invention relates to the field of map labeling, in particular to a labeling method of buildings under a complex three-dimensional urban scene based on candidate label evaluation.
Background
The map is a unique language in geography, describes geographic knowledge in the real world vividly, intuitively and comprehensively, provides a scientific way for human to know the world and recognize the world, summarizes a lot of geographic knowledge, can acquire a lot of geographic features and geographic rules by observing and analyzing the map, and provides a method and means for scientific discovery and analysis of human. With the progress of computer hardware and geographic data acquisition technology, 3D maps are widely applied in many fields such as planning, navigation, tourism, scientific research and the like, the 3D maps include some basic services such as position inquiry, trip planning, path display and the like, and also integrate some living services such as vehicle inquiry, hotel reservation, leisure and entertainment and the like and office services such as online government affairs and electronic commerce and the like in the maps, and the 3D maps introduce the concept of digital cities into the daily life of users more vividly and truly, thereby bringing practical convenience to the daily life of people. Compared with a two-dimensional map, along with the progress of computer graphics and virtual reality technology, the three-dimensional map has richer scene details and sense of reality, but the daily needs of users are met, and meanwhile, difficulties are brought to the users for identifying geographic space features and extracting information in scenes.
The annotation, which is a specific natural language in the map, can play a supplementary role in the identifiability of the scene information. By introducing the label into the 3D scene, especially in a complex city environment, and by adding labels to natural geographic entities and other human geographic entities, the information expression capability in a virtual environment can be effectively enhanced, a user is helped to establish the relation between virtual environment elements and real world space objects, and a more effective method is provided for the user to acquire the relevant information of the three-dimensional scene. The building object is taken as a typical feature in the 3D scene, and the readability of the 3D scene information can be effectively improved by adding an appropriate label to the building object, so that the immersion of a user in the three-dimensional map scene is improved. But unlike 2D planar features, architectural features and shapes in 3D scenes are quite complex, which further increases the difficulty of building label placement in three-dimensional geographic space. In addition, the spatial relationship between the viewpoint and the building and the relationship between the building and the surrounding environment affect the effect of building labeling.
At present, a plurality of high-tech companies at home and abroad put forward corresponding three-dimensional map labeling modes and are widely commented. However, most of the algorithms adopt a real-time operation mode for label placement, which brings huge performance consumption while ensuring the optimal position of the label, and simultaneously, the problem of confusion associated with the label and the building can also occur, thus actually influencing the actual operation experience of the user. Therefore, how to establish and improve the quality and efficiency of placing building labels in three-dimensional space becomes a valuable research topic.
Disclosure of Invention
The invention aims to provide a labeling method of a 3D map building based on candidate label evaluation aiming at the defects and shortcomings of the existing labeling method in the three-dimensional map labeling process, and the method is used for realizing the accurate labeling effect of the building in a complex three-dimensional city scene.
The technical scheme adopted by the invention for solving the technical problems is as follows: a method for 3D map building annotation based on candidate tag evaluation, the method comprising the steps of:
step 1: and preprocessing the original city building data. Uniformly converting the original data from an shp format into a GeoJSON format, introducing a place name field and a floor number field into the data, and rendering the data into a Cesium platform as a building simplified model.
Step 2: dividing the building outline polygon data into a plurality of triangles, calculating the gravity center coordinate and the area of each triangle, calculating the weighted average of all the triangle gravity center coordinates taking the area as the weight to obtain the center coordinate of the polygon, giving floor factors to obtain the center point coordinate of the highest point or the highest plane of the city building, and taking the center point coordinate as an aiming point for placing a label, so that the label aiming point has the maximum visibility and can keep good visual relevance with the building. And constructing a dynamic direction label which always faces to the screen for the building according to the aiming point of the label.
And step 3: around the dynamic directional labels, there are many potential locations for placing labels, and representative label locations are selected from the set of potential label locations, thereby forming a candidate label set for the building.
And 4, step 4: and evaluating the quality of the label based on the visibility of the label and the reading habit of the user. Firstly, the visibility detection is carried out on the labels in the scene according to the view cone, the labels outside the visual field are removed, and the subsequent operation is not involved. And then, giving a weight to the candidate tag according to the reading habit of the user, wherein the weight directly reflects the appropriateness of the tag position. When the weight of a candidate position is minimum, the position is considered as the best label position.
And 5: and applying a screen space projection technology in perspective transformation to the superposition of multiple building labels in a three-dimensional scene. So that the tags are projected from three-dimensional space into two-dimensional screen space, the tag coordinate system is converted from three-dimensional cartesian coordinates into two-dimensional screen coordinates, and then overlap detection is performed between the individual tags.
Step 6: and applying the bubble sorting algorithm idea to the label conflict resolution of a two-dimensional screen space, designing an algorithm to resolve conflicts existing among labels, and outputting a corresponding label placing result.
Furthermore, the invention uses a polygon center calculation method for reference to obtain the coordinates of the highest point or the central point of the highest plane of the urban building, and uses the coordinates as the aiming point for placing the label to construct a dynamic direction label facing the screen for the building all the time.
Further, the invention combines the requirements of 3D scene building labeling, and selects representative label positions from the potential position set of labels by using a candidate label construction method for reference, so as to form a candidate label set of the building.
Furthermore, the quality evaluation is carried out on the candidate labels based on the label visibility and the reading habit of the user, the labels outside the visual field range are directly removed through the visual cone technology, and the labels do not participate in the operation of the next stage. And giving a weight to the candidate tag according to the reading habit of the user, reflecting the appropriateness of the position of the tag through the weight, and further giving different operation priorities to the candidate tag.
Further, the method combines the requirements of label collision of multiple buildings in a 3D scene, uses a screen space projection technology in perspective transformation for reference, converts a label coordinate system from a three-dimensional Cartesian coordinate system into a two-dimensional screen coordinate system, and judges whether two labels are intersected through a label center point coordinate to complete overlapping detection between the labels.
Furthermore, the invention combines the requirement of label conflict resolution in a two-dimensional screen space, and designs an algorithm to eliminate the conflict existing between labels by using the algorithm idea of bubble sorting for reference. In a specific conflict resolution process, firstly inputting all candidate label sets, inputting two labels each time according to a sequence, calling other labels in the (N-1) th label candidate set to compare when the Nth label overlaps with the (N-1) label, then performing overlap test with the (N-2) th label, putting the (N + 1) th label when the label does not have label conflict with the previous (N-1) labels, and repeating the steps until all labels are completely placed.
Has the advantages that:
1. according to the invention, by combining the requirements of 3D map building labeling and using a candidate label construction method for reference, a candidate label set mainly comprising dynamic direction labels is constructed for each building in a scene, so that the problem of performance consumption caused by real-time calculation of the optimal positions of the labels is effectively reduced, the time complexity of calculation is further reduced, and a better three-dimensional building labeling effect is obtained.
2. The method deeply researches the text length of the label in the object space, adopts a scheme of dynamic space object size, and the pixel size corresponding to the building in the two-dimensional screen space and the visual distance of the user present a negative correlation relationship. The scheme can effectively ensure the text readability of the label, and a user can still clearly see the label even if the building is in a far place.
3. According to the method, the scheme of the dynamic direction label is adopted, so that the label can always face the screen, the good visibility of the label at any visual angle is guaranteed, the excellent visual relevance between the label and the building is kept, and the problem of text inversion caused by the fixed label on the plane roof when the city scene is overlooked is effectively solved.
4. According to the invention, the requirements of label collision of a plurality of buildings in a 3D scene are combined, a screen space projection technology in perspective transformation is used for reference, the labels are converted from a three-dimensional Cartesian coordinate system to a two-dimensional screen coordinate system, label overlapping detection is carried out in the screen space, and an algorithm is designed to solve the collision among the labels, so that the visibility of the building labels is greatly improved, and a good visual effect is provided for a user.
Drawings
Fig. 1 is a technical flowchart of a 3D map building labeling method based on candidate tag evaluation according to the present invention.
Fig. 2 is a schematic diagram of building outline data and its position information used in the example.
FIG. 3 is a schematic diagram of a candidate tag set for building construction.
FIG. 4 is a schematic diagram of a label view cone culling technique.
Fig. 5 is a schematic diagram of evaluation results of candidate tags of a building.
FIG. 6 is a diagram of a screen space projection technique.
FIG. 7 is a flow chart of a tag conflict resolution algorithm in screen space.
The specific implementation mode is as follows:
in the following detailed description of the embodiments of the present invention with reference to the accompanying drawings, a 3D map building labeling method based on candidate tag evaluation includes the following steps:
(1) the method comprises the steps of preprocessing original city building data, calculating to obtain center point coordinate data of a contour, and storing the center point coordinate data as an attribute field in an attribute table of the data. The highest point of a building or the central point of the highest plane is selected as an aiming point for placing the label, then the dynamic direction label is constructed, and the label always faces the screen, so that the label can be well readable under various visual angles.
(2) Around the dynamic directional labels, there are many potential locations where labels can be placed, and representative labels are selected from the potential location sets of labels to form a candidate label set for the building.
(3) During real-time operation, the orientation and size of the tag may be dynamically adjusted, thereby affecting the visual viewing effect of the user. Therefore, the quality of the label must be evaluated to ensure the best visual effect when viewed in real time by the user. And (4) considering the characteristics of the building label in the 3D scene, and evaluating the quality of the label according to the visibility of the label and the reading habit of the user.
1) The first influencing factor is the visibility of the label. The tag will be placed by its default position and its previously calculated object size. However, it may still be culled from the view frustum or obscured by other scene entities in the environment (e.g., buildings). To solve this situation, it is necessary to perform visibility detection on candidate tags and reject tags with poor visibility.
2) The second influencing factor is the reading habit of the user, in cartography, the receiving effect of the user on information is directly influenced by different positions of the label, an ideal label has excellent visual correlation effect and good readability, and the quality of the label near the aiming point is evaluated according to the general reading habit of the user. Different weights are given to each candidate position of the label aiming point in the scene, the weight directly reflects the position appropriateness of the candidate label, and the smaller the weight is, the more appropriate the candidate position of the label is.
(4) The screen space technology in perspective transformation is applied to the problem of conflict of a plurality of building labels, the building labels are projected to a two-dimensional screen space from a three-dimensional space, the overlap among the labels is detected in the screen, an algorithm is designed to eliminate the conflict among the labels, and finally the placement of the labels is completed.
1) According to the scheme provided by the invention, all labels in the current view field are obtained through the view cones, labels outside the view cones do not enter into conflict calculation, and then the three-dimensional Cartesian coordinates labeled in the object space are converted into two-dimensional screen coordinates. After the annotations within the view frustum are projected into screen space in FIG. 6, tag collision is considered a two-dimensional overlay problem.
2) And after the tag conflict problem is converted from three dimensions to two dimensions, the conflict problem is solved in a screen space. The placement positions of the labels are represented by rectangular areas, whether the two rectangles are intersected or not is judged through the distance difference of the center points of the two rectangular areas, when all candidate positions of one label are obviously overlapped with the other label, the show attribute of the label is set to be Flase, and the label is hidden and does not participate in the next-stage operation.
3) By combining the requirement of label conflict resolution in a two-dimensional screen space and using the idea of bubble sorting for reference, an algorithm is designed to eliminate the conflict existing between the labels. In a specific conflict solving process, firstly inputting all building candidate label sets, inputting two labels each time according to a sequence, calling other labels in the N-1 label candidate set for comparison when the Nth label is overlapped with the N-1 labels, then performing overlap test with the N-2 labels, putting the (N + 1) th label when the label is not in label collision with the previous (N-1) labels, and repeating the steps until all the labels are completely placed.
As shown in fig. 1, the 3D map building annotation method based on candidate tag evaluation of the present invention mainly consists of the following three parts:
1. building candidate tag locations are generated based on the dynamic direction.
2. Label quality assessment based on label visibility and reading habits.
3. Tag conflict resolution allowing for overlapping locations.
The detailed flow of the 3D map building annotation method is described in detail by taking building data in Beijing as an example.
(1) Building data preprocessing
Selecting building outline data of the east city area of Beijing City as shown in FIG. 2, calculating the center point coordinates of each outline polygon, storing the coordinates as attribute fields in an attribute table of the data, giving different heights to the building according to different floor numbers of the data, and rendering the coordinates on a Cesium platform in a GeoJSON format to be used as a simple model of the building.
(2) Building candidate tag locations are generated based on the dynamic direction.
And calculating and acquiring the central point of the highest plane of the building based on the center of the polygon as an aiming point for placing the label, and generating a dynamic direction label facing the screen all the time. Around the dynamic orientation tag, there are many potential locations where the tag can be placed. Fig. 3 shows a typical set of four possible potential tag locations for a tag target point, referred to as a quartile model of candidate tags, from which a set of candidate tag locations for a building is constructed.
(3) Label quality assessment based on label visibility and reading habits.
As shown in fig. 4, the building tags are subjected to visibility detection, and tags with poor visibility are directly removed from the candidate tag set and do not participate in the next stage of operation. And secondly, performing quality evaluation on the labels near the aiming point according to the general reading habits of the user. Each candidate position of the target point of the label in the scene is given different weight, and the weight directly reflects the position appropriateness of the candidate label. As shown in fig. 5, each candidate tag has a different weight, and the weight is inversely related to the position accuracy, and when the weight of a candidate position is the smallest, the position is considered as the best tag position.
In addition, the invention also researches the text length of the label in the object space, and adopts a scheme of dynamic space object size to ensure that the label far away from the user has good readability. First, an expected pixel size (px) of each tag is obtained in a screen space according to the font size (pt) of the tag, the font size can be defined by a user, and then the corresponding size of each pixel value (px) in an object space is calculated according to a model matrix, a projection matrix, a view matrix, a window matrix and the position of the tag.
The size of the pixel corresponding to the building in the two-dimensional screen space and the visual distance of the user present a negative correlation, but in the method provided by the invention, the font size of the label is set to be a dynamic size, namely, the size of the label in the screen space is always kept unchanged, so that the label can still be clearly seen by the user even if the label is in a remote place.
(4) Tag conflict resolution allowing for overlapping locations.
Aiming at the situation that label collision may occur when the optimal labels of different buildings in a scene are projected into a screen space, a screen space projection technology in perspective transformation is applied to the problem solution of label collision, so that the labels of the buildings are converted into a two-dimensional screen coordinate system from a three-dimensional Cartesian coordinate system, and after the labels in the view frustum are projected into the screen space, the label collision is regarded as a two-dimensional overlapping problem in the figure 6. And (4) performing overlapping detection among all the labels in a screen space, and designing an algorithm according to the bubble sorting idea to finally solve the conflict among the labels. FIG. 7 is a flow chart of an algorithm for tag conflict resolution. By combining the method provided by the invention, the method can realize accurate marking of the building in a complex three-dimensional scene while maintaining good visual relevance between the label and the building, and has good flexibility and universality.
The above description is only an embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be made by those skilled in the art within the technical scope of the present invention are intended to be included in the scope of the present invention.