Method and device for generating virtual map, electronic device and storage medium
By setting the coordinates and heights of path polygons and non-path polygons in the virtual map generation process and adding preset noise, the problem of rough virtual map generation is solved, and the effect of automatically generating a scene that closely approximates reality is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-12
- Publication Date
- 2026-03-31
AI Technical Summary
Current virtual map generation technologies are relatively crude and lack realism, requiring manual correction, resulting in low output efficiency and difficulty in meeting actual needs.
By acquiring the graphics on the coordinate plane, determining the path polygons and non-path polygons, and setting their coordinate heights, preset noise is then added to generate a virtual map, creating an effect that closely approximates the real scene.
Virtual maps that closely resemble real-world scenes can be automatically generated without manual processing, meeting practical needs and improving generation efficiency and realism.
Smart Images

Figure CN115920407B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to methods, apparatus, electronic devices and storage media for generating virtual maps. Background Technology
[0002] In applications such as online games, film and television special effects, and virtual reality, there is often a need to use a large number of virtual maps in a short period of time. For example, in an online game scenario, a game instance is provided for multiple users. Different users can use different game scenes in the instance, and as the number of users increases, the virtual maps in the instance become scarce. Related technologies use random heightmaps to generate 3D virtual maps, but the generated virtual maps are relatively coarse, lack realism, and require manual correction, resulting in low production efficiency and difficulty in meeting practical needs. Summary of the Invention
[0003] This disclosure provides a method, apparatus, electronic device, and storage medium for generating virtual maps, to at least solve the problem in related technologies where virtual maps require manual correction. The technical solution of this disclosure is as follows:
[0004] According to a first aspect of the present disclosure, a method for generating a virtual map is provided, comprising:
[0005] Obtain a graphic on a coordinate plane; the graphic includes multiple polygons, wherein there is no gap between any two adjacent polygons;
[0006] A target polygon is determined from a plurality of polygons, and based on the target polygon, polygons corresponding to a first path and a second path in the virtual map are determined respectively; wherein, the first path is the path initially determined in the virtual map, and the second path is a path generated based on the first path;
[0007] The coordinate height of the path polygons is set to a first preset value, and the coordinate height of the non-path polygons is set to a second preset value to obtain an initial virtual map; wherein, the path polygons include the polygons corresponding to the first path and the second path, and the non-path polygons include the polygons in the graphic other than the first path and the second path;
[0008] Preset noise is added to the coordinates and height of the initial virtual map to generate the virtual map.
[0009] In one possible implementation, determining the polygon corresponding to the first path in the virtual map, based on the target polygon, includes:
[0010] Determine a first adjacent polygon and a second adjacent polygon; wherein the first adjacent polygon is located within a first preset direction range of the target polygon, and the second adjacent polygon is located within a second preset direction range of the target polygon;
[0011] Search for the next adjacent polygon of the first adjacent polygon within the first preset direction range. When found, search for the next adjacent polygon of the next adjacent polygon again, and repeat the search process until the first cutoff condition is met.
[0012] Search for the next adjacent polygon of the second adjacent polygon within the second preset direction range. When found, search for the next adjacent polygon of the next adjacent polygon again. Repeat the search process until the second cutoff condition is met.
[0013] The polygons corresponding to the first path in the virtual map are determined to be the target polygon, the first adjacent polygon, the second adjacent polygon, and each of the next adjacent polygons.
[0014] In one possible implementation, the repeated search process until a first cutoff condition is met includes:
[0015] Repeat the search process until the path length corresponding to the searched polygon is satisfied to be a first preset percentage of the preset length of the first path;
[0016] The repeated search process, until the second cutoff condition is met, includes:
[0017] Repeat the search process until the path length corresponding to the searched polygon is satisfied with a second preset percentage of the preset length of the first path.
[0018] In one possible implementation, based on the target polygon, the polygons corresponding to the first path and the second path are determined respectively, including:
[0019] Based on the target polygon, determine the polygon corresponding to the first path;
[0020] A preset number of starting polygons are randomly determined from the polygons corresponding to the first path;
[0021] Search for the next adjacent polygon of the starting polygon; when found, search for the next adjacent polygon of the next adjacent polygon again, and repeat the search process until the third cutoff condition is met; wherein, the next adjacent polygon includes a polygon randomly determined from the adjacent polygons of the current polygon;
[0022] The polygon corresponding to the second path is determined as the starting polygon and each of the next adjacent polygons.
[0023] In one possible implementation, after determining the polygons corresponding to the first path and the second path respectively, the method further includes:
[0024] Obtain the polygons at both ends of the first path and the second path respectively;
[0025] Randomly assign values to the polygons at both ends to determine the polygons whose values are within a first preset range;
[0026] The adjacent polygons of the polygons within the first preset range are determined as path polygons, and the path polygons are updated accordingly.
[0027] Setting the coordinate height of the path polygon to a first preset value includes:
[0028] Set the coordinate height of the updated path polygon to the first preset value.
[0029] In one possible implementation, after determining the polygons corresponding to the first path and the second path respectively, the method further includes:
[0030] Obtain the width of the adjacent edge between two adjacent polygons in the path polygon;
[0031] If the width is less than a preset width threshold, the original non-path polygon with the endpoints of the adjacent edges as vertices is used as the path polygon to update the path polygon.
[0032] Setting the coordinate height of the path polygon to a first preset value includes:
[0033] Set the coordinate height of the updated path polygon to the first preset value.
[0034] In one possible implementation, determining the target polygon from the plurality of polygons includes:
[0035] Obtain the x-coordinate and y-coordinate of each of the multiple polygons;
[0036] Based on the horizontal and vertical coordinates, the target polygon is determined to be a polygon with the center of the graphic as the center and within a preset radius.
[0037] In one possible implementation, determining the target polygon as a polygon within a preset radius centered on the center of the graphic, based on the horizontal and vertical coordinates, includes:
[0038] Arrange the polygons according to the sum of the horizontal and vertical coordinates;
[0039] The target polygon is obtained by obtaining the polygon whose ratio of the arrangement number to the total number of polygons is a preset percentage; wherein the preset percentage ranges from [1 / 2-δ, 1 / 2+δ], where 0≤δ≤1 / 2.
[0040] In one possible implementation, adding preset noise to the coordinate height of the initial virtual map to generate the virtual map includes:
[0041] Obtain the noise value of the preset noise corresponding to the non-path polygon in the initial virtual map;
[0042] If the noise value is within the second preset range, the coordinate height of the non-path polygon is updated to the third preset value;
[0043] The noise values are added to the corresponding path polygons or non-path polygons to generate a virtual map.
[0044] In one possible implementation, adding the noise value to the corresponding path polygon or non-path polygon to generate a virtual map includes:
[0045] The noise value is multiplied by a preset floating value and then superimposed onto the corresponding path polygon or non-path polygon to generate a virtual map.
[0046] In one possible implementation, after setting the coordinate height of the non-path polygon to a second preset value, the method further includes:
[0047] Obtain the area of a connected region, which is composed of non-path polygons and whose boundaries are adjacent to the path polygons.
[0048] If the area is less than a preset area threshold, the coordinate height of the polygon corresponding to the connected region is set to the first preset value.
[0049] In one possible implementation, before setting the coordinate height of the path polygon to a first preset value, the following is also included:
[0050] Set the coordinate height of the polygon corresponding to the boundary of the graphic to a third preset value.
[0051] In one possible implementation, obtaining the graphic on the coordinate plane includes:
[0052] According to a preset point distribution algorithm, a preset number of coordinate points are distributed on a coordinate plane to obtain a point set of the coordinate plane;
[0053] Based on the point set, a Venn diagram is generated, resulting in a graphic on the coordinate plane.
[0054] According to a second aspect of the present disclosure, a virtual map generation apparatus is provided, comprising:
[0055] The first acquisition module is used to acquire a graphic on a coordinate plane; the graphic includes multiple polygons, wherein there is no gap between any two adjacent polygons;
[0056] The determining module is used to determine a target polygon from a plurality of polygons, and, based on the target polygon, determine the polygon corresponding to a first path and the polygon corresponding to a second path in the virtual map respectively; wherein, the first path is the path initially determined in the virtual map, and the second path is the path generated based on the first path;
[0057] The setting module is used to set the coordinate height of the path polygons to a first preset value and the coordinate height of the non-path polygons to a second preset value to obtain an initial virtual map; wherein, the path polygons include the polygons corresponding to the first path and the second path, and the non-path polygons include the polygons in the graphic other than the first path and the second path;
[0058] The generation module is used to add preset noise to the coordinates and heights of the initial virtual map to generate the virtual map.
[0059] In one possible implementation, the determining module includes:
[0060] A first determining submodule is used to determine a first adjacent polygon and a second adjacent polygon; wherein the first adjacent polygon is located within a first preset direction range of the target polygon, and the second adjacent polygon is located within a second preset direction range of the target polygon;
[0061] The first search submodule is used to search for the next adjacent polygon of the first adjacent polygon within the first preset direction range. When a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the first cutoff condition is met.
[0062] The second search submodule is used to search for the next adjacent polygon of the second adjacent polygon within the second preset direction range. When a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the second cutoff condition is met.
[0063] The second determining submodule is used to determine that the polygon corresponding to the first path in the virtual map is the target polygon, the first adjacent polygon, the second adjacent polygon, and each of the next adjacent polygons.
[0064] In one possible implementation, the first search submodule includes:
[0065] The first search unit is used to search for the next adjacent polygon of the first adjacent polygon within the first preset direction range. When a polygon is found, the unit searches for the next adjacent polygon of the next adjacent polygon again, repeating the search process until the path length corresponding to the searched polygon accounts for a first preset percentage of the preset length of the first path.
[0066] The second search submodule includes a second search unit, which is used to search for the next adjacent polygon of the second adjacent polygon within the second preset direction range. When a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the path length corresponding to the searched polygon is satisfied to a second preset percentage of the first path preset length.
[0067] In one possible implementation, the determining module further includes:
[0068] The third determining submodule is used to determine the polygon corresponding to the first path based on the target polygon;
[0069] The fourth determining submodule is used to randomly determine a preset number of starting polygons from the polygons corresponding to the first path;
[0070] The third search submodule is used to search for the next adjacent polygon of the starting polygon; when a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the third cutoff condition is met; wherein, the next adjacent polygon includes a polygon randomly determined from the adjacent polygons of the current polygon.
[0071] The fifth determining submodule is used to determine the polygon corresponding to the second path as the starting polygon and each of the next adjacent polygons.
[0072] In one possible implementation, the device further includes:
[0073] The second acquisition module is used to acquire the polygons at both ends of the first path and the second path, respectively.
[0074] The processing module is used to randomly assign values to the polygons at both ends and determine the polygons whose values are within a first preset range;
[0075] The first update module is used to determine the adjacent polygons of the polygons within the first preset range as path polygons, so as to update the path polygons.
[0076] The setting module includes:
[0077] The settings submodule is used to set the coordinate height of the updated path polygon to the first preset value.
[0078] In one possible implementation, the device further includes:
[0079] The third acquisition module is used to acquire the width of the adjacent edge between two adjacent polygons in the path polygon;
[0080] The second update module is used to update the path polygon by taking the original non-path polygon with the endpoints of the adjacent edges as vertices when the width is less than a preset width threshold.
[0081] The setting module includes:
[0082] The settings submodule is used to set the coordinate height of the updated path polygon to the first preset value.
[0083] In one possible implementation, the determining module further includes:
[0084] The first acquisition submodule is used to acquire the x-coordinate and y-coordinate of each of the multiple polygons respectively;
[0085] The sixth determination submodule is used to determine the target polygon as a polygon within a preset radius with the center of the graphic as the center, based on the horizontal coordinate and the vertical coordinate.
[0086] In one possible implementation, the sixth determining submodule includes:
[0087] An arrangement unit is used to arrange the polygons according to the sum of the horizontal and vertical coordinates;
[0088] A determining unit is used to obtain polygons whose arrangement number is a preset percentage relative to the total number of polygons, thereby obtaining the target polygon; wherein the preset percentage range includes [1 / 2-δ, 1 / 2+δ], where 0≤δ≤1 / 2.
[0089] In one possible implementation, the generation module includes:
[0090] The second acquisition submodule is used to acquire the noise value of the preset noise corresponding to the non-path polygon in the initial virtual map;
[0091] The update submodule is used to update the coordinate height of the non-path polygon to a third preset value when the noise value is within a second preset range.
[0092] The first generation submodule is used to add the noise value to the corresponding path polygon or non-path polygon to generate a virtual map.
[0093] In one possible implementation, the generation module includes:
[0094] The generation unit is used to multiply the noise value by a preset floating value and then superimpose it onto the corresponding path polygon or non-path polygon to generate a virtual map.
[0095] In one possible implementation, the device further includes:
[0096] The third acquisition module is used to acquire the area of the connected region, which is composed of non-path polygons and whose boundaries are adjacent to the path polygons.
[0097] The first setting module is used to set the coordinate height of the polygon corresponding to the connected domain to the first preset value when the area is less than a preset area threshold.
[0098] In one possible implementation, the device further includes:
[0099] The second setting module is used to set the coordinate height of the polygon corresponding to the boundary of the graphic to a third preset value.
[0100] In one possible implementation, the first acquisition module includes:
[0101] The distribution submodule is used to distribute a preset number of coordinate points on the coordinate plane according to a preset point distribution algorithm, so as to obtain the point set of the coordinate plane;
[0102] The second generation submodule is used to generate a Venn diagram based on the point set, thereby obtaining a graphic on the coordinate plane.
[0103] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0104] processor;
[0105] Memory used to store the processor's executable instructions;
[0106] The processor is configured to execute the instructions to implement the virtual map generation method as described in any of the embodiments of this disclosure.
[0107] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform a virtual map generation method as described in any one of the embodiments of the present disclosure.
[0108] According to a fifth aspect of the present disclosure, a computer program product is provided, the computer program product including instructions that, when executed by a processor of an electronic device, enable the electronic device to perform the virtual map generation method according to any one of the embodiments of the present disclosure.
[0109] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects:
[0110] In this embodiment, based on a graphic on a coordinate plane, path polygons and non-path polygons are determined within the graphic to form a crisscrossing virtual road network. The coordinate heights of the path and non-path polygons are pre-set. When the pre-set coordinate heights are subsequently corrected using preset noise, the distinction between the path and non-path portions is still maintained due to the pre-set relationship. The addition of noise results in path and non-path polygons of varying heights, creating a undulating effect that more closely resembles a real-world scene. Therefore, the solution in this embodiment can automatically generate a virtual map that closely approximates a real-world scene without requiring any manual map processing, thus meeting practical needs.
[0111] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0112] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0113] Figure 1 This is a flowchart illustrating a method for generating a virtual map according to an exemplary embodiment.
[0114] Figure 2 This is a schematic diagram of a coordinate plane graph according to an exemplary embodiment.
[0115] Figure 3 This is a schematic diagram of a first path in a virtual map according to an exemplary embodiment.
[0116] Figure 4 This is a schematic diagram of a first path and a second path in a virtual map according to an exemplary embodiment.
[0117] Figure 5 This is a flowchart illustrating a method for generating a virtual map according to an exemplary embodiment.
[0118] Figure 6 This is a block diagram illustrating the generation of a virtual map according to an exemplary embodiment.
[0119] Figure 7 This is a block diagram illustrating an electronic device according to an exemplary embodiment.
[0120] Figure 8 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation
[0121] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0122] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0123] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0124] The virtual map generation method provided in this disclosure can be applied to terminals or servers. Terminals can be, but are not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Servers can be implemented using independent servers or server clusters composed of multiple servers.
[0125] Figure 1 This is a flowchart illustrating a method for generating a virtual map according to an exemplary embodiment. The method is applied in a terminal or server. Figure 1 As shown, the method includes:
[0126] Step S101: Obtain a graphic on the coordinate plane; the graphic includes multiple polygons, wherein there is no gap between any two adjacent polygons.
[0127] In this embodiment of the disclosure, the graphic may include multiple polygons, which may include regular polygons, such as regular quadrilaterals, parallelograms, regular hexagons, etc., or any irregular polygons. The number of sides of the polygons may include three or more. In this embodiment of the disclosure, there is no gap between any two adjacent polygons, that is, there are no non-polygonal regions in the graphic. In an exemplary embodiment, reference is made to... Figure 2 As shown, Figure 2 In this diagram, x represents the horizontal coordinate and z represents the vertical coordinate. On the xoz coordinate plane, there is no gap between any two adjacent polygons in the graph. In an exemplary embodiment, the graph can be obtained using existing random graph generation algorithms, such as inputting the number of edges and vertices to obtain random polygons. Alternatively, it can be obtained using graph generation tools; this disclosure does not limit this approach.
[0128] In this embodiment of the disclosure, for a graphic on a coordinate plane, the range of coordinate values can be determined based on the size of the virtual map. Alternatively, the area of the graphic can be appropriately widened, and the graphic can be cropped within a preset range in a real-world scenario.
[0129] Step S103: Determine the target polygon from the plurality of polygons, and based on the target polygon, determine the polygon corresponding to the first path and the polygon corresponding to the second path in the virtual map respectively; wherein, the first path is the path determined for the first time in the virtual map, and the second path is the path generated based on the first path.
[0130] In this embodiment, the target polygon serves to locate the virtual map. In one exemplary embodiment, the target polygon may be selected from a polygon within a preset range of the graphic center. In another exemplary embodiment, the target polygon may also include a polygon at or near the graphic edge. In this embodiment, the first path represents the initially determined path, and the second path represents subsequent branch paths generated other than the initially generated path. In one exemplary embodiment, the second path may include a path generated based on the first path. Both the first and second paths contain continuous polygons. In one exemplary embodiment, the first path may include any path passing through the target polygon; the second path may include paths intersecting with the first path. In this embodiment, the number of first and second paths is not limited; the number of paths can be determined according to the specific application scenario of the virtual map.
[0131] Step S105: Set the coordinate height of the path polygons to a first preset value and set the coordinate height of the non-path polygons to a second preset value to obtain an initial virtual map; wherein, the path polygons include the polygons corresponding to the first path and the second path, and the non-path polygons include the polygons in the map other than the first path and the second path.
[0132] In this embodiment of the disclosure, the path polygon may include the polygons corresponding to the first path and the second path, and the non-path polygon includes polygons in the graphic other than the first path and the second path. In this embodiment of the disclosure, the height of the path polygon is set to a first preset value, and the coordinate height of the non-path polygon is set to a second preset value. Considering practical application scenarios, such as in a valley, the height of the path is generally lower than the height of the non-path; therefore, the first preset value can be set to be less than the second preset value. In, for example, in elevated roads or railways, the height of the path is generally higher than the height of the non-path; therefore, the first preset value can be set to be greater than the second preset value.
[0133] Step S107: Add preset noise to the coordinate height of the initial virtual map to generate the virtual map.
[0134] In this embodiment, the preset noise can include various types, such as Gaussian noise, salt-and-pepper noise, and Poisson noise. In an exemplary embodiment, one type of noise can be added to the coordinate height, or two or more types of noise can be added; this disclosure does not limit this. In an exemplary embodiment, adding preset noise to the coordinate height of the initial virtual map can include performing addition, subtraction, multiplication, and division operations, or a combination of addition, subtraction, multiplication, and division, on the coordinate height of each polygon in the initial virtual map and the noise magnitude to change the height of the initial virtual map, presenting a bumpy effect, thus obtaining a virtual map.
[0135] In this embodiment, based on a graphic on a coordinate plane, path polygons and non-path polygons are determined within the graphic to form a crisscrossing virtual road network. The coordinate heights of the path and non-path polygons are pre-set. When the pre-set coordinate heights are subsequently corrected using preset noise, the distinction between the path and non-path portions is still maintained due to the pre-set relationship. The addition of noise results in path and non-path polygons of varying heights, creating a undulating effect that more closely resembles a real-world scene. Therefore, the solution in this embodiment can automatically generate a virtual map that closely approximates a real-world scene without requiring any manual map processing, thus meeting practical needs.
[0136] In one possible implementation, step S103, which involves determining a target polygon from a plurality of polygons, and using the target polygon as a reference, determining the polygons corresponding to the first path and the second path in the virtual map, includes:
[0137] Determine a first adjacent polygon and a second adjacent polygon; wherein the first adjacent polygon is located within a first preset direction range of the target polygon, and the second adjacent polygon is located within a second preset direction range of the target polygon.
[0138] Search for the next adjacent polygon of the first adjacent polygon within the first preset direction range. When found, search for the next adjacent polygon of the next adjacent polygon again, and repeat the search process until the first cutoff condition is met.
[0139] Search for the next adjacent polygon of the second adjacent polygon within the second preset direction range. When found, search for the next adjacent polygon of the next adjacent polygon again, and repeat the search process until the second cutoff condition is met.
[0140] The polygons corresponding to the first path in the virtual map are determined to be the target polygon, the first adjacent polygon, the second adjacent polygon, and each of the next adjacent polygons.
[0141] In this embodiment of the present disclosure, the first preset directional range of the target polygon can be set according to the specific scenario or randomly, such as the angle range of the fourth quadrant in a coordinate graph, or further narrowed to an angle range of 280 degrees to 350 degrees. In this embodiment of the present disclosure, the second preset range can also be set according to the specific scenario or randomly. In an exemplary embodiment, the first preset directional range and the second preset directional range are different, so that the first path has better extensibility. Figure 3 This is a schematic diagram illustrating a first path in a virtual map according to an exemplary embodiment. (Reference) Figure 3 As shown, the target polygon 301 has a first adjacent polygon 303 and a second adjacent polygon 305. In an exemplary embodiment, if there are multiple adjacent polygons within a first preset direction range, one of these adjacent polygons can be selected as the first adjacent polygon. In an exemplary embodiment, each polygon may have a different number of adjacent polygons. Assuming the number of adjacent polygons is n, the neighbors can be numbered from 0 to n-1 in a clockwise direction. The first half of the adjacent polygons represents neighbors with a number range of [0, (n-1) / 2], and the second half of the adjacent polygons represents neighbors with a number range of [(n-1) / 2, n-1]. One of the adjacent polygons in the first half can be selected as the first adjacent polygon, and correspondingly, one of the adjacent polygons in the second half can be selected as the second adjacent polygon.
[0142] In this embodiment of the disclosure, the next adjacent polygon of the first adjacent polygon within the first preset direction range is searched, for example, by referring to... Figure 3 In this context, the next adjacent polygon of the first adjacent polygon 303 is polygon 307. Then, the adjacent polygons of polygon 307 within the first preset direction range are searched until the first cutoff condition is met. The next adjacent polygon of the second adjacent polygon within the second preset direction range is searched, for example, referring to... Figure 3 In this process, the next adjacent polygon of the second adjacent polygon 305 is polygon 309. Then, the adjacent polygons of polygon 309 within the second preset direction range are searched until the second cutoff condition is met.
[0143] In this embodiment of the disclosure, the first cutoff condition and the second cutoff condition may include the condition that the next adjacent polygon found is a preset cutoff marker, such as the boundary of a virtual map, a cliff, etc. In another exemplary embodiment, the first cutoff condition and the second cutoff condition may be set such that the length of the first path meets a preset requirement.
[0144] In this embodiment of the disclosure, the polygon corresponding to the first path is the target polygon, the first adjacent polygon and the second adjacent polygon of the target polygon, and each of the subsequently determined next adjacent polygons.
[0145] In this embodiment of the disclosure, based on the target polygon, the first path is extended in a first preset direction range and a second preset direction range respectively, so that the first path does not intersect itself, thereby improving the uniformity of the distribution of the first path in the virtual map and ensuring the usability of the virtual map.
[0146] In one possible implementation, the repeated search process until a first cutoff condition is met includes:
[0147] Repeat the search process until the path length corresponding to the searched polygon is satisfied to be a first preset percentage of the preset length of the first path;
[0148] The repeated search process, until the second cutoff condition is met, includes:
[0149] Repeat the search process until the path length corresponding to the searched polygon is satisfied with a second preset percentage of the preset length of the first path.
[0150] In this embodiment of the disclosure, reference is made to Figure 3 Starting from the first adjacent polygon 301, during the upward search, the first cutoff condition may include a first preset percentage of the path length corresponding to the searched polygons relative to the preset length of the first path. For example, if the length of the first path is 100, the first preset percentage can be set to 50%, meaning that at least 50 paths corresponding to the searched polygons need to be found. Similarly, starting from the second adjacent polygon 305, during the downward search, the second cutoff condition may include a second preset percentage of the path length corresponding to the searched polygons relative to the preset length of the first path. For example, if the length of the first path is 100, the first preset percentage can be set to 49%, meaning that at least 49 paths corresponding to the searched polygons need to be found. Together with the target polygon, they constitute the preset length of the first path, 100.
[0151] In this embodiment of the disclosure, the first preset percentage of the path length corresponding to the searched polygon to the preset length of the first path is used as the first cutoff condition; the second preset percentage of the path length corresponding to the searched polygon to the preset length of the first path is used as the second cutoff condition, so that the first path polygon that meets the preset length can be obtained.
[0152] In one possible implementation, determining the polygons corresponding to the first path and the second path, based on the target polygon, includes:
[0153] Based on the target polygon, determine the polygon corresponding to the first path;
[0154] A preset number of starting polygons are randomly determined from the polygons corresponding to the first path;
[0155] Search for the next adjacent polygon of the starting polygon; when found, search for the next adjacent polygon of the next adjacent polygon again, and repeat the search process until the third cutoff condition is met; wherein, the next adjacent polygon includes a polygon randomly determined from the adjacent polygons of the current polygon;
[0156] The polygon corresponding to the second path is determined as the starting polygon and each of the next adjacent polygons.
[0157] In this embodiment of the disclosure, determining the polygon corresponding to the first path based on the target polygon may include any of the methods for determining the first path described in the above embodiments, or may include any one or more first paths determined randomly, which will not be elaborated further in this disclosure.
[0158] In this embodiment of the disclosure, a preset number of starting polygons are randomly determined from the polygons corresponding to the first path. In an exemplary embodiment, reference is made to... Figure 4 As shown, for example, a second adjacent polygon 305 is randomly determined from the polygons corresponding to the first path, and polygon 309 is used as the starting polygon. Taking polygon 309 as the starting polygon as an example, an adjacent polygon is randomly determined from the multiple adjacent polygons of polygon 309 as the next adjacent polygon, for example, polygon 310 is used as the next adjacent polygon. The adjacent polygons of polygon 309 are searched again, and polygon 313 is randomly determined as the polygon on the second path, until the third cutoff condition is met.
[0159] In this embodiment of the disclosure, the third cutoff condition may include the searched polygons being set with a preset cutoff marker, such as a cliff marker or a path marker. In an exemplary embodiment, the third cutoff condition may further include the length of the second path meeting a preset length requirement; if the length of the second path does not meet the preset length requirement, the second path can be regenerated. In another exemplary embodiment, the second path may further randomly select a preset number of polygons from the first generated second path as starting polygons to generate different second paths a second time; correspondingly, the third cutoff condition may include the number of times the second path is generated meeting a preset requirement.
[0160] In this embodiment of the disclosure, a preset number of starting polygons are randomly determined in the first path, and the next adjacent polygon of the starting polygon is continuously searched to generate different second paths. This can ensure that each path in the virtual map is identical to at least one of the other paths, thus avoiding the generation of invalid paths.
[0161] In one possible implementation, after determining the polygons corresponding to the first path and the second path respectively, the method further includes:
[0162] Obtain the polygons at both ends of the first path and the second path respectively;
[0163] Randomly assign values to the polygons at both ends to determine the polygons whose values are within a first preset range;
[0164] The adjacent polygons of the polygons within the first preset range are determined as path polygons, and the path polygons are updated accordingly.
[0165] Setting the coordinate height of the path polygon to a first preset value includes:
[0166] Set the coordinate height of the updated path polygon to the first preset value.
[0167] In this embodiment, taking the polygons at both ends as an example, only one of the polygons has an adjacency relationship with other polygons. The polygons at both ends are randomly assigned values, for example, within the range of 0 to 1. A first preset range may include 0 to 0.5 or 0.5 to 1. When the first preset range is 0 to 0.5, the corresponding rule is to classify the adjacent polygons of the polygon as path polygons; when the first preset range is 0.5 to 1, the corresponding rule is not to classify the adjacent polygons of the polygon as path polygons. In an exemplary embodiment, the current moment can be used as the seed for random numbers to obtain different random values. When a random value is needed next time, the next moment is selected as the seed for random numbers. Since the current moment and the next moment will not repeat, the generated random values will also not repeat, ensuring that the same virtual map will not appear.
[0168] In this embodiment, the polygons at both ends of the first path and the second path are randomly assigned values, and the adjacent polygons of the polygons within the first preset range are determined as path polygons. This achieves random expansion of both ends of the path, which is more in line with the characteristics of the path entrance and exit area being large in actual scenarios. Moreover, the random expansion, rather than the complete expansion, is closer to the real scenario.
[0169] In one possible implementation, after determining the polygons corresponding to the first path and the second path respectively, the method further includes:
[0170] Obtain the width of the adjacent edge between two adjacent polygons in the path polygon;
[0171] If the width is less than a preset width threshold, the original non-path polygon with the endpoints of the adjacent edges as vertices is used as the path polygon to update the path polygon.
[0172] Setting the coordinate height of the path polygon to a first preset value includes:
[0173] Set the coordinate height of the updated path polygon to the first preset value.
[0174] In this embodiment of the disclosure, the adjacent edges of two adjacent polygons, such as polygon A and polygon B, are adjacent. An adjacent edge of polygon A and polygon B includes an edge that belongs to both polygon A and polygon B. In an exemplary embodiment, reference is made to... Figure 4 As shown, polygon 501 and polygon 301 are adjacent. If the width of the adjacent edge is less than a preset width threshold, the original non-path polygon with the endpoint of the adjacent edge as its vertex is designated as the path polygon. For example, in the above example, polygons 502 and 503 are also designated as path polygons, and their coordinate height values are updated. Similarly, the area of each polygon in the path polygon is obtained. If the area is less than a preset area threshold, all adjacent polygons of that polygon can be designated as path polygons.
[0175] In this embodiment of the disclosure, the width of the adjacent edges of two adjacent polygons in the path polygon is obtained. When the width is narrow, the polygons at both ends of the adjacent edges are used to expand the path; approximately, the path can also be expanded by considering the area of the polygons. This embodiment of the disclosure can expand narrow paths, ensuring the usability of the virtual map.
[0176] In one possible implementation, determining the target polygon from the plurality of polygons includes:
[0177] Obtain the x-coordinate and y-coordinate of each of the multiple polygons;
[0178] Based on the horizontal and vertical coordinates, the target polygon is determined to be a polygon with the center of the graphic as the center and within a preset radius.
[0179] In this embodiment, the x-coordinate and y-coordinate of the polygon may include the x-coordinate or y-coordinate of a preset position point in each polygon. The preset position point may include a center point, centroid, centroid, or the point where the shape is generated. In an exemplary embodiment, determining the target polygon based on the x-coordinate and y-coordinate may include: arranging the x-coordinates of all polygons in the shape according to their values, selecting multiple polygons whose x-coordinates are located at the center, arranging the y-coordinates of these multiple polygons according to their values, and selecting the polygon whose y-coordinate is located at the center as the target polygon. In another exemplary embodiment, determining the target polygon based on the x-coordinate and y-coordinate may further include: arranging the y-coordinates of all polygons in the shape according to their values, selecting multiple polygons whose y-coordinates are located at the center, arranging the x-coordinates of these multiple polygons according to their values, and selecting the polygon whose x-coordinate is located at the center as the target polygon. In another exemplary embodiment, the sum of the x-coordinates and y-coordinates of the polygons may also be obtained, arranged according to the magnitude of the sum, and the middle polygon may be selected as the target polygon. It should be noted that in the above method, if there are two middle polygons, one of the two polygons may be selected as the target polygon. Since the size and shape of the polygons are irregular, the target polygon obtained by the methods of the above embodiments is a polygon close to the center of the graphic, that is, the target polygon is a polygon within a preset radius with the center of the graphic as the center.
[0180] In this embodiment, by filtering target polygons using their x and y coordinates, the starting position of the path in the virtual map can be determined according to requirements, avoiding starting positions that are too far to the edge, which would result in a generated path that does not meet the requirements. This improves the effectiveness of path generation.
[0181] In one possible implementation, determining the target polygon as a polygon within a preset radius centered on the center of the graphic, based on the horizontal and vertical coordinates, includes:
[0182] Arrange the polygons according to the sum of the horizontal and vertical coordinates;
[0183] The target polygon is obtained by obtaining the polygon whose ratio of the arrangement number to the total number of polygons is a preset percentage; wherein the preset percentage ranges from [1 / 2-δ, 1 / 2+δ], where 0≤δ≤1 / 2.
[0184] In this embodiment, the sum of the horizontal and vertical coordinates of polygons, for example, polygons A(x1,z1), B(x2,z2), C(x3,z3), etc., are used to establish a correspondence between polygons and their sums, such as A: x1+z1, B: x2+z2, C: x3+z3, etc. Polygons A, B, C, etc., are sorted according to their corresponding values. The ratio of the sorting number to the total number of polygons is taken as a preset percentage of the polygons. For example, polygon number 0.5×50=25 is taken, where 50 represents the total number of polygons and 0.5 represents the preset percentage. In this embodiment, the preset percentage range includes [1 / 2-δ, 1 / 2+δ], where 0≤δ≤1 / 2. It should be noted that when δ is fixed, the number of target polygons satisfying the value range may be multiple. In this case, one can be randomly selected from multiple target polygons. The target polygon obtained by the method according to the embodiment is a polygon close to the center of the graphic, which makes the first path and the second path obtained subsequently based on the target polygon more extensible. It should be noted that the setting method of determining the target polygon by the horizontal and vertical coordinates is not limited to the above examples. For example, the horizontal and vertical coordinates of the polygons can be multiplied by the vertical coordinates, and the polygons can be sorted according to the size of the product and selected according to a preset proportion. Those skilled in the art may make other changes under the inspiration of the technical essence of this application, but as long as the function and effect achieved are the same as or similar to this application, they should be covered within the protection scope of this application.
[0185] In this embodiment of the disclosure, by sorting the sum of the horizontal and vertical coordinates, the target polygon of the target location can be quickly determined, such as the polygon at the center of the graphic. Thus, the path generated with this polygon as the starting position is more likely to meet the preset requirements, thereby improving the usability of the virtual map.
[0186] In one possible implementation, adding preset noise to the coordinate height of the initial virtual map to generate the virtual map includes:
[0187] Obtain the noise value of the preset noise corresponding to the non-path polygon in the initial virtual map;
[0188] If the noise value is within the second preset range, the coordinate height of the non-path polygon is updated to the third preset value;
[0189] The noise values are added to the corresponding path polygons or non-path polygons to generate a virtual map.
[0190] In this embodiment, each polygon in the virtual map can be assigned a corresponding noise value according to a preset noise type, and each non-path polygon in the virtual map can also be assigned a corresponding noise value according to a preset noise type. In an exemplary embodiment, if the noise value is within a second preset range, for example, from 0.6 to 1, the coordinate height of the corresponding non-path polygon can be updated from the original second preset value to a third preset value. In another exemplary embodiment, if the noise value exceeds the second preset range, the second preset value of the corresponding non-path polygon remains unchanged. Thus, an initial virtual map with three heights is obtained. It should be noted that the setting of polygon coordinate height in the initial virtual map is not limited to the above three heights; four or more heights can be set as needed. Those skilled in the art may make other changes based on the essence of this application, but as long as the function and effect achieved are the same as or similar to this application, they should all be covered within the scope of protection of this application.
[0191] In this embodiment of the disclosure, adding the noise value to the corresponding path polygon or the updated non-path polygon may include performing addition, subtraction, multiplication, and division operations or a combination of addition, subtraction, multiplication, and division on the coordinate height of each polygon in the initial virtual map and the noise magnitude, so as to change the first preset value corresponding to the path polygon and the second or third preset value corresponding to the non-path polygon, presenting a bumpy effect and obtaining a virtual map.
[0192] In this embodiment of the disclosure, noise is applied to randomly split the coordinate height of a non-path polygon into two coordinate heights, which facilitates the creation of a virtual map with complex terrain.
[0193] In one possible implementation, adding the noise value to the corresponding path polygon or non-path polygon to generate a virtual map includes:
[0194] The noise value is multiplied by a preset floating value and then superimposed onto the corresponding path polygon or non-path polygon to generate a virtual map.
[0195] In this embodiment of the disclosure, for example, taking a path polygon as an example, the coordinate height corresponding to the path polygon is a first preset value, denoted as 'a', the noise value is denoted as 'b', and the preset floating value is 'c'. Then, the coordinate height of the first path polygon after applying noise is: a + b × c. In an exemplary embodiment, the coordinate height of a non-path polygon may include two types, such as a second preset value or a third preset value. The method of adding noise to the second preset value and the third preset value is the same as that of the first preset value, and will not be repeated here. The noise corresponding to the noise value may include Burmester noise. Due to the continuity of the Burmester noise value, the coordinate height after adding Burmester noise presents a continuous and smooth effect, which is closer to the real scene.
[0196] In this embodiment, the noise value is multiplied by a preset floating value and then superimposed onto the corresponding path polygon or non-path polygon, which can easily obtain path polygons and non-path polygons of different heights, forming a bumpy effect that is closer to the real scene.
[0197] In one possible implementation, after setting the coordinate height of the non-path polygon to a second preset value, the method further includes:
[0198] Obtain the area of a connected region, which is composed of non-path polygons and whose boundaries are adjacent to the path polygons.
[0199] If the area is less than a preset area threshold, the coordinate height of the polygon corresponding to the connected region is set to the first preset value.
[0200] In this embodiment, the connected region is composed of non-path polygons, and the boundaries of the non-path polygons are adjacent to the path polygons. The area of the connected region may include one or more non-path polygons. When the area of the connected region is less than a preset area threshold, it can be considered a small protrusion, and the coordinate height of the connected region can be set to a first preset value to smooth out the small protrusion. In an exemplary embodiment, a smoothing algorithm can also be used to perform global smoothing processing on the initial virtual map to further improve the uniformity of coordinate height changes.
[0201] In this embodiment of the disclosure, by comparing the areas of connected regions, if the area is smaller, it is set to a first preset value to smooth out small bumps and present a more natural virtual map.
[0202] In one possible implementation, before setting the coordinate height of the path polygon to a first preset value, the following is also included:
[0203] Set the coordinate height of the polygon corresponding to the boundary of the graphic to a third preset value.
[0204] In this embodiment of the disclosure, the coordinate height of the polygon corresponding to the boundary of the graphic can be set to a third preset value according to the needs of the actual scene. For example, in areas where passage is impossible, such as cliffs. In another exemplary embodiment, the adjacent polygons of the polygon corresponding to the boundary can also be set to the third preset value.
[0205] In this embodiment of the disclosure, the coordinate height of the polygon corresponding to the boundary of the graphic is set to a third preset value, wherein the third preset value is used as a specific identifier and can be used as a cutoff condition for the path generation method.
[0206] In one possible implementation, obtaining the graph of the coordinate plane includes:
[0207] According to a preset point distribution algorithm, a preset number of coordinate points are distributed on a coordinate plane to obtain a point set of the coordinate plane;
[0208] Based on the point set, a Venn diagram is generated, resulting in a graph of the coordinate plane.
[0209] In this embodiment, the point distribution algorithm can include various methods, such as the Lloyd Relaxation algorithm, derivative algorithms of the Lloyd Relaxation algorithm, such as the LBG algorithm, etc. In an exemplary embodiment, the coordinate points can be evenly distributed on the coordinate plane by two Lloyd Relaxation algorithms. The number of coordinate points determines the area of the generated polygons. For example, when the total area of the virtual map is fixed, the more coordinate points there are, the more polygons are generated, and the smaller the area of each polygon is. Therefore, the number of coordinate points can be determined according to actual needs. The method for generating a Voronoi diagram based on the point set can be obtained from publicly available materials. For example, a Delaunay triangulation can be constructed based on the generated discrete coordinate points, the circumcenter of each triangle can be calculated, the circumcenters of adjacent triangles can be connected to form the edges of the Voronoi diagram, and the circumcenters of the triangles can form the points of the Voronoi diagram, thus completing the construction of the Voronoi diagram.
[0210] In this embodiment of the disclosure, the method for generating a Venn diagram can quickly obtain a graphic of a coordinate plane that meets the requirements, and by controlling the number of points, the size of the polygon can be adjusted, thereby adjusting the path width.
[0211] Figure 5 This is a flowchart illustrating a method for generating a virtual map according to an exemplary embodiment. (Reference) Figure 5 As shown, the method includes:
[0212] Step S501: According to the preset point distribution algorithm, a preset number of coordinate points are distributed on the coordinate plane to obtain the point set of the coordinate plane.
[0213] Step S503: Based on the point set, generate a Venn diagram to obtain the graph of the coordinate plane.
[0214] In this embodiment, the point distribution algorithm can include various methods, such as the Lloyd Relaxation algorithm, derivative algorithms of the Lloyd Relaxation algorithm, such as the LBG algorithm, etc. In an exemplary embodiment, the coordinate points can be evenly distributed on the coordinate plane by two Lloyd Relaxation algorithms. The number of coordinate points determines the area of the generated polygons. For example, when the total area of the virtual map is fixed, the more coordinate points there are, the more polygons are generated, and the smaller the area of each polygon is. Therefore, the number of coordinate points can be determined according to actual needs. The method for generating a Voronoi diagram based on the point set can be obtained from publicly available materials.
[0215] Step S505: Determine the target polygon from the plurality of polygons, and using the target polygon as a reference, determine the polygon corresponding to the first path and the polygon corresponding to the second path in the virtual map respectively.
[0216] In this embodiment, the target polygon serves to locate the virtual map. In one exemplary embodiment, the target polygon can be selected from a polygon within a preset range of the graphic center. In another exemplary embodiment, the target polygon can also include a polygon at or near the graphic edge. In this embodiment, the first path represents the initially generated path, and the second path represents subsequent branch paths generated other than the initially generated path. Both the first and second paths contain continuous polygons. In one exemplary embodiment, the first path can include any path passing through the target polygon; the second path can include paths intersecting with the first path. In this embodiment, the number of first and second paths is not limited; the number of paths can be determined according to the specific application scenario of the virtual map.
[0217] Step S507: Set the coordinate height of the path polygon to a first preset value, and set the coordinate height of the non-path polygon to a second preset value.
[0218] In this embodiment of the disclosure, the path polygon may include the polygons corresponding to the first path and the second path, and the non-path polygon includes polygons in the graphic other than the first path and the second path. In this embodiment of the disclosure, the height of the path polygon is set to a first preset value, and the coordinate height of the non-path polygon is set to a second preset value. Considering practical application scenarios, such as in a valley, the height of the path is generally lower than the height of the non-path; therefore, the first preset value can be set to be less than the second preset value. In, for example, in elevated roads or railways, the height of the path is generally higher than the height of the non-path; therefore, the first preset value can be set to be greater than the second preset value.
[0219] Step S509: Obtain the noise value of the preset noise corresponding to the non-path polygon in the initial virtual map.
[0220] Step S511: If the noise value is within the second preset range, update the coordinate height of the non-path polygon to the third preset value.
[0221] Step S513: Add the noise value to the corresponding path polygon or non-path polygon to generate a virtual map.
[0222] In this embodiment, each polygon in the virtual map can be assigned a corresponding noise value according to a preset noise type, and each non-path polygon in the virtual map can also be assigned a corresponding noise value according to a preset noise type. In an exemplary embodiment, if the noise value is within a second preset range, for example, from 0.6 to 1, the coordinate height of the corresponding non-path polygon can be updated from the original second preset value to a third preset value. In another exemplary embodiment, if the noise value exceeds the second preset range, the second preset value of the corresponding non-path polygon remains unchanged. Thus, an initial virtual map with three heights is obtained. It should be noted that the setting of polygon coordinate height in the initial virtual map is not limited to the above three heights; four or more heights can be set as needed. Those skilled in the art may make other changes based on the essence of this application, but as long as the function and effect achieved are the same as or similar to this application, they should all be covered within the scope of protection of this application.
[0223] It should be understood that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order constraint on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the diagram may include multiple steps or stages, which are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0224] It is understood that the same / similar parts between the various embodiments of the methods described above in this specification can be referred to each other. Each embodiment focuses on the differences from other embodiments, and relevant parts can be referred to the description of other method embodiments.
[0225] Based on the same inventive concept, this disclosure also provides a virtual map generation apparatus for implementing the above-described method. The solution provided by this apparatus is similar to the implementation described in the above-described method; therefore, the specific limitations in the target account identification apparatus embodiments provided below can be found in the limitations of the target account identification method described above, and will not be repeated here.
[0226] The apparatus may include a system (including a distributed system), software (application), module, component, server, client, etc., that uses the methods described in the embodiments of this specification, combined with necessary hardware implementation. Based on the same innovative concept, the apparatuses in one or more embodiments provided in this disclosure are as described in the following embodiments. Since the implementation schemes and methods for solving the problem by the apparatus are similar, the implementation of the specific apparatus in the embodiments of this specification can refer to the implementation of the foregoing methods, and repeated details will not be repeated. As used below, the terms "unit" or "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the apparatuses described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0227] Figure 6 This is an apparatus for generating a virtual map, as illustrated in an exemplary embodiment. (Refer to...) Figure 6 The device includes:
[0228] The first acquisition module 601 is used to acquire a graphic on a coordinate plane; the graphic includes multiple polygons, wherein there is no gap between any two adjacent polygons.
[0229] The determining module 603 is used to determine a target polygon from a plurality of polygons, and, based on the target polygon, determine the polygon corresponding to a first path and the polygon corresponding to a second path in the virtual map respectively; wherein, the first path is the path initially determined in the virtual map, and the second path is the path generated based on the first path;
[0230] Setting module 605 is used to set the coordinate height of the path polygon to a first preset value and the coordinate height of the non-path polygon to a second preset value to obtain an initial virtual map; wherein, the path polygon includes the polygons corresponding to the first path and the second path, and the non-path polygon includes the polygons in the graphic other than the first path and the second path;
[0231] The generation module 607 is used to add preset noise to the coordinate height of the initial virtual map to generate the virtual map.
[0232] In one possible implementation, the determining module includes:
[0233] A first determining submodule is used to determine a first adjacent polygon and a second adjacent polygon; wherein the first adjacent polygon is located within a first preset direction range of the target polygon, and the second adjacent polygon is located within a second preset direction range of the target polygon;
[0234] The first search submodule is used to search for the next adjacent polygon of the first adjacent polygon within the first preset direction range. When a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the first cutoff condition is met.
[0235] The second search submodule is used to search for the next adjacent polygon of the second adjacent polygon within the second preset direction range. When a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the second cutoff condition is met.
[0236] The second determining submodule is used to determine that the polygon corresponding to the first path in the virtual map is the target polygon, the first adjacent polygon, the second adjacent polygon, and each of the next adjacent polygons.
[0237] In one possible implementation, the first search submodule includes:
[0238] The first search unit is used to search for the next adjacent polygon of the first adjacent polygon within the first preset direction range. When a polygon is found, the unit searches for the next adjacent polygon of the next adjacent polygon again, repeating the search process until the path length corresponding to the searched polygon accounts for a first preset percentage of the preset length of the first path.
[0239] The second search submodule includes a second search unit, which is used to search for the next adjacent polygon of the second adjacent polygon within the second preset direction range. When a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the path length corresponding to the searched polygon is satisfied to a second preset percentage of the first path preset length.
[0240] In one possible implementation, the determining module further includes:
[0241] The third determining submodule is used to determine the polygon corresponding to the first path based on the target polygon;
[0242] The fourth determining submodule is used to randomly determine a preset number of starting polygons from the polygons corresponding to the first path;
[0243] The third search submodule is used to search for the next adjacent polygon of the starting polygon; when a polygon is found, the next adjacent polygon of the next adjacent polygon is searched again, and the search process is repeated until the third cutoff condition is met; wherein, the next adjacent polygon includes a polygon randomly determined from the adjacent polygons of the current polygon.
[0244] The fifth determining submodule is used to determine the polygon corresponding to the second path as the starting polygon and each of the next adjacent polygons.
[0245] In one possible implementation, the device further includes:
[0246] The second acquisition module is used to acquire the polygons at both ends of the first path and the second path, respectively.
[0247] The processing module is used to randomly assign values to the polygons at both ends and determine the polygons whose values are within a first preset range;
[0248] The first update module is used to determine the adjacent polygons of the polygons within the first preset range as path polygons, so as to update the path polygons.
[0249] The setting module includes:
[0250] The settings submodule is used to set the coordinate height of the updated path polygon to the first preset value.
[0251] In one possible implementation, the device further includes:
[0252] The third acquisition module is used to acquire the width of the adjacent edge between two adjacent polygons in the path polygon;
[0253] The second update module is used to update the path polygon by taking the original non-path polygon with the endpoints of the adjacent edges as vertices when the width is less than a preset width threshold.
[0254] The setting module includes:
[0255] The settings submodule is used to set the coordinate height of the updated path polygon to the first preset value.
[0256] In one possible implementation, the determining module further includes:
[0257] The first acquisition submodule is used to acquire the x-coordinate and y-coordinate of each of the multiple polygons respectively;
[0258] The sixth determination submodule is used to determine the target polygon as a polygon within a preset radius with the center of the graphic as the center, based on the horizontal coordinate and the vertical coordinate.
[0259] In one possible implementation, the sixth determining submodule includes:
[0260] An arrangement unit is used to arrange the polygons according to the sum of the horizontal and vertical coordinates;
[0261] A determining unit is used to obtain polygons whose arrangement number is a preset percentage relative to the total number of polygons, thereby obtaining the target polygon; wherein the preset percentage range includes [1 / 2-δ, 1 / 2+δ], where 0≤δ≤1 / 2.
[0262] In one possible implementation, the generation module includes:
[0263] The second acquisition submodule is used to acquire the noise value of the preset noise corresponding to the non-path polygon in the initial virtual map;
[0264] The update submodule is used to update the coordinate height of the non-path polygon to a third preset value when the noise value is within a second preset range.
[0265] The first generation submodule is used to add the noise value to the corresponding path polygon or non-path polygon to generate a virtual map.
[0266] In one possible implementation, the generation module includes:
[0267] The generation unit is used to multiply the noise value by a preset floating value and then superimpose it onto the corresponding path polygon or non-path polygon to generate a virtual map.
[0268] In one possible implementation, the device further includes:
[0269] The third acquisition module is used to acquire the area of the connected region, which is composed of non-path polygons and whose boundaries are adjacent to the path polygons.
[0270] The first setting module is used to set the coordinate height of the polygon corresponding to the connected domain to the first preset value when the area is less than a preset area threshold.
[0271] In one possible implementation, the device further includes:
[0272] The second setting module is used to set the coordinate height of the polygon corresponding to the boundary of the graphic to a third preset value.
[0273] In one possible implementation, the first acquisition module includes:
[0274] The distribution submodule is used to distribute a preset number of coordinate points on the coordinate plane according to a preset point distribution algorithm, so as to obtain the point set of the coordinate plane;
[0275] The second generation submodule is used to generate a Venn diagram based on the point set, thereby obtaining a graphic on the coordinate plane.
[0276] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0277] Figure 7 This is a block diagram illustrating an electronic device 700 for a method of generating virtual maps according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0278] Reference Figure 7 The electronic device 700 may include one or more of the following components: processing component 702, memory 704, power supply component 706, multimedia component 708, audio component 710, input / output (I / O) interface 712, sensor component 714, and communication component 716.
[0279] Processing component 702 typically controls the overall operation of electronic device 700, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 702 may include one or more modules to facilitate interaction between processing component 702 and other components. For example, processing component 702 may include a multimedia module to facilitate interaction between multimedia component 708 and processing component 702.
[0280] Memory 704 is configured to store various types of data to support the operation of electronic device 700. Examples of such data include instructions for any application or method operating on electronic device 700, contact data, phonebook data, messages, pictures, videos, etc. Memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, optical disk, or graphene memory.
[0281] Power supply component 706 provides power to various components of electronic device 700. Power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 700.
[0282] Multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 708 includes a front-facing camera and / or a rear-facing camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0283] Audio component 710 is configured to output and / or input audio signals. For example, audio component 710 includes a microphone (MIC) configured to receive external audio signals when electronic device 700 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 704 or transmitted via communication component 716. In some embodiments, audio component 710 also includes a speaker for outputting audio signals.
[0284] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0285] Sensor assembly 714 includes one or more sensors for providing state assessments of various aspects of electronic device 700. For example, sensor assembly 714 can detect the on / off state of electronic device 700, the relative positioning of components such as the display and keypad of electronic device 700, changes in position of electronic device 700 or its components, the presence or absence of user contact with electronic device 700, orientation or acceleration / deceleration of device 700, and temperature changes of electronic device 700. Sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 714 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0286] Communication component 716 is configured to facilitate wired or wireless communication between electronic device 700 and other devices. Electronic device 700 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 716 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 716 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0287] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0288] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, which can be executed by a processor 720 of an electronic device 700 to perform the above-described method. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0289] In an exemplary embodiment, a computer program product is also provided, which includes instructions that can be executed by a processor 720 of an electronic device 700 to perform the above-described method.
[0290] Figure 8 This is a block diagram illustrating an electronic device 800 for a method of generating a virtual map according to an exemplary embodiment. For example, the electronic device 800 may be a server. (Refer to...) Figure 8 The electronic device 800 includes a processing component 820, which further includes one or more processors, and memory resources represented by memory 822 for storing instructions, such as application programs, that can be executed by the processing component 820. The application programs stored in memory 822 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 820 is configured to execute instructions to perform the methods described above.
[0291] Electronic device 800 may further include: a power supply component 824 configured to perform power management of electronic device 800, a wired or wireless network interface 826 configured to connect electronic device 800 to a network, and an input / output (I / O) interface 828. Electronic device 800 may operate on an operating system stored in memory 822, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, or similar.
[0292] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 822 including instructions, which can be executed by a processor of an electronic device 800 to perform the above-described method. The storage medium may be a computer-readable storage medium, such as a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.
[0293] In an exemplary embodiment, a computer program product is also provided, the computer program product including instructions that can be executed by a processor of an electronic device 800 to perform the above-described method.
[0294] It should be noted that the above-mentioned apparatus, electronic equipment, computer-readable storage medium, computer program product, etc., may also include other implementation methods according to the description of the method embodiments. For specific implementation methods, please refer to the description of the relevant method embodiments, which will not be elaborated here.
[0295] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0296] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method of generating a virtual map, characterized by, The application relates to a method for generating a virtual map. The method comprises the following steps: acquiring a graph on a coordinate plane; the graph comprises a plurality of polygons, wherein there is no interval region between any two adjacent polygons in the plurality of polygons; the plurality of polygons comprises a plurality of irregular polygons; determining a target polygon from the plurality of polygons, and determining a polygon corresponding to a first path and a polygon corresponding to a second path in a virtual map based on the target polygon; wherein the first path is a path first determined in the virtual map, and the second path is a path generated based on the first path; the method comprises the following steps of determining the polygon corresponding to the first path in the virtual map based on the target polygon: determining a first adjacent polygon and a second adjacent polygon; wherein the first adjacent polygon is located in a first preset direction range of the target polygon, and the second adjacent polygon is located in a second preset direction range of the target polygon; searching for a next adjacent polygon of the first adjacent polygon in the first preset direction range, and when the next adjacent polygon is searched, searching for a next adjacent polygon of the next adjacent polygon again, and repeating the searching process until a first stop condition is met; searching for a next adjacent polygon of the second adjacent polygon in the second preset direction range, and when the next adjacent polygon is searched, searching for a next adjacent polygon of the next adjacent polygon again, and repeating the searching process until a second stop condition is met; and determining the polygon corresponding to the first path in the virtual map as the target polygon, the first adjacent polygon, the second adjacent polygon and each next adjacent polygon; setting a coordinate height of a path polygon as a first preset value and setting a coordinate height of a non-path polygon as a second preset value to obtain an initial virtual map; wherein the path polygon comprises the polygon corresponding to the first path and the second path, and the non-path polygon comprises the polygon in the graph except the first path and the second path; 2. The method of claim 1, wherein, adding a preset noise to the coordinate height of the initial virtual map to generate the virtual map. The repeating searching process until the first stop condition is met comprises the following steps: repeating the searching process until a path length corresponding to a searched polygon accounts for a first preset proportion of a preset length of the first path; The repeating searching process until the second stop condition is met comprises the following steps:
3. The method of claim 1, wherein, repeating the searching process until a path length corresponding to a searched polygon accounts for a second preset proportion of the preset length of the first path. The method further comprises the following steps of: determining the polygon corresponding to the first path in the virtual map based on the target polygon; randomly determining a preset number of starting polygons from the polygon corresponding to the first path; searching for a next adjacent polygon of the starting polygon; when searched, searching for a next adjacent polygon of the next adjacent polygon again, and repeating the searching process until a third stop condition is met; wherein the next adjacent polygon comprises a polygon randomly determined from the adjacent polygons of the current polygon; determining the polygon corresponding to the second path as the starting polygon and each of the next adjacent polygons.
4. The method of claim 1, wherein, After the respective determination of the polygon corresponding to the first path and the polygon corresponding to the second path in the virtual map, the method further comprises: respectively acquiring the polygons at both ends of the first path and the second path; randomly assigning values to the polygons at both ends, and determining the polygons with values in a first preset range; determining the adjacent polygons of the polygons in the first preset range as the polygons corresponding to the paths to update the path polygons; the method further comprises: setting the coordinate height of the updated path polygon to the first preset value.
5. The method of claim 1, wherein, After the respective determination of the polygon corresponding to the first path and the polygon corresponding to the second path in the virtual map, the method further comprises: acquiring the width of the adjacent edge of the adjacent two polygons in the path polygon; in the case where the width is less than a preset width threshold, the original non-path polygon with the end point of the adjacent edge as the vertex is taken as the path polygon to update the path polygon; the method further comprises: setting the coordinate height of the updated path polygon to the first preset value.
6. The method of claim 1, wherein, The method further comprises: respectively acquiring the horizontal coordinates and vertical coordinates of each polygon in the plurality of polygons; determining the target polygon as the polygon within a preset radius range with the center of the graph as the center.
7. The method of claim 6, wherein, The method further comprises: arranging the polygons according to the sum of the horizontal coordinates and the vertical coordinates; acquiring the polygon with a preset proportion of the ratio of the arrangement serial number to the total number of the polygons to obtain the target polygon; wherein the preset proportion has a value range of [1 / 2-δ, 1 / 2+δ], and 0≤δ≤1 / 2.
8. The method of claim 1, wherein, The method further comprises: acquiring the noise value of the preset noise corresponding to the non-path polygon in the initial virtual map; in the case where the noise value is within a second preset range, updating the coordinate height of the non-path polygon to a third preset value; adding the noise value to the corresponding path polygon or non-path polygon to generate a virtual map.
9. The method of claim 8, wherein, The method further comprises: multiplying the noise value by a preset floating value and superimposing it on the corresponding path polygon or non-path polygon to generate a virtual map.
10. The method of claim 1, wherein, The method further includes, after setting the coordinate height of the non-path polygon to the second preset value: Obtaining an area of a connected domain, the connected domain being composed of the non-path polygon, and a boundary of the connected domain being adjacent to the path polygon; In a case where the area is less than a preset area threshold, setting the coordinate height of the polygon corresponding to the connected domain to the first preset value; In a case where the area is greater than or equal to the preset threshold, setting the coordinate height of the polygon corresponding to the connected domain to the second preset value.
11. The method of claim 1, wherein, The method further includes, before setting the coordinate height of the path polygon to the first preset value: Setting the coordinate height of the polygon corresponding to the boundary of the graph to a third preset value.
12. The method according to any one of claims 1 to 11, characterized in that, The method further includes: Distributing a preset number of coordinate points on the coordinate plane according to a preset point distribution algorithm to obtain a point set of the coordinate plane; Generating a Venn diagram based on the point set to obtain the graph on the coordinate plane.
13. An apparatus for generating a virtual map, the apparatus comprising: The method further includes: A first obtaining module, configured to obtain a graph on a coordinate plane; the graph includes a plurality of polygons, wherein there is no interval region between any two adjacent polygons in the plurality of polygons; the plurality of polygons includes a plurality of irregular polygons; A determining module, configured to determine a target polygon from the plurality of polygons, and determine a polygon corresponding to a first path and a polygon corresponding to a second path in a virtual map based on the target polygon; the first path is a path first determined in the virtual map, and the second path is a path generated based on the first path; the determining module includes: a first determining submodule, configured to determine a first adjacent polygon and a second adjacent polygon; the first adjacent polygon is located in a first preset direction range of the target polygon, and the second adjacent polygon is located in a second preset direction range of the target polygon; a first searching submodule, configured to search for a next adjacent polygon of the first adjacent polygon in the first preset direction range, and when the next adjacent polygon is searched, search for a next adjacent polygon of the next adjacent polygon again, and repeat the searching process until a first stop condition is met; a second searching submodule, configured to search for a next adjacent polygon of the second adjacent polygon in the second preset direction range, and when the next adjacent polygon is searched, search for a next adjacent polygon of the next adjacent polygon again, and repeat the searching process until a second stop condition is met; and a second determining submodule, configured to determine the polygon corresponding to the first path in the virtual map as the target polygon, the first adjacent polygon, the second adjacent polygon, and each next adjacent polygon; A setting module, configured to set a coordinate height of a path polygon to a first preset value, and set a coordinate height of a non-path polygon to a second preset value to obtain an initial virtual map; the path polygon includes the polygon corresponding to the first path and the second path, and the non-path polygon includes polygons in the graph other than the first path and the second path. The generating module is configured to add preset noise to the coordinate height of the initial virtual map to generate the virtual map.
14. An electronic device, comprising: The method comprises: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the method for generating a virtual map according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is enabled to perform the method for generating a virtual map according to any one of claims 1 to 12.
Citation Information
Patent Citations
Virtual scene generation method and device, computer equipment and storage medium
CN115359202A