Method and device for generating region boundary in virtual space, electronic equipment and medium
By collecting and processing regional boundary data in real space in extended real-life technology and generating regular and closed virtual boundaries, the safety hazards caused by irregular boundaries in the prior art are solved, and the user's sense of security and operational controllability are improved.
Patent Information
- Application Number
- CN202411826003.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-11
AI Technical Summary
In the existing extended real-life technology, the area boundaries in the virtual space are often irregular and unclosed, resulting in users prone to collisions with obstacles in the real environment when they are active in the virtual environment, increasing safety hazards.
By obtaining the N first sampling points and distance information of the contour of the preset area collected by the XR device in the real space, performing density processing, removing the intersection path segments, forming a closed pattern, and smoothing the boundaries and fitting to generate a regular and closed target area boundary.
It realizes the generation of regular closed regional boundaries in the virtual environment, allowing users to intuitively identify boundaries, avoid collisions with obstacles in the real environment, and improve user safety.
Smart Images

Figure CN119741323A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of extended reality technology, and specifically relates to a method, device, electronic device and medium for generating area boundaries in a virtual space. Background Art
[0002] When a user uses an extended reality (XR) device to enter a virtual environment, the user's field of vision will be blocked by the virtual environment, and the user will not be able to know the situation in the real environment. At this time, the XR device will scan the real environment through sensors such as cameras and direct time offlight (dTof) to obtain an irregular environment boundary. The XR device will render this environment boundary into the virtual space through a security prevention algorithm to provide safety prompts to the user and prevent the user from colliding with obstacles in the real environment when moving in the virtual environment.
[0003] Since the safety protection algorithm needs to work in a closed area, the irregular and non-closed environmental boundaries in the real environment will affect the application effect and performance of the safety protection algorithm. The irregular and non-closed environmental boundaries of the real environment are rendered into the virtual space. In the virtual environment, the environmental boundaries are also irregular and non-closed. If the boundaries are irregular and non-closed, it will cause visual errors to users and bring greater dangers to users. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, device, electronic device and storage medium for generating area boundaries in a virtual space, so as to generate regular closed area boundaries in a virtual environment, so that a user can intuitively see the regular closed area boundaries in the virtual environment, and avoid colliding with obstacles in the real environment when the user is active in the virtual environment.
[0005] In a first aspect, an embodiment of the present application provides a method for generating a region boundary in a virtual space, the method being applied to an XR device, the method comprising:
[0006] Acquire N first sampling points of the outline of a preset area collected by the XR device in the real space, and first distance information from the XR device to the first sampling point when each first sampling point is collected, wherein there is no obstacle in the preset area;
[0007] According to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, the N first sampling points are subjected to density processing to obtain M second sampling points, where M and N are both positive integers;
[0008] In a case where there are intersecting path segments in the first path formed by the M second sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points of the M second sampling points form a first closed figure, and the first path is a path formed by sequentially connecting the M second sampling points in a sampling order;
[0009] Smoothing the boundary of the first closed figure to obtain a second closed figure;
[0010] The first and last sampling points of the second closed figure are fitted to obtain a target area boundary, where the target area boundary is a boundary corresponding to the outline of the preset area in the virtual space.
[0011] In a second aspect, an embodiment of the present application provides a device for generating a region boundary in a virtual space, the device being applied to an XR device, the device comprising:
[0012] A first acquisition module, configured to acquire N first sampling points of the outline of a preset area collected by the XR device in the real space, and first distance information from the XR device to the first sampling point when each of the first sampling points is collected, wherein there is no obstacle in the preset area;
[0013] A first determining module, configured to perform density processing on the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, to obtain M second sampling points, where M and N are both positive integers;
[0014] a second determining module, configured to, when there are intersecting path segments in the first path formed by the M second sampling points and the intersecting path segments enclose a closed area, remove the second sampling points enclosing the closed area, and form a first closed graph with the remaining second sampling points among the M second sampling points, wherein the first path is a path formed by sequentially connecting the M second sampling points in a sampling order;
[0015] A third determining module, configured to smooth the boundary of the first closed figure to obtain a second closed figure;
[0016] The fourth determination module is used to fit the first and last sampling points of the second closed figure to obtain a target area boundary, where the target area boundary is a boundary corresponding to the outline of the preset area in the virtual space.
[0017] In a third aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0018] In a fourth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0020] In an embodiment of the present application, by performing density processing on the N first sampling points according to the number of N first sampling points of the outline of the preset area collected by the XR device in the real space and the first distance information from the XR device to the first sampling point when each first sampling point is collected, M second sampling points are obtained. When there are intersecting path segments in the first path composed of the M second sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points of the M second sampling points form a first closed figure, and then the boundary of the first closed figure is smoothed to obtain a second closed figure, and the first and last sampling points of the second closed figure are fitted to obtain the boundary of the target area. In this way, the boundary of the target area obtained by the solution of the embodiment of the present application is regular and closed, and the user can intuitively see the regular and closed boundary of the target area in the virtual environment, thereby avoiding the user from colliding with obstacles in the real environment when moving in the virtual environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is a flowchart of a method for generating a region boundary in a virtual space provided by some embodiments of the present application;
[0022] Figure 2 is a schematic diagram of a first sampling point provided in some embodiments of the present application;
[0023] Figure 3 is a schematic diagram of a second sampling point provided in some embodiments of the present application;
[0024] Figure 4 is a schematic diagram of a first path provided by some embodiments of the present application;
[0025] Figure 5 is a schematic diagram of a process of generating a first closed figure provided in some embodiments of the present application;
[0026] Figure 6 is a schematic diagram of a process of generating a first closed figure provided in some embodiments of the present application;
[0027] Figure 7 is a schematic diagram of smoothing a first closed figure provided by some embodiments of the present application;
[0028] Figure 8 is a schematic diagram of a second closed figure provided by some embodiments of the present application;
[0029] Fig. 9 is a schematic diagram of fitting the first sampling point of the second closed figure provided by some embodiments of the present application;
[0030] Fig.10 is a schematic diagram of a target area boundary provided by some embodiments of the present application;
[0031] Fig.11 is a partial schematic diagram of the target area boundary provided by some embodiments of the present application;
[0032] Fig.12 is a partial schematic diagram of an initial area boundary with a preset area provided in some embodiments of the present application;
[0033] Fig.13 is a schematic diagram of a flow chart of adjusting all thresholds in a target area boundary generation process provided by some embodiments of the present application;
[0034] Fig.14 is a schematic diagram of the structure of a device for generating a region boundary in a virtual space shown in some embodiments of the present application;
[0035] Fig.15 is a schematic diagram of the structure of an electronic device shown in some embodiments of the present application;
[0036] Fig.16 It is a schematic diagram of the hardware structure of an electronic device shown in some embodiments of the present application. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0038] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or N. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0039] As described in the background technology, in the prior art, the region boundaries in the virtual environment are irregular and not closed, which may cause the user to encounter obstacles when moving in the real environment. In order to solve the above problem, the embodiments of the present application provide a method, device, electronic device and medium for generating region boundaries in a virtual space, by performing density processing on the N first sampling points according to the number of N first sampling points of the outline of the preset region collected by the XR device in the real space, and the first distance information from the XR device to the first sampling point when each first sampling point is collected, to obtain M second sampling points, and in the first path composed of the M second sampling points When there are intersecting path segments and the intersecting path segments form a closed area, the second sampling points that form the closed area are removed, and the remaining second sampling points of the M second sampling points form a first closed figure, and then the boundary of the first closed figure is smoothed to obtain a second closed figure, and the first and last sampling points of the second closed figure are fitted to obtain the target area boundary. In this way, the target area boundary obtained by the solution of the embodiment of the present application is regular and closed, and the user can intuitively see the regular and closed target area boundary in the virtual environment, thereby avoiding the user from colliding with obstacles in the real environment when moving in the virtual environment.
[0040] The technical solution of the embodiment of the present application can be applied to the scenario of processing irregular and non-closed area boundaries in a virtual environment.
[0041] The following is a detailed description of the method for generating area boundaries in a virtual space provided by the embodiment of the present application through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0042] Figure 1 It is a flow chart of a method for generating area boundaries in a virtual space provided in an embodiment of the present application. The executor of the information processing method may be an XR device, which may be, but is not limited to, a virtual reality (VR) device or an augmented reality (AR) device.
[0043] like Figure 1 As shown, the method for generating area boundaries in a virtual space provided in an embodiment of the present application may include steps 110 to 150.
[0044] Step 110: Obtain N first sampling points of the outline of the preset area collected by the XR device in the real space, and first distance information from the XR device to the first sampling point when each first sampling point is collected.
[0045] The preset area may be an area where no obstacles exist in the real space, that is, no obstacles exist in the preset area.
[0046] The first sampling point may be a sampling point obtained by sampling the contour of the preset area.
[0047] For each first sampling point, the corresponding first distance information may be the distance information between the XR device and the first sampling point when the first sampling point is collected.
[0048] In some embodiments of the present application, N first sampling points of the contour of a preset area may be collected through the handle of the XR device. Specifically, the handle of the XR device may have a ray emitting end, which may emit rays. The emitted rays are projected onto the contour of the preset area, thereby obtaining a first sampling point.
[0049] The handle of the XR device may also have a ray receiving end, which can receive rays fed back from the outline of the preset area. Then, according to the dTof algorithm in the dTof sensor, the distance between the sampling point projected on the outline of the preset area and the handle of the XR device can be obtained. This distance is the first distance information.
[0050] Step 120: Perform density processing on the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each first sampling point to obtain M second sampling points.
[0051] The M second sampling points may be sampling points obtained by performing a sparse / dense process on the N first sampling points, where M and N are both positive integers.
[0052] In some embodiments of the present application, the dense area and the sparse area of the N first sampling points can be determined according to the number of the N first sampling points and the first distance information corresponding to each first sampling point, and then the sampling points are deleted for the first sampling points in the dense area, and the sampling points are compensated for the first sampling points in the sparse area, so that M second sampling points can be obtained. The specific implementation method is as follows:
[0053] In some embodiments of the present application, when the handle of the XR device is used to collect the first sampling points, the speed at which the user draws with the handle is uncertain, so the sparsity of the collected first sampling points is also different, that is, some first sampling points are very dense, and some first sampling points are very sparse, which leads to irregularity in determining the contour boundary of the preset area. Therefore, in order to ensure the regularity of the contour boundary of the preset area, step 120 may specifically include:
[0054] Calculate the average value of the first distance information corresponding to the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each first sampling point to obtain the average distance information;
[0055] Obtaining distance information between every two adjacent first sampling points of N first sampling points to obtain N second distance information;
[0056] Determine, according to the average distance information and each second distance information, the density state of the line segment between the two first sampling points corresponding to each second distance information;
[0057] According to the density state of the line segment between every two adjacent first sampling points, the N first sampling points are subjected to density processing to obtain M second sampling points.
[0058] The average distance information may be an average value of the first distance information corresponding to the N first sampling points calculated according to the number of the N first sampling points and the first distance information corresponding to each first sampling point.
[0059] The second distance information may be distance information between two adjacent first sampling points among the N first sampling points.
[0060] The density state may be the density state of the line segment between every two adjacent first sampling points, and specifically the density state may be a sparse state or a dense state.
[0061] In some embodiments of the present application, according to the number of N first sampling points and the first distance information corresponding to each first sampling point, the average value of the first distance information corresponding to the N first sampling points can be calculated according to the following formula (1) to obtain the average distance information:
[0062] L_avg=(L1+L2+…LN) / N (1)
[0063] In the above formula (1), L_avg is the average distance information.
[0064] Then, the distance information between every two adjacent first sampling points of the N first sampling points is obtained to obtain N second distance information. According to the average distance information and each second distance information, the density state of the line segment between the two first sampling points corresponding to each second distance information can be determined, that is, it is determined whether the line segment between the two first sampling points corresponding to each second distance information is sparse or dense. Then, according to the density state of the line segment between every two adjacent first sampling points, the N first sampling points are subjected to density processing to obtain M second sampling points.
[0065] In one example, taking N=11 as an example, Figure 2 : is a schematic diagram of 11 first sampling points collected, 9 of which are P1, P2, P3, ..., P11. According to the above formula (1), the average value of the first distance information corresponding to P1, P2, P3, ..., P11 is calculated. After obtaining the average distance information L_avg, the distance information between each two adjacent first sampling points in P1, P2, P3, ..., P11 is obtained to obtain 8 second distance information, that is, Figure 2 D1, D2, ..., D11 in the figure, and then the density of the line segments between P1 and P2, the line segments between P2 and P3, ..., the line segments between P8 and P9 can be determined according to the average distance information L_avg and D1, D2, ..., D11. Then, according to the density of the line segments between P1 and P2, the line segments between P2 and P3, ..., the line segments between P10 and P11, the line segments between P1 and P2, the line segments between P2 and P3, ..., the line segments between P10 and P11 can be density processed.
[0066] In the embodiment of the present application, by performing density processing on N first sampling points according to the density of the line segment between each two adjacent first sampling points, the density between the first sampling points can be made consistent, thereby ensuring that the contour boundary of the drawn preset area is more regular.
[0067] In some embodiments of the present application, in order to accurately determine the density state of the line segment between the two first sampling points corresponding to each second distance information, the step of determining the density state of the line segment between the two first sampling points corresponding to each second distance information according to the average distance information and each second distance information may specifically include:
[0068] Calculate the difference between the average distance information and each second distance information to obtain N differences;
[0069] When the difference corresponding to the first target distance information is greater than the first preset difference threshold, determining that the density state of the line segment corresponding to the first target distance information is a sparse state;
[0070] When the difference corresponding to the first target distance information is less than the second preset difference threshold, it is determined that the density state of the line segment corresponding to the first target distance information is a dense state.
[0071] The first target distance information may be any one of each second distance information.
[0072] The first preset difference threshold may be the maximum threshold of the difference corresponding to the preset first target distance information. The first preset difference threshold may be, for example, 1.5. The specific value of the first preset difference threshold may be set according to user needs and is not limited in the embodiment of the present application.
[0073] The second preset difference threshold may be a preset minimum threshold of the difference corresponding to the first target distance information. The second preset difference threshold may be, for example, 0.5. The specific value of the second preset difference threshold may be set according to user needs and is not limited in the embodiment of the present application.
[0074] In some embodiments of the present application, when the difference corresponding to the first target distance information is greater than the first preset difference threshold, the density state of the line segment corresponding to the first target distance information can be determined to be a sparse state; when the difference corresponding to the first target distance information is less than the second preset difference threshold, the density state of the line segment corresponding to the first target distance information can be determined to be a dense state.
[0075] Continuing to refer to the above example, taking the first preset difference threshold as 1.5 and the second preset difference threshold as 0.5 as an example, if the difference between the average distance information L_avg and D3-D6, D9-D11 is between 0.5-1.5, and the difference between the average distance information L_avg and D1 and D2 is greater than 1.5, then the density state of the line segment between P1 and P2, and the line segment between P3 and P4 is considered to be sparse; if the difference between the average distance information L_avg and D5 and D8 is less than 0.5, then the density state of the line segment between P7 and P8, and between P8 and P9 is considered to be dense.
[0076] In an embodiment of the present application, the density state of the line segment corresponding to each second distance information is determined by the difference between the average distance information and each second distance information, so that the density state of the line segment corresponding to each second distance information can be accurately determined.
[0077] In some embodiments of the present application, if the density state of the line segment between two first sampling points is sparse, sampling point compensation processing needs to be performed; if the density state of the line segment between two first sampling points is dense, some sampling points need to be deleted, that is, performing density processing on N first sampling points according to the density state of the line segment between each two adjacent first sampling points to obtain M second sampling points may specifically include:
[0078] When it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a dense state, removing the first target sampling point or the second target sampling point;
[0079] When it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a sparse state, a sampling point is added between the first target sampling point and the second target sampling point.
[0080] The first target sampling point and the second target sampling point may be any two adjacent first sampling points among the N first sampling points. For example, the first target sampling point and the second target sampling point may be respectively Figure 2 The first sampling point P1 and the first sampling point P2 in .
[0081] In some embodiments of the present application, if the density state of the line segment between the first target sampling point and the second target sampling point is a dense state, the first target sampling point or the second target sampling point is removed; if the density state of the line segment between the first target sampling point and the second target sampling point is a sparse state, a sampling point is added between the first target sampling point and the second target sampling point.
[0082] Continuing with the above example, the line segment between P1 and P2, and the line segment between P2 and P3 are in a sparse state, then Figure 3 As shown, a sampling point P12 is added between P1 and P2, and a sampling point P13 is added between P2 and P3. If the density state of the line segments between P7 and P8, and between P8 and P9 is dense, P7, P8 or P9 can be deleted, for example, P8 can be deleted, so that 12 second sampling points can be obtained.
[0083] It should be noted that, when the density state of the line segment between the first target sampling point and the second target sampling point is dense, when the first target sampling point or the second target sampling point is removed, specifically, according to the distance between the second target sampling point and the first sampling point in front of the first target sampling point (distance 1), and the distance between the first target sampling point and the first sampling point behind the second target sampling point (distance 2), the distance 1 and the distance 2 are compared, and whichever distance is smaller, the sampling point corresponding to the distance is deleted. For example, if the distance 1 is greater than the distance 2, the first target sampling point corresponding to the distance 2 is deleted, so as to avoid a larger distance between the sampling points.
[0084] For example, continuing to refer to the above example, the distance between P6 and P8 is 2.5, the distance between P8 and P9 is less than the second preset difference threshold 0.5, the distance between P8 and P10 is 2.1, and the distance between P7 and P9 is 1.6. If P7 is deleted, the distance between P6 and P8 is too large, and a sampling point needs to be added between P6 and P7. If P9 is deleted, the distance between P8 and P10 is also too large. If P8 is deleted, the distance between P7 and P9 is between the first preset difference threshold and the second preset difference threshold, so P8 can be deleted and P7 and P9 can be retained.
[0085] When the density state of the line segment between the first target sampling point and the second target sampling point is sparse, when adding a sampling point between the first target sampling point and the second target sampling point, the number of added sampling points can be set according to the needs, and the distance between the two sampling points can be kept within a certain range as much as possible, for example, the distance between the two sampling points can be kept within 1-1.5. In the above example, only one sampling point is added as an example for explanation, but it is not limited to only one sampling point.
[0086] In an embodiment of the present application, when it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a dense state, the first target sampling point or the second target sampling point is removed, and when it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a sparse state, a sampling point is added between the first target sampling point and the second target sampling point. In this way, the line segment between the first target sampling point and the second target sampling point can be accurately processed to obtain regular sampling points, and then a regular contour boundary can be obtained.
[0087] Step 130: When there are intersecting path segments in the first path composed of the M second sampling points, and the intersecting path segments enclose a closed area, remove the second sampling points that enclose the closed area, and form a first closed figure with the remaining second sampling points in the M second sampling points.
[0088] The first path may be a path formed by sequentially connecting M second sampling points in a sampling order.
[0089] Continuing with the above example, the 12 second sampling points are connected in sequence, that is, P1 is connected to P12, P12 is connected to P2, P2 is connected to P13, ..., P11 is connected to P1, so that the following can be obtained: Figure 4 The first path is shown.
[0090] The first closed image may be a closed figure formed by the remaining second sampling points in the M second sampling points after removing the second sampling points forming the closed area.
[0091] In some embodiments of the present application, since the areas enclosed by the sampling points may intersect in the process of collecting sampling points of the contour of the preset area, and the safety zone actually required in the virtual space should be an area, what is drawn is the contour boundary of the preset area, and the boundaries cannot intersect, and the intersection affects the visual effect finally displayed in the virtual space, so it is necessary to process the intersecting areas.
[0092] Specifically, when there are intersecting path segments in the first path composed of M second sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area can be removed, and the remaining second sampling points in the M second sampling points form a first closed figure.
[0093] Continue to refer Figure 4 , Figure 4 The path segment formed by P6 and P7 in the first path shown intersects with the path segment formed by P10 and P11, and the intersecting path segments P6-P7 and P10-P11 can enclose a closed area 41. Then, the second sampling points P7, P10 and P9 enclosing the closed area 41 can be removed, and P6 and P11 can be connected. Then, the remaining second sampling points P1, P12, P2, P13, P3, P4, P5, P6 and P11 can form a closed area 41. Figure 5 The first closed figure 51 is shown.
[0094] In some other embodiments of the present application, after the second sampling points that enclose a closed area are removed, the paths between the remaining sampling points will be interrupted, but according to the solution of the embodiment of the present application, the remaining sampling points can also be connected to form a first closed figure.
[0095] In one example, reference Figure 6, the second sampling points P1-P11 form a first path, the path segment formed by P10 and P1 intersects with the path segment formed by P10 and P11, and the intersecting path segments P10-P1 and P10-P11 can enclose a closed area 601, then the second sampling point P11 enclosing the closed area 601 can be removed, and there is a break between P10 and P1, then P10 and P1 can be connected to form a first closed figure 602.
[0096] In some embodiments of the present application, after obtaining the M second sampling points, the positions of some second sampling points may be relatively deviated, and such second sampling points are called noise sampling points. In order to make the formed target area boundary more regular, before step 130, the above method may further include:
[0097] Remove the noise sampling points from the M second sampling points to obtain P third sampling points;
[0098] Step 130 may specifically include:
[0099] When there are intersecting path segments in the first path composed of the P third sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points among the M second sampling points form a first closed figure.
[0100] The third sampling point may be a sampling point remaining after removing noise sampling points from the M second sampling points. Here, P is a positive integer.
[0101] In some embodiments of the present application, before processing the intersection area, the noise sampling points in the M second sampling points may be first removed to obtain P third sampling points, and the intersection area may be processed based on the P third sampling points, so that a relatively regular first closed figure may be obtained.
[0102] In an embodiment of the present application, by removing noise sampling points from the M second sampling points, P third sampling points are obtained, and thus the intersection area can be processed based on the P third sampling points, thereby obtaining a relatively regular first closed figure, and thereby obtaining a relatively regular target area boundary.
[0103] In some embodiments of the present application, in order to improve the efficiency and accuracy of removing noise sampling points, removing the noise sampling points from the M second sampling points to obtain P third sampling points may specifically include:
[0104] Dividing the M second sampling points into at least one calculation window;
[0105] The following steps are performed for each calculation window to remove the noise sampling points within the calculation window:
[0106] Obtaining the position information of each second sampling point in the calculation window;
[0107] Calculate the average value of the coordinate value of each coordinate axis of each second sampling point in the calculation window to obtain the average coordinate value of the X axis, the average coordinate value of the Y axis and the average coordinate value of the Z axis respectively;
[0108] When it is determined that the coordinate value of the target axis of the third target sampling point is less than the preset coordinate value of the target axis, the coordinate value of the target axis of the third target sampling point is updated based on the coordinate value of the target axis of the third target sampling point and the average coordinate value of the target axis to obtain an updated third target sampling point.
[0109] Each calculation window may include at least one second sampling point.
[0110] For each calculation window, the position information of each second sampling point in the calculation window may include an X-axis coordinate value, a Y-axis coordinate value, and a Z-axis coordinate value of the second sampling point.
[0111] The third target sampling point may be any second sampling point in the calculation window.
[0112] The target axis can be the X axis, the Y axis and / or the Z axis.
[0113] The preset coordinate value of the target axis may be a preset coordinate value of the target axis, and the preset coordinate value of the target axis may be a preset coordinate value of the target axis that enables a smooth connection between the third target sampling point and its adjacent second sampling point. The specific value of the preset coordinate value of the target axis can be set according to user needs and is not limited in the embodiments of the present application.
[0114] In some embodiments of the present application, the M second sampling points may be divided into at least one calculation window, and calculations may be performed sequentially for each calculation window. This way, the amount of calculations per calculation will not be too large, and the efficiency of the calculations may be improved.
[0115] For each calculation window, the position information of each second sampling point in the calculation window can be obtained, and then the average coordinate value of each coordinate axis of each second sampling point in the calculation window is calculated to obtain the average coordinate value of the X-axis, the average coordinate value of the Y-axis, and the average coordinate value of the Z-axis respectively.
[0116] Continuing to refer to the above example, the position information of P1, P12, P2, P13, P3, P4, P5, P6, P7, P9, P10 and P11 can be obtained respectively, and then the average value of the X-axis coordinate values of P1, P12, P2, P13, P3, P4, P5, P6, P7, P9, P10 and P11, the average value of the Y-axis coordinate values of P1, P12, P2, P13, P3, P4, P5, P6, P7, P9, P10 and P11, and the average value of the Z-axis coordinate values of P1, P12, P2, P13, P3, P4, P5, P6, P7, P9, P10 and P11 can be calculated respectively.
[0117] The following is an example of calculating the average value of the X-axis coordinate values of P1, P12, P2, P13, P3, P4, P5, P6, P7, P9, P10 and P11. The average value of the X-axis coordinate values of P1, P12, P2, P13, P3, P4, P5, P6, P7, P9, P10 and P11 can be calculated using the following formula (2):
[0118]
[0119] After obtaining the average value of the coordinate value of each coordinate axis of each second sampling point in the calculation window, when it is determined that the coordinate value of the target axis of the third target sampling point is less than the preset coordinate value of the target axis, the coordinate value of the target axis of the third target sampling point is updated based on the coordinate value of the target axis of the third target sampling point and the average coordinate value of the target axis to obtain an updated third target sampling point.
[0120] That is to say, if it is determined that the X-axis coordinate value of a second sampling point is less than the preset X-axis coordinate value, the X-axis coordinate value of the second sampling point is updated based on the X-axis coordinate value of the second sampling point and the average X-axis coordinate value.
[0121] When it is determined that the Y-axis coordinate value of the second sampling point is less than the preset Y-axis coordinate value, the Y-axis coordinate value of the second sampling point is updated based on the Y-axis coordinate value of the second sampling point and the average Y-axis coordinate value.
[0122] When it is determined that the Z-axis coordinate value of the second sampling point is less than the preset Z-axis coordinate value, the Z-axis coordinate value of the second sampling point is updated based on the Z-axis coordinate value of the second sampling point and the average Z-axis coordinate value.
[0123] In this way, the updated second sampling point can be obtained based on the updated coordinate value of the X axis, the updated coordinate value of the Y axis and / or the updated coordinate value of the Z axis.
[0124] Continuing to refer to the above example, for example, if the position of a second sampling point Pi is relatively deviated, it can be determined whether the X-axis coordinate, Y-axis coordinate and Z-axis coordinate of the second sampling point Pi are respectively less than their corresponding preset coordinate values. If it is determined that the X-axis coordinate and Y-axis coordinate of the second sampling point Pi are respectively less than their corresponding preset coordinate values, the X-axis coordinate value of the second sampling point Pi can be updated according to the average coordinate value of the X-axis and the X-axis coordinate value of the second sampling point Pi, and the Y-axis coordinate value of the second sampling point Pi can be updated according to the average coordinate value of the Y-axis and the Y-axis coordinate value of the second sampling point Pi.
[0125] In an embodiment of the present application, by dividing the M second sampling points into at least one calculation window, the second sampling points in each calculation window can be calculated in turn, and the noise sampling points in the calculation window can be removed. In this way, the amount of calculation when removing the noise sampling points each time will not be too large, thereby improving the efficiency of removing the noise sampling points. In addition, for each calculation window, the noise sampling points are removed according to the position information of the second sampling points in the calculation window, so that the sampling points with large position information deviations can be accurately determined and removed, thereby improving the accuracy of removing the noise sampling points.
[0126] In some embodiments of the present application, in order to accurately determine the coordinate value of the target axis of the updated third target sampling point, the coordinate value of the target axis of the third target sampling point is updated based on the coordinate value of the target axis of the third target sampling point and the average coordinate value of the target axis to obtain the updated third target sampling point, which may specifically include:
[0127] Calculate the average coordinate value of the target axis and the average coordinate value of the target axis of the third target sampling point;
[0128] The average value is used as the updated coordinate value of the target axis of the third target sampling point.
[0129] In some embodiments of the present application, the average coordinate value of the target axis and the average coordinate value of the target axis of the third target sampling point may be used as the updated coordinate value of the target axis of the third target sampling point.
[0130] That is, if it is determined that the coordinate value of the X axis of a certain second sampling point is less than the preset coordinate value of the X axis, the average coordinate value of the X axis and the average value of the coordinate value of the X axis of the second sampling point can be calculated, and then the average value can be used as the updated coordinate value of the X axis of the second sampling point. If it is determined that the coordinate value of the Y axis of a certain second sampling point is less than the preset coordinate value of the Y axis, the average coordinate value of the Y axis and the average value of the coordinate value of the Y axis of the second sampling point can be calculated, and then the average value can be used as the updated coordinate value of the Y axis of the second sampling point. If it is determined that the coordinate value of the Z axis of a certain second sampling point is less than the preset coordinate value of the Z axis, the average coordinate value of the Z axis and the average value of the coordinate value of the Z axis of the second sampling point can be calculated, and then the average value can be used as the updated coordinate value of the Z axis of the second sampling point.
[0131] Continuing to refer to the above example, taking the case where the X-axis coordinate and the Y-axis coordinate of the second sampling point Pi are respectively less than the corresponding preset coordinate values, the average coordinate value of the X-axis and the average value 1 of the X-axis coordinate value of the second sampling point Pi are calculated, and the average value 1 is used as the updated X-axis coordinate value of the second sampling point Pi. The average coordinate value of the Y-axis and the average value 2 of the Y-axis coordinate value of the second sampling point Pi are calculated, and the average value 2 is used as the updated Y-axis coordinate value of the second sampling point Pi to obtain the updated second sampling point Pi.
[0132] In an embodiment of the present application, the average coordinate value of the target axis and the average coordinate value of the target axis of the third target sampling point are used as the coordinate value of the target axis of the updated third target sampling point, so that the coordinate value of the target axis of the updated third target sampling point can be accurately determined.
[0133] It should be noted that after obtaining the updated second sampling points Pi, the second sampling points can be connected in sequence, so that a first path can be obtained, and then a first closed graph can be obtained based on the first path.
[0134] Step 140: Smoothing the boundary of the first closed figure to obtain a second closed figure.
[0135] The second closed figure may be a closed figure obtained by smoothing the boundary of the first closed figure.
[0136] In some embodiments of the present application, in order to obtain a smooth target area boundary, step 140 may specifically include:
[0137] The following steps are performed for every three adjacent sampling points of each sampling point of the first closed figure to obtain a second closed figure:
[0138] Acquire a fourth target sampling point, a fifth target sampling point, and a sixth target sampling point that are adjacent to each other;
[0139] Connecting the fourth target sampling point and the sixth target sampling point based on a Bezier curve to obtain a candidate feature point;
[0140] Acquire a first direction vector between the fourth target sampling point and the sixth target sampling point, and a second direction vector between the fifth target sampling point and the candidate feature point;
[0141] Determine, based on the first direction vector and the second direction vector, an angle value of an angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point;
[0142] Based on the angle value, the candidate feature points of the target are determined.
[0143] The fourth target sampling point, the fifth target sampling point and the sixth target sampling point may be any three adjacent sampling points among the sampling points of the first closed figure. Specifically, the fourth target sampling point is located before the fifth target sampling point, the sixth target sampling point is located after the fifth target sampling point, and the angle between the line between the fourth target sampling point and the fifth target sampling point and the line between the fifth target sampling point and the sixth target sampling point is greater than a preset angle threshold.
[0144] The above-mentioned preset angle threshold may be a threshold of the angle between a line between the fourth target sampling point and the fifth target sampling point, and a line between the fifth target sampling point and the sixth target sampling point, for example, may be 80°. The specific value of the preset angle threshold may be set according to user needs and is not limited in the embodiment of the present application.
[0145] Continue to refer Figure 5 , taking the fifth target sampling point as P1 and the preset angle threshold as 80° as an example, the fourth target sampling point is P11, the sixth target sampling point is P12, and the angle between the line between P1 and P11 and the line between P1 and P12 is greater than 80°, it is considered that when P1, P12, P2, P13, P3, P4, P5, P6 and P11 are connected by a smooth curve to form a smooth boundary, there is no way to connect P1, P11 and P12 by a smooth curve, such as Figure 5 shown.
[0146] The candidate feature point may be a point on the Bezier curve, which can smoothly connect the fourth target sampling point and the sixth target sampling point, and has the smallest position information difference with the fifth target sampling point.
[0147] Continuing with the above example, Figure 7 As shown, a smooth curve may be drawn, for example, a Bezier curve may be used to connect P12 and P11. On the Bezier curve, there is a point P1' which is closest to P1, and P11, P12 and the point may be connected by a smooth curve.
[0148] The first direction vector may be a direction vector between the fourth target sampling point and the sixth target sampling point.
[0149] The second direction vector may be a direction vector between the fifth target sampling point and the candidate feature point.
[0150] The target candidate feature point may be a feature point determined on the Bezier curve that smoothly connects the fourth target sampling point and the sixth target sampling point, and a point with the smallest position information difference with the fifth target sampling point.
[0151] In some embodiments of the present application, for every three adjacent sampling points among the sampling points of the first closed figure, it is determined whether the angle between the line connecting the sampling point located in the middle (hereinafter referred to as the control point) and the sampling points before and after it (the sampling point before the control point is referred to as the starting point, and the sampling point before the control point is referred to as the ending point) is greater than a preset angle threshold. If not, there is no need to process the three sampling points. If greater, the position of the sampling point located in the middle is re-determined in the following manner to form a second closed figure.
[0152] The starting point and the end point are connected by a Bezier curve, and then a point (i.e., the target candidate feature point) is found on the Bezier curve so that the distance between it and the control point is the shortest. This point is used as the new control point, that is, the position of the original control point is moved to the position of this point.
[0153] Specifically, to find the target candidate feature point on the Bezier curve, first find the candidate feature point B(t) by the following formula (3):
[0154] B(t)=(1-t) 2 ·P 起始点 +2·(1-t)·t·P 控制点 +t 2 ·P 结束点 (3)
[0155] In the above formula (3), the range of t is 0-1, P 起始点 Characterizes the position information of the starting point, P 控制点 Represents the location information of the control point, P 结束点 Represents the location information of the end point.
[0156] Then, the first direction vector between the starting point and the ending point, and the second direction vector between the control point and the candidate feature point are obtained. Based on the first direction vector and the second direction vector, the dot product calculation is performed according to the following formula (4) to determine the angle value of the angle formed by the candidate feature point, the ending point and the starting point. That is, the angle value doubleres between the line connecting the candidate feature point and the starting point and the line connecting the candidate feature point and the ending point can be determined according to the following formula (4):
[0157] doubleres=V1 _ x·V2 _ x+V1 _ y·V2 _ y+V1 _ z·V2 _ z (4)
[0158] In the above formula (4), V1 is the first direction vector, V2 is the second direction vector, V1_x is the component vector of the first direction vector in the X-axis direction, V1_y is the component vector of the first direction vector in the Y-axis direction, V1_z is the component vector of the first direction vector in the Z-axis direction, V2_x is the component vector of the second direction vector in the X-axis direction, V2_y is the component vector of the second direction vector in the Y-axis direction, and V2_z is the component vector of the second direction vector in the Z-axis direction.
[0159] After obtaining the angle value of the angle formed by the candidate feature point, the end point and the start point according to the above formula (4), the target candidate feature point can be determined based on the angle value.
[0160] Continue to refer Figure 7 ,exist Figure 7 In the formula (4), P1 is the control point, P11 is the starting point, and P12 is the ending point. According to the position information of P1, P11, and P12, the position information of the candidate feature point on the Bezier curve can be obtained by substituting them into the above formula (3). Then, the direction vector between P11 and the candidate feature point is obtained as the first direction vector, and the direction vector between the candidate feature point and P12 is obtained as the second direction vector. The first direction vector and the second direction vector are substituted into the above formula (4) to obtain the angle value of the angle θ between the line between P11 and the candidate feature point and the line between the candidate feature point and P12. According to the angle value of the angle θ, the target candidate feature point P1' can be determined.
[0161] In the embodiment of the present application, by performing smoothing processing on every three adjacent sampling points in the first closed figure, a smooth target area boundary can be obtained.
[0162] It should be noted that before smoothing every three adjacent sampling points in the first closed figure according to the above formula (3) and formula (4), the sampling points in the first closed figure can be smoothed once using the above formula (2), and then the smoothed sampling points are smoothed using the above formula (3) and formula (4). In this way, the sampling points of the first closed figure are gradually smoothed, avoiding the problem of poor smoothing effect caused by directly smoothing the sampling points using the above formula (3) and formula (4).
[0163] In some embodiments of the present application, the first direction vector and the second direction vector may include an X-axis direction component vector, a Y-axis direction component vector, and a Z-axis direction component vector; in order to determine the angle value of the angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point, the determining the angle value of the angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point based on the first direction vector and the second direction vector may specifically include:
[0164] Calculate the product of the X-axis direction component vector of the first direction vector and the X-axis direction component vector of the second direction vector to obtain the X-axis direction target component vector;
[0165] Calculate the product of the Y-axis direction vector component of the first direction vector and the Y-axis direction vector component of the second direction vector to obtain the Y-axis direction target vector component;
[0166] Calculate the product of the Z-axis direction component vector of the first direction vector and the Z-axis direction component vector of the second direction vector to obtain the Z-axis direction target component vector;
[0167] The sum of the target component vector in the X-axis direction, the target component vector in the Y-axis direction, and the target component vector in the Z-axis direction is determined as the angle value of the angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point.
[0168] The target X-axis direction component vector may be the product of the X-axis direction component vector of the first direction vector and the X-axis direction component vector of the second direction vector, that is, V1_x·V2_x in the above formula (4).
[0169] The Y-axis target component vector may be the product of the Y-axis component vector of the first direction vector and the Y-axis component vector of the second direction vector, that is, V1_y·V2_y in the above formula (4).
[0170] The target Z-axis direction component vector may be the product of the Z-axis direction component vector of the first direction vector and the Z-axis direction component vector of the second direction vector, that is, V1_z·V2_z in the above formula (4).
[0171] In some embodiments of the present application, the product of the X-axis direction component of the first direction vector and the X-axis direction component of the second direction vector, the product of the Y-axis direction component of the first direction vector and the Y-axis direction component of the second direction vector, and the product of the Z-axis direction component of the first direction vector and the Z-axis direction component of the second direction vector can be calculated respectively, and then the sum of the products is determined as the angle value of the angle formed by the candidate feature point, the fourth target sampling point and the sixth target sampling point, as shown in the above formula (4).
[0172] In an embodiment of the present application, by respectively calculating the product of the X-axis direction component of the first direction vector and the X-axis direction component of the second direction vector, the product of the Y-axis direction component of the first direction vector and the Y-axis direction component of the second direction vector, and the product of the Z-axis direction component of the first direction vector and the Z-axis direction component of the second direction vector, and then determining the sum of the products as the angle value of the angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point, the angle value of the angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point can be accurately determined.
[0173] In some embodiments of the present application, in order to accurately determine the target candidate feature points, the determining the target candidate feature points based on the angle value may specifically include:
[0174] The candidate feature point corresponding to the angle value of 90° is determined as the target candidate feature point.
[0175] In some embodiments of the present application, the value of t in the above formula (3) can be continuously adjusted. Specifically, the value of t can be continuously adjusted starting from 0 and in steps of 0.01 until the angle value obtained according to the above formula (4) is 90°, and then the candidate feature point corresponding to the angle value of 90° is determined as the target candidate feature point.
[0176] In the embodiment of the present application, the candidate feature point corresponding to the angle value of 90° is determined as the target candidate feature point, so that the target candidate feature point can be accurately determined.
[0177] Step 150: Fit the first and last sampling points of the second closed figure to obtain the boundary of the target area.
[0178] The boundary of the target area may be a boundary corresponding to the outline of the preset area in the virtual space, that is, the outline boundary of the preset area finally displayed in the virtual space, and the boundary of the target area is regular and closed.
[0179] In some embodiments of the present application, after the second closed figure is obtained, the first and last sampling points in the second closed figure may not be well closed, for example, the tail has a boundary that is drawn too far, such as Figure 8In this case, the first and last sampling points of the second closed figure need to be fitted so that the closed boundary of the target area can be obtained.
[0180] In some embodiments of the present application, in order to ensure the closure of the boundary of the target area, step 150 may specifically include:
[0181] The following steps are performed for the Q sampling points at the tail of the second closed figure to obtain the boundary of the target area:
[0182] Get the angle between the first sampling point of the second closed figure and the i-th sampling point of the tail;
[0183] When it is determined that the angle is less than the third threshold, the i-th sampling point at the tail is deleted;
[0184] Update i to i+1;
[0185] Return to the step of obtaining the angle between the first sampling point of the second closed figure and the i-th sampling point of the tail, and when it is determined that the angle is less than the third threshold, deleting the i-th sampling point of the tail, until the angle is greater than or equal to the third threshold, thereby obtaining the target tail sampling point;
[0186] The first sampling point of the second closed figure and the sampling point of the target tail are fitted to obtain the boundary of the target area.
[0187] Wherein, Q is a positive integer, the initial value of i is 1, and i starts counting from the last sampling point at the tail.
[0188] The third threshold may be a preset threshold of the angle between the first sampling point of the second closed figure and the i-th sampling point of the tail. The third threshold may be, for example, 120°. The specific value of the third threshold may be set according to user needs and is not limited in the embodiment of the present application.
[0189] The target tail sampling point may be the i-th sampling point of the tail corresponding to when the angle between the first sampling point of the second closed figure and the i-th sampling point of the tail is greater than or equal to the third threshold.
[0190] In some embodiments of the present application, for the tail Q sampling points of the second closed figure, the tail Q sampling points here may be: the sampling points after the sampling point closed with the first sampling point among the tail sampling points of the second closed figure, such as Fig. 9 As described above, the first sampling point P1 is closed to the tail sampling point P9, and the sampling points P15-P17 after the tail sampling point P9 are the tail Q sampling points that need to be processed. The specific processing process is as follows:
[0191] First, the angle between the first sampling point of the second closed figure and the last sampling point of the tail is obtained, and it is determined whether the angle is less than the third threshold value. If so, it is determined that the last sampling point of the tail is a sampling point that is overdrawn, and the last sampling point of the tail can be deleted. Then, the second-to-last sampling point of the tail is processed continuously, and the angle between the first sampling point of the second closed figure and the second-to-last sampling point of the tail is determined. It is determined whether the angle is less than the third threshold value. If so, it is determined that the second-to-last sampling point of the tail is a sampling point that is overdrawn, and the second-to-last sampling point of the tail can be deleted. In this way, the Q sampling points of the tail are processed in turn until the angle between a certain sampling point of the tail and the first sampling point of the second closed figure is greater than or equal to the third threshold value. Then, the tail sampling point is determined as the target tail sampling point, and then the target tail sampling point is connected with the first sampling point of the second closed figure to obtain the closed target area boundary.
[0192] Continue to refer Fig. 9 , taking the third threshold of 120° as an example, for the overdrawn sampling points P15-P17, as Fig. 9 As shown, first determine whether the angle between the first sampling point P1 and the last sampling point P18 of the tail is less than 120°, and the angle between P1 and P17 is less than 120°, then delete P17, then determine whether the angle between P1 and P16 is less than 120°, and the angle between P1 and P16 is less than 120°, then delete P16, then determine whether the angle between P1 and P15 is less than 120°, and the angle between P1 and P15 is less than 120°, then delete P15, then determine whether the angle between P1 and P9 is less than 120°, and the angle between P1 and P9 is not less than 120°, then retain P9, and use P9 as the target tail sampling point, then connect P1 and P9, and get the following Fig.10 The target area boundaries are shown.
[0193] In the embodiment of the present application, the Q sampling points at the tail are judged in sequence to avoid drawing a line segment that is too far at the tail, thereby ensuring the closure of the boundary of the target area.
[0194] In some embodiments of the present application, in order to obtain a target area boundary that is more consistent with an original area boundary of a preset area, fitting the first sampling point of the second closed figure and the target tail sampling point to obtain the target area boundary may include:
[0195] Fit the first sampling point of the second closed figure and the sampling point of the target tail to obtain the candidate region boundary;
[0196] Get the original area boundary of the preset area;
[0197] Determine the fit between the candidate region boundary and the original region;
[0198] When the degree of fit is less than or equal to a fourth threshold, each threshold in the process of determining the candidate region boundary is adjusted, the candidate region boundary is regenerated, and an updated candidate region boundary is obtained;
[0199] When it is determined that the degree of fit between the updated candidate region boundary and the original region boundary is greater than a fourth threshold, the updated candidate region boundary is determined as the target region boundary.
[0200] The candidate region boundary may be a region boundary obtained by fitting the first sampling point of the second closed figure and the target tail sampling point.
[0201] The original region boundary may be a region boundary of the preset region in the real space.
[0202] The fourth threshold may be a pre-set threshold of the degree of fit between the candidate region boundary and the original region. The fourth threshold may be, for example, 90%. The specific value of the fourth threshold may be set according to user needs and is not limited in the embodiments of the present application.
[0203] In some embodiments of the present application, after performing the above operations and obtaining the candidate area boundary, the candidate area boundary may not fit the original area boundary of the user preset area well. At this time, it is necessary to adjust each threshold in the candidate area boundary determination process, regenerate the candidate area boundary, and obtain an updated candidate area boundary. When the degree of fit between the updated candidate area boundary and the original area boundary is less than the fourth threshold, the updated candidate area boundary is determined as the target area boundary.
[0204] In one example, if Fig.11 and Fig.12 As shown, Fig.11 A partial schematic diagram of the determined candidate region boundary. Fig.12 is a partial schematic diagram of the original area boundary of the preset area. Fig.11 and Fig.12 It can be seen that Fig.11 The candidate region boundaries shown are Fig.12 The original region boundaries shown do not fit well, specifically Fig.11 The candidate region boundary shown in the figure has lost the details of the region boundary. The sampling points P20 and P21 should protrude outward, but after the above operation, the sampling points P20 and P21 are excessively smoothed, resulting in Fig.11The candidate region boundary shown has lost the details of the region boundary. At this time, each threshold in the candidate region boundary determination process can be adjusted to regenerate the candidate region boundary to obtain an updated candidate region boundary. When the degree of fit between the updated candidate region boundary and the original region boundary is less than the fourth threshold, the updated candidate region boundary is determined as the target region boundary.
[0205] It should be noted that each threshold in the process of determining the boundary of the candidate area may be all thresholds involved in the process of determining the boundary of the candidate area, such as the first threshold, the second threshold and the third threshold mentioned above, and the thresholds or parameters involved in the calculation of formulas (1)-(4), such as the parameter t involved in calculating the above formula (3), and the first preset difference threshold and the second preset difference threshold involved in determining the density state of the line segment corresponding to the first target distance information, the order of the Bezier curve used when smoothing the first closed figure, such as the second order or the third order, and so on.
[0206] In the embodiment of the present application, by calculating the degree of fit between the generated candidate region boundary and the original region boundary of the preset region, a target region boundary that is more consistent with the original region boundary of the preset region can be obtained.
[0207] In some embodiments of the present application, in order to accurately determine the degree of fit between the candidate region boundary and the original region boundary, the determining the degree of fit between the candidate region boundary and the original region boundary may specifically include:
[0208] Compare the candidate region boundary with the original region boundary to determine the fit between the candidate region boundary and the original region boundary;
[0209] Determine the smoothness of the candidate region boundary according to the angle between each two adjacent sampling points in the candidate region boundary and the angle between each two adjacent sampling points in the original region boundary;
[0210] Based on the fit and smoothness, the fit between the candidate region boundary and the original region boundary is determined.
[0211] In some embodiments of the present application, the candidate region boundary and the original region boundary may be compared to determine the degree of fit between the candidate region boundary and the original region boundary, and then the smoothness of the candidate region boundary may be determined based on the angle between each two adjacent sampling points in the candidate region boundary and the angle between each two adjacent sampling points in the original region boundary. Based on the degree of fit and the smoothness, the degree of fit between the candidate region boundary and the original region boundary may be determined.
[0212] In some embodiments of the present application, comparing the candidate region boundary with the original region boundary to determine the degree of fit between the candidate region boundary and the original region boundary may specifically be:
[0213] Cut the candidate region boundary and the original region boundary into small squares according to the horizontal and vertical unit value of 1. If the small square that exists in the candidate region boundary also exists completely in the original region boundary, the small square is discarded and not processed. If the small square that exists in the candidate region boundary partially exists in the original region boundary, or the small square that exists in the original region boundary partially exists in the candidate region boundary, then add 1 to the numerator and denominator. If the small square that exists in the candidate region boundary does not exist in the original region boundary at all, then add 1 to the denominator. After counting all the small squares, calculate the ratio of the numerator and denominator to obtain the degree of fit between the candidate region boundary and the original region boundary.
[0214] In some embodiments of the present application, the degree of fit between the candidate region boundary and the original region boundary is determined based on the degree of fit between the candidate region boundary and the original region boundary and the smoothness of the candidate region boundary. Specifically, the ratio of the degree of fit to the smoothness may be determined as the degree of fit, as shown in the following formula (5):
[0215] c=f / s (5)
[0216] Among them, c is the fit between the candidate region boundary and the original region boundary, f is the fit between the candidate region boundary and the original region boundary, and s is the smoothness of the candidate region boundary.
[0217] In the embodiment of the present application, the degree of fit between the candidate region boundary and the original region boundary and the smoothness of the candidate region boundary can be accurately determined.
[0218] In some embodiments of the present application, in order to accurately determine the smoothness of the candidate region boundary, the determining the smoothness of the candidate region boundary according to the angle between each two adjacent sampling points in the candidate region boundary and the angle between each two adjacent sampling points in the original region boundary may include:
[0219] Calculate the average value of the angle of each sampling point in the boundary of the candidate region to obtain a first average value;
[0220] Calculate the average value of the angle of each sampling point in the original area boundary to obtain a second average value;
[0221] The smoothness of the boundary of the candidate region is determined according to the first average value and the second average value.
[0222] The first average value may be the calculated average value of the angle of each sampling point in the boundary of the candidate region.
[0223] The second average value may be an average value of the angles of each sampling point in the calculated original region boundary.
[0224] In some embodiments of the present application, an angle can be obtained for every three adjacent sampling points in the candidate region boundary, and then the candidate region boundary can obtain multiple angle values, and the multiple angle values are averaged to obtain a first average value. Correspondingly, an angle can be obtained for every three adjacent sampling points in the original region boundary, and then the original region boundary can obtain multiple angle values, and the multiple angle values are averaged to obtain a second average value.
[0225] Then, the smoothness of the boundary of the candidate region may be determined according to the first average value and the second average value. Specifically, the ratio of the first average value to the second average value may be determined as the smoothness of the boundary of the candidate region.
[0226] In an embodiment of the present application, a first average value is obtained by calculating the average value of the angle of each sampling point in the boundary of the candidate area, and a second average value is obtained by calculating the average value of the angle of each sampling point in the boundary of the original area. Then, based on the first average value and the second average value, the smoothness of the boundary of the candidate area can be accurately determined.
[0227] In some embodiments of the present application, when adjusting each threshold in the process of generating the candidate region boundary, the adjustment may be performed in the following manner:
[0228] Before step 110, the above method may further include:
[0229] The following process is performed for each threshold in the candidate region boundary generation process to obtain the target value of each threshold:
[0230] Setting the value of the j-th threshold in the candidate region boundary generation process to the first value, and setting the values of other thresholds to the second value;
[0231] The step of adjusting each threshold in the process of determining the candidate region boundary, regenerating the candidate region boundary, and obtaining the updated candidate region boundary may include:
[0232] Adjusting the first value to obtain an updated first value;
[0233] Regenerate the candidate region boundary based on the updated first value and the second value to obtain an updated candidate region boundary;
[0234] The updated candidate area boundary is updated as the candidate area boundary, and the process of determining the degree of fit between the candidate area boundary and the original area boundary is returned. When the degree of fit is less than or equal to a fourth threshold, each threshold in the candidate area boundary determination process is adjusted, and the candidate area boundary is regenerated to obtain an updated candidate area boundary, until the degree of fit between the updated candidate area boundary and the original area boundary is greater than the fourth threshold, and a target value of the j-th threshold is obtained.
[0235] The first value may be the value of the jth threshold set in the process of generating the candidate region boundary, where j is a positive integer and the initial value of j is 1.
[0236] The second value may be a value of another threshold set during the generation process of the candidate region boundary.
[0237] The other thresholds here are the thresholds except the jth threshold in each threshold in the candidate region boundary generation process. For example, taking a total of 10 thresholds involved in the candidate region boundary generation process, j=1 as an example, the other thresholds are the other 9 thresholds except the first threshold in the 10 thresholds.
[0238] It should be noted that the above-mentioned other thresholds being the second numerical value does not mean that the other thresholds are all set to the same numerical value. The second numerical value here is only to distinguish it from the numerical value set for the jth threshold, that is to say, for each of the other thresholds, it can have its corresponding second numerical value, and the second numerical value corresponding to each other threshold can be the same or different. The specific value depends on the value range of each other threshold and user needs, and is not limited in the embodiments of the present application.
[0239] In some embodiments of the present application, the value of the first threshold in the candidate area boundary generation process is first set to the first value, and then the values of other thresholds are set to the second value. If the value based on the first threshold is the first value and the values of other thresholds are the second thresholds, the obtained candidate area boundary and the original area boundary of the preset area have a fit degree less than or equal to a fourth threshold, then the first value is readjusted, and the values of other thresholds are kept unchanged to obtain an updated first value. Then, based on the updated first and second values, the candidate area boundary is regenerated to obtain an updated candidate area boundary, and the fit degree of the updated candidate area boundary with the original area boundary of the preset area is recalculated. If the fit degree of the updated candidate area boundary with the original area boundary of the preset area is still less than or equal to the fourth threshold, the first value is adjusted again, and the above operation is repeated until the fit degree of the updated candidate area boundary with the original area boundary is greater than the fourth threshold, and the value of the first threshold at this time is determined as the target value of the first threshold.
[0240] After determining the target value of the first threshold, keep the value of the first threshold as the target value, and then adjust the second threshold. The specific adjustment method is the same as the adjustment method of the first threshold mentioned above to obtain the target value of the second threshold. In this way, the target values of all thresholds involved in the candidate area boundary generation process are obtained. The candidate area boundary obtained based on the target value is consistent with the original area boundary of the preset area. The candidate area boundary obtained when all thresholds take the target value at this time can be determined as the target area boundary.
[0241] It should be noted that when all thresholds are adjusted, all thresholds can be adjusted in steps of 1 (or 0.01, 0.1). The specific adjustment method can be set according to user needs and is not limited in the embodiments of the present application.
[0242] It should be noted that, taking the adjustment of the first threshold as an example, when adjusting the value of the first threshold, when it is determined that the degree of fit between the candidate area boundary obtained based on the value of the first threshold and the original area boundary of the preset area is greater than the fourth threshold, the value of the first threshold at this time is determined as the target value of the first threshold. However, in actual operation, no matter how the adjustment is made, the degree of fit between the boundary of the candidate area and the original boundary of the preset area cannot be greater than the fourth threshold, and the degree of fit between the boundary of the candidate area and the original boundary of the preset area can only be infinitely close to the fourth threshold. For example, taking the fourth threshold of 90% as an example, when the first threshold is continuously adjusted, as the value of the first threshold is adjusted, the degree of fit between the boundary of the candidate area and the original boundary of the preset area is infinitely close to 90%, but will not be greater than 90%. At this time, when it is determined that the number of times the value of the first threshold is adjusted reaches a certain number, the adjustment of the first threshold is stopped, and the second threshold is continued to be adjusted. In this way, when no matter how the adjustment is made, the degree of fit between the boundary of the candidate area and the original boundary of the preset area cannot be greater than the fourth threshold, other thresholds can be continued to be adjusted to avoid delaying the adjustment of other thresholds due to the adjustment of this threshold, thereby ensuring the generation of the boundary of the target area.
[0243] It should be noted that the above-mentioned target area boundary generation process can be executed in a model. The input of the model is all thresholds in the target area boundary generation process, and the N first sampling points of the outline of the preset area collected by the XR device in the real space, and the first distance information from the XR device to the first sampling point when each first sampling point is collected, and the position information of the N first sampling points. The output of the model is the fit between the target area boundary and the original area boundary of the preset area, as well as the target area boundary.
[0244] In an embodiment of the present application, by continuously adjusting all thresholds in the process of generating candidate area boundaries, the generated candidate area boundaries are made more consistent with the original area boundaries of the preset area, thereby improving the consistency between the generated target area boundaries and the original area boundaries of the preset area.
[0245] In order to better understand the adjustment process of all thresholds in the process of generating candidate region boundaries, the following is a flow chart of adjusting all thresholds in the process of generating target region boundaries, such as Fig.13 As shown, the process of adjusting all thresholds in the process of generating candidate region boundaries includes steps 1 to 4.
[0246] Step 1: Select the jth threshold and configure the jth threshold as a first value.
[0247] In step 1, the initial value of j is 1.
[0248] Step 2: Randomly configure the values of other thresholds.
[0249] Step 3: determine whether the degree of fit between the generated candidate region boundary and the original region boundary of the preset region is greater than a fourth threshold. If so, execute step 4; if not, return to step 1 and adjust the value of the jth threshold.
[0250] Step 4: Get the target value of the j-th threshold.
[0251] The method for generating a region boundary in a virtual space provided in the embodiment of the present application may be executed by a device for generating a region boundary in a virtual space. In the embodiment of the present application, the device for generating a region boundary in a virtual space is taken as an example to illustrate the device for generating a region boundary in a virtual space provided in the embodiment of the present application.
[0252] Fig.14 FIG. 1 is a schematic diagram of a structure of a device for generating a region boundary in a virtual space according to an exemplary embodiment, wherein the device for generating a region boundary in a virtual space is applied to an XR device. Fig.14 As shown, the region boundary generating device 1400 in the virtual space may include:
[0253] A first acquisition module 1410 is used to acquire N first sampling points of the outline of a preset area collected by the XR device in the real space, and first distance information from the XR device to the first sampling point when each of the first sampling points is collected, and there is no obstacle in the preset area;
[0254] A first determining module 1420 is configured to perform a density processing on the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, so as to obtain M second sampling points, where M and N are both positive integers;
[0255] a second determining module 1430, configured to, when there are intersecting path segments in the first path formed by the M second sampling points and the intersecting path segments enclose a closed area, remove the second sampling points enclosing the closed area, and form a first closed graph with the remaining second sampling points among the M second sampling points, wherein the first path is a path formed by sequentially connecting the M second sampling points in a sampling order;
[0256] A third determining module 1440 is used to smooth the boundary of the first closed figure to obtain a second closed figure;
[0257] The fourth determination module 1450 is used to fit the first and last sampling points of the second closed figure to obtain a target area boundary, where the target area boundary is a boundary corresponding to the outline of the preset area in the virtual space.
[0258] In an embodiment of the present application, by performing density processing on the N first sampling points according to the number of N first sampling points of the outline of the preset area collected by the XR device in the real space and the first distance information from the XR device to the first sampling point when each first sampling point is collected, M second sampling points are obtained. When there are intersecting path segments in the first path composed of the M second sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points of the M second sampling points form a first closed figure, and then the boundary of the first closed figure is smoothed to obtain a second closed figure, and the first and last sampling points of the second closed figure are fitted to obtain the boundary of the target area. In this way, the boundary of the target area obtained by the solution of the embodiment of the present application is regular and closed, and the user can intuitively see the regular and closed boundary of the target area in the virtual environment, thereby avoiding the user from colliding with obstacles in the real environment when moving in the virtual environment.
[0259] In some embodiments of the present application, the first determining module 1420 may include:
[0260] a first determining unit, configured to calculate an average value of the first distance information corresponding to the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, to obtain average distance information;
[0261] A second determining unit is used to obtain distance information between every two adjacent first sampling points of N first sampling points to obtain N-1 second distance information;
[0262] A third determining unit, configured to determine, according to the average distance information and each piece of the second distance information, a density state of a line segment between two first sampling points corresponding to each piece of the second distance information;
[0263] The fourth determining unit is configured to perform density processing on the N first sampling points according to the density state of the line segment between each two adjacent first sampling points to obtain M second sampling points.
[0264] In some embodiments of the present application, the fourth determining unit is specifically configured to:
[0265] When it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a dense state, removing the first target sampling point or the second target sampling point;
[0266] When it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a sparse state, adding a sampling point between the first target sampling point and the second target sampling point;
[0267] The first target sampling point and the second target sampling point are any two adjacent first sampling points among the N first sampling points.
[0268] In some embodiments of the present application, the above-mentioned device may further include:
[0269] a sampling point removal module, configured to, when there are intersecting path segments in the first path formed by the M second sampling points and the intersecting path segments enclose a closed area, remove the second sampling points enclosing the closed area, and remove noise sampling points from the M second sampling points before the remaining second sampling points from the M second sampling points form a first closed figure, to obtain P third sampling points, where P is a positive integer;
[0270] The second determining module 1430 is specifically used for:
[0271] When there are intersecting path segments in the first path formed by the P third sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points among the M second sampling points form a first closed figure.
[0272] In some embodiments of the present application, the sampling point removal module includes:
[0273] a dividing unit, configured to divide the M second sampling points into at least one calculation window, each calculation window including at least one second sampling point;
[0274] a processing unit, configured to perform the following steps for each calculation window to remove noise sampling points within the calculation window: obtaining position information of each second sampling point in the calculation window, wherein the position information of each second sampling point includes an X-axis coordinate value, a Y-axis coordinate value, and a Z-axis coordinate value of the second sampling point; calculating an average value of the coordinate value of each coordinate axis of each second sampling point in the calculation window to obtain an average coordinate value of the X-axis, an average coordinate value of the Y-axis, and an average coordinate value of the Z-axis respectively; and, when it is determined that the coordinate value of the target axis of the third target sampling point is less than a preset coordinate value of the target axis, updating the coordinate value of the target axis of the third target sampling point based on the coordinate value of the target axis of the third target sampling point and the average coordinate value of the target axis to obtain an updated third target sampling point; wherein the third target sampling point is any second sampling point in the calculation window, and the target axis is the X-axis, the Y-axis, and / or the Z-axis.
[0275] In some embodiments of the present application, the processing unit is specifically used to:
[0276] Calculating an average coordinate value of the target axis and an average coordinate value of the target axis of the third target sampling point;
[0277] The average value is used as the updated coordinate value of the target axis of the third target sampling point.
[0278] In some embodiments of the present application, the third determination module 1440 is specifically used to:
[0279] The following steps are performed for every three adjacent sampling points of each sampling point of the first closed figure to obtain a second closed figure:
[0280] Acquire a fourth target sampling point, a fifth target sampling point, and a sixth target sampling point that are adjacent to each other, wherein the fourth target sampling point, the fifth target sampling point, and the sixth target sampling point are three adjacent sampling points among the sampling points of the first closed figure, the fourth target sampling point is located before the fifth target sampling point, the sixth target sampling point is located after the fifth target sampling point, and an angle between a line between the fourth target sampling point and the fifth target sampling point and a line between the fifth target sampling point and the sixth target sampling point is greater than a preset angle threshold;
[0281] Connecting the fourth target sampling point and the sixth target sampling point based on a Bezier curve to obtain a candidate feature point, wherein the candidate feature point is a feature point that smoothly connects the fourth target sampling point and the sixth target sampling point on the Bezier curve and has the smallest difference in position information with the fifth target sampling point;
[0282] Acquire a first direction vector between the fourth target sampling point and the sixth target sampling point, and a second direction vector between the fifth target sampling point and the candidate feature point;
[0283] Determine, based on the first direction vector and the second direction vector, an angle value of an angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point;
[0284] Based on the angle value, a candidate target feature point is determined.
[0285] In some embodiments of the present application, the first direction vector and the second direction vector each include an X-axis direction vector component, a Y-axis direction vector component, and a Z-axis direction vector component;
[0286] The third determining module 1440 is specifically used for:
[0287] Calculate the product of the X-axis direction vector component of the first direction vector and the X-axis direction vector component of the second direction vector to obtain the X-axis direction target vector component;
[0288] Calculate the product of the Y-axis direction vector component of the first direction vector and the Y-axis direction vector component of the second direction vector to obtain the Y-axis direction target vector component;
[0289] Calculate the product of the Z-axis direction vector component of the first direction vector and the Z-axis direction vector component of the second direction vector to obtain the Z-axis direction target vector component;
[0290] The sum of the X-axis direction target component vector, the Y-axis direction target component vector and the Z-axis direction target component vector is determined as the angle value of the angle formed by the candidate feature point, the fourth target sampling point and the sixth target sampling point.
[0291] The device for generating the region boundary in the virtual space in the embodiment of the present application may be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device may be a terminal, or may be other devices other than a terminal. Exemplarily, the electronic device may be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and may also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0292] The device for generating a region boundary in a virtual space in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0293] The device for generating area boundaries in a virtual space provided in the embodiment of the present application can achieve Figure 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0294] Alternatively, if Fig.15 As shown, an embodiment of the present application also provides an electronic device 1500, including a processor 1501 and a memory 1502, and the memory 1502 stores a program or instruction that can be executed on the processor 1501. When the program or instruction is executed by the processor 1501, the various steps of the embodiment of the method for generating area boundaries in the above-mentioned virtual space are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0295] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0296] Fig.16 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0297] The electronic device 1600 includes but is not limited to: a radio frequency unit 1601, a network module 1602, an audio output unit 1603, an input unit 1604, a sensor 1605, a display unit 1606, a user input unit 1607, an interface unit 1608, a memory 1609, and a processor 1610 and other components.
[0298] Those skilled in the art will appreciate that the electronic device 1600 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1610 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.16 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0299] The processor 1610 is used to obtain N first sampling points of the outline of the preset area collected by the XR device in the real space, and the first distance information from the XR device to the first sampling point when each of the first sampling points is collected, and there is no obstacle in the preset area; according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, the N first sampling points are subjected to density processing to obtain M second sampling points, where M and N are both positive integers; when there are intersecting path segments in the first path composed of the M second sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points of the M second sampling points are formed into a first closed figure, and the first path is a path formed by connecting the M second sampling points in sequence according to the sampling order; the boundary of the first closed figure is smoothed to obtain a second closed figure; the first and last sampling points of the second closed figure are fitted to obtain a target area boundary, and the target area boundary is a boundary corresponding to the outline of the preset area in the virtual space.
[0300] In this way, by performing density processing on the N first sampling points according to the number of N first sampling points of the outline of the preset area collected by the XR device in the real space, and the first distance information from the XR device to the first sampling point when each first sampling point is collected, M second sampling points are obtained. When there are intersecting path segments in the first path composed of the M second sampling points, and the intersecting path segments form a closed area, the second sampling points that enclose the closed area are removed, and the remaining second sampling points of the M second sampling points form a first closed figure, and then the boundary of the first closed figure is smoothed to obtain a second closed figure, and the first and last sampling points of the second closed figure are fitted to obtain the boundary of the target area. In this way, the boundary of the target area obtained by the solution of the embodiment of the present application is regular and closed, and the user can intuitively see the regular and closed boundary of the target area in the virtual environment, thereby avoiding the user from colliding with obstacles in the real environment when moving in the virtual environment.
[0301] Optionally, the processor 1610 is further configured to calculate an average value of the first distance information corresponding to the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, to obtain average distance information; obtain distance information between every two adjacent first sampling points of the N first sampling points, to obtain N second distance information; determine a density state of a line segment between two first sampling points corresponding to each second distance information according to the average distance information and each of the second distance information; and perform density processing on the N first sampling points according to the density state of the line segment between every two adjacent first sampling points, to obtain M second sampling points.
[0302] In this way, by performing density processing on the N first sampling points according to the density of the line segment between each two adjacent first sampling points, the density between the first sampling points can be made consistent, thereby ensuring that the contour boundary of the drawn preset area is more regular.
[0303] Optionally, the processor 1610 is further configured to, when it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a dense state, remove the first target sampling point or the second target sampling point; when it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a sparse state, add a sampling point between the first target sampling point and the second target sampling point; wherein the first target sampling point and the second target sampling point are any two adjacent first sampling points among the N first sampling points.
[0304] In this way, when it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a dense state, the first target sampling point or the second target sampling point is removed, and when it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a sparse state, a sampling point is added between the first target sampling point and the second target sampling point. In this way, the line segment between the first target sampling point and the second target sampling point can be accurately processed to obtain regular sampling points, and then a regular contour boundary can be obtained.
[0305] Optionally, the processor 1610 is further configured to remove noise sampling points from the M second sampling points to obtain P third sampling points, where P is a positive integer; when there are intersecting path segments in the first path formed by the P third sampling points, and the intersecting path segments form a closed area, the second sampling points that form the closed area are removed, and the remaining second sampling points from the M second sampling points form a first closed figure.
[0306] In this way, by removing the noise sampling points from the M second sampling points, P third sampling points are obtained, and the intersection area can be processed based on the P third sampling points, thereby obtaining a more regular first closed figure and a more regular target area boundary.
[0307] Optionally, the processor 1610 is further configured to divide the M second sampling points into at least one calculation window, each calculation window including at least one second sampling point; perform the following steps for each calculation window to remove noise sampling points in the calculation window: obtain position information of each second sampling point in the calculation window, wherein the position information of each second sampling point includes a coordinate value of an X axis, a coordinate value of a Y axis, and a coordinate value of a Z axis of the second sampling point; calculate an average value of the coordinate value of each coordinate axis of each second sampling point in the calculation window, and obtain an average coordinate value of the X axis, an average coordinate value of the Y axis, and an average coordinate value of the Z axis respectively; when it is determined that the coordinate value of the target axis of the third target sampling point is less than a preset coordinate value of the target axis, based on the coordinate value of the target axis of the third target sampling point and the average coordinate value of the target axis, update the coordinate value of the target axis of the third target sampling point to obtain an updated third target sampling point; wherein the third target sampling point is any second sampling point in the calculation window, and the target axis is the X axis, the Y axis, and / or the Z axis.
[0308] In this way, by dividing the M second sampling points into at least one calculation window, the second sampling points in each calculation window can be calculated in turn, and the noise sampling points in the calculation window can be removed. In this way, the amount of calculation when removing the noise sampling points each time will not be too large, thereby improving the efficiency of removing the noise sampling points. In addition, for each calculation window, the noise sampling points are removed according to the position information of the second sampling points in the calculation window, so that the sampling points with large position information deviations can be accurately determined and removed, thereby improving the accuracy of removing the noise sampling points.
[0309] Optionally, the processor 1610 is further configured to calculate an average coordinate value of the target axis and an average coordinate value of the target axis of the third target sampling point; and use the average value as the updated coordinate value of the target axis of the third target sampling point.
[0310] In this way, the average coordinate value of the target axis and the average coordinate value of the target axis of the third target sampling point are used as the updated coordinate value of the target axis of the third target sampling point, so that the updated coordinate value of the target axis of the third target sampling point can be accurately determined.
[0311] Optionally, the processor 1610 is further configured to perform the following steps for every three adjacent sampling points among the sampling points of the first closed figure to obtain a second closed figure: acquiring a fourth target sampling point, a fifth target sampling point, and a sixth target sampling point that are adjacent to each other, wherein the fourth target sampling point, the fifth target sampling point, and the sixth target sampling point are three adjacent sampling points among the sampling points of the first closed figure, the fourth target sampling point is located before the fifth target sampling point, the sixth target sampling point is located after the fifth target sampling point, and an angle between a line between the fourth target sampling point and the fifth target sampling point and a line between the fifth target sampling point and the sixth target sampling point is greater than a predetermined angle. Set an angle threshold; connect the fourth target sampling point and the sixth target sampling point based on a Bezier curve to obtain a candidate feature point, where the candidate feature point is a feature point that smoothly connects the fourth target sampling point and the sixth target sampling point on the Bezier curve and has the smallest difference in position information with the fifth target sampling point; obtain a first direction vector between the fourth target sampling point and the sixth target sampling point, and a second direction vector between the fifth target sampling point and the candidate feature point; determine an angle value of an angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point based on the first direction vector and the second direction vector; and determine a target candidate feature point based on the angle value.
[0312] In this way, by performing smoothing processing on every three adjacent sampling points in the first closed figure, a smooth target area boundary can be obtained.
[0313] Optionally, the first direction vector and the second direction vector both include an X-axis component vector, a Y-axis component vector and a Z-axis component vector; the processor 1610 is further used to calculate the product of the X-axis component vector of the first direction vector and the X-axis component vector of the second direction vector to obtain an X-axis target component vector; calculate the product of the Y-axis component vector of the first direction vector and the Y-axis component vector of the second direction vector to obtain a Y-axis target component vector; calculate the product of the Z-axis component vector of the first direction vector and the Z-axis component vector of the second direction vector to obtain a Z-axis target component vector; and determine the sum of the X-axis target component vector, the Y-axis target component vector and the Z-axis target component vector as the angle value of the angle formed by the candidate feature point, the fourth target sampling point and the sixth target sampling point.
[0314] In this way, by respectively calculating the product of the X-axis direction component of the first direction vector and the X-axis direction component of the second direction vector, the product of the Y-axis direction component of the first direction vector and the Y-axis direction component of the second direction vector, and the product of the Z-axis direction component of the first direction vector and the Z-axis direction component of the second direction vector, and then determining the sum of the products as the angle value of the angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point, the angle value of the angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point can be accurately determined.
[0315] It should be understood that in the embodiment of the present application, the input unit 1604 may include a graphics processor (Graphics Processing Unit, GPU) 16041 and a microphone 16042, and the graphics processor 16041 processes the image data of the static picture or video obtained by the image capture device (such as a color camera) in the video capture mode or the image capture mode. The display unit 1606 may include a display panel 16061, and the display panel 16061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1607 includes a touch panel 16071 and at least one of other input devices 16072. The touch panel 16071 is also called a touch screen. The touch panel 16071 may include two parts: a touch detection device and a touch controller. Other input devices 16072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0316] The memory 1609 can be used to store software programs and various data. The memory 1609 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1609 may include a volatile memory or a non-volatile memory, or the memory 1609 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1609 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0317] The processor 1610 may include one or more processing units; optionally, the processor 1610 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1610.
[0318] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned embodiment of the method for generating area boundaries in a virtual space is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0319] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0320] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned embodiment of the method for generating area boundaries in the virtual space, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0321] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0322] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned embodiment of the method for generating area boundaries in a virtual space, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0323] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0324] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0325] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A method for generating a region boundary in a virtual space, characterized in that: The method is applied to an extended reality XR device, and the method comprises: Acquire N first sampling points of the outline of a preset area collected by the XR device in the real space, and first distance information from the XR device to the first sampling point when each first sampling point is collected, wherein there is no obstacle in the preset area; According to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, the N first sampling points are subjected to density processing to obtain M second sampling points, where M and N are both positive integers; In a case where there are intersecting path segments in the first path formed by the M second sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points of the M second sampling points form a first closed figure, and the first path is a path formed by sequentially connecting the M second sampling points in a sampling order; Smoothing the boundary of the first closed figure to obtain a second closed figure; The first and last sampling points of the second closed figure are fitted to obtain a target area boundary, where the target area boundary is a boundary corresponding to the outline of the preset area in the virtual space.
2. The method according to claim 1, characterized in that The step of performing density processing on the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points to obtain M second sampling points includes: Calculate, according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, an average value of the first distance information corresponding to the N first sampling points to obtain average distance information; Acquire distance information between every two adjacent first sampling points of N first sampling points to obtain N second distance information; Determine, according to the average distance information and each piece of the second distance information, a density state of a line segment between two first sampling points corresponding to each piece of the second distance information; According to the density state of the line segment between every two adjacent first sampling points, the N first sampling points are subjected to density processing to obtain M second sampling points.
3. The method according to claim 2, characterized in that The step of performing density processing on the N first sampling points according to the density state of the line segment between each two adjacent first sampling points to obtain M second sampling points includes: When it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a dense state, removing the first target sampling point or the second target sampling point; When it is determined that the density state of the line segment between the first target sampling point and the second target sampling point is a sparse state, adding a sampling point between the first target sampling point and the second target sampling point; The first target sampling point and the second target sampling point are any two adjacent first sampling points among the N first sampling points.
4. The method according to claim 1, characterized in that: In the case where there are intersecting path segments in the first path formed by the M second sampling points, and the intersecting path segments enclose a closed area, before removing the second sampling points enclosing the closed area and forming a first closed figure with the remaining second sampling points in the M second sampling points, the method further includes: Remove the noise sampling points from the M second sampling points to obtain P third sampling points, where P is a positive integer; In the case where there are intersecting path segments in the first path formed by the M second sampling points, and the intersecting path segments enclose a closed area, removing the second sampling points enclosing the closed area, and forming a first closed figure with the remaining second sampling points in the M second sampling points, including: When there are intersecting path segments in the first path formed by the P third sampling points, and the intersecting path segments enclose a closed area, the second sampling points enclosing the closed area are removed, and the remaining second sampling points among the M second sampling points form a first closed figure.
5. The method according to claim 4, characterized in that The removing noise sampling points from the M second sampling points to obtain P third sampling points includes: Divide the M second sampling points into at least one calculation window, each calculation window including at least one second sampling point; The following steps are performed for each calculation window to remove the noise sampling points in the calculation window: Acquire the position information of each second sampling point in the calculation window, wherein the position information of each second sampling point includes the coordinate value of the second sampling point on the X axis, the coordinate value of the Y axis, and the coordinate value of the Z axis; Calculate the average value of the coordinate value of each coordinate axis of each second sampling point in the calculation window to obtain the average coordinate value of the X axis, the average coordinate value of the Y axis and the average coordinate value of the Z axis respectively; When it is determined that the coordinate value of the target axis of the third target sampling point is less than the preset coordinate value of the target axis, based on the coordinate value of the target axis of the third target sampling point and the average coordinate value of the target axis, the coordinate value of the target axis of the third target sampling point is updated to obtain an updated third target sampling point; The third target sampling point is any second sampling point in the calculation window, and the target axis is the X axis, the Y axis and / or the Z axis.
6. The method according to claim 5, characterized in that The updating of the coordinate value of the target axis of the third target sampling point based on the coordinate value of the target axis of the third target sampling point and the average coordinate value of the target axis to obtain an updated third target sampling point includes: Calculating an average coordinate value of the target axis and an average coordinate value of the target axis of the third target sampling point; The average value is used as the updated coordinate value of the target axis of the third target sampling point.
7. The method according to claim 1, characterized in that The step of smoothing the first closed figure to obtain a second closed figure includes: The following steps are performed for every three adjacent sampling points of each sampling point of the first closed figure to obtain a second closed figure: Acquire a fourth target sampling point, a fifth target sampling point, and a sixth target sampling point that are adjacent to each other, wherein the fourth target sampling point, the fifth target sampling point, and the sixth target sampling point are three adjacent sampling points among the sampling points of the first closed figure, the fourth target sampling point is located before the fifth target sampling point, the sixth target sampling point is located after the fifth target sampling point, and an angle between a line between the fourth target sampling point and the fifth target sampling point and a line between the fifth target sampling point and the sixth target sampling point is greater than a preset angle threshold; Connecting the fourth target sampling point and the sixth target sampling point based on a Bezier curve to obtain a candidate feature point, wherein the candidate feature point is a feature point that smoothly connects the fourth target sampling point and the sixth target sampling point on the Bezier curve and has the smallest difference in position information with the fifth target sampling point; Acquire a first direction vector between the fourth target sampling point and the sixth target sampling point, and a second direction vector between the fifth target sampling point and the candidate feature point; Determine, based on the first direction vector and the second direction vector, an angle value of an angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point; Based on the angle value, a candidate target feature point is determined.
8. The method according to claim 7, characterized in that The first direction vector and the second direction vector each include an X-axis direction vector component, a Y-axis direction vector component and a Z-axis direction vector component; The determining, based on the first direction vector and the second direction vector, an angle value of an angle formed by the candidate feature point, the fourth target sampling point, and the sixth target sampling point comprises: Calculate the product of the X-axis direction vector component of the first direction vector and the X-axis direction vector component of the second direction vector to obtain the X-axis direction target vector component; Calculate the product of the Y-axis direction vector component of the first direction vector and the Y-axis direction vector component of the second direction vector to obtain the Y-axis direction target vector component; Calculate the product of the Z-axis direction vector component of the first direction vector and the Z-axis direction vector component of the second direction vector to obtain the Z-axis direction target vector component; The sum of the X-axis direction target component vector, the Y-axis direction target component vector and the Z-axis direction target component vector is determined as the angle value of the angle formed by the candidate feature point, the fourth target sampling point and the sixth target sampling point.
9. A device for generating a region boundary in a virtual space, characterized in that: The device is applied to an extended reality XR device, and the device includes: A first acquisition module, configured to acquire N first sampling points of the outline of a preset area collected by the XR device in the real space, and first distance information from the XR device to the first sampling point when each of the first sampling points is collected, wherein there is no obstacle in the preset area; A first determining module, configured to perform density processing on the N first sampling points according to the number of the N first sampling points and the first distance information corresponding to each of the first sampling points, to obtain M second sampling points, where M and N are both positive integers; a second determining module, configured to, when there are intersecting path segments in the first path formed by the M second sampling points and the intersecting path segments enclose a closed area, remove the second sampling points enclosing the closed area, and form a first closed graph with the remaining second sampling points among the M second sampling points, wherein the first path is a path formed by sequentially connecting the M second sampling points in a sampling order; A third determining module, configured to smooth the boundary of the first closed figure to obtain a second closed figure; The fourth determination module is used to fit the first and last sampling points of the second closed figure to obtain a target area boundary, where the target area boundary is a boundary corresponding to the outline of the preset area in the virtual space.
10. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method for generating a region boundary in a virtual space as described in any one of claims 1 to 8 are implemented.
11. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the method for generating a region boundary in a virtual space as described in any one of claims 1-8 are implemented.
Citation Information
Patent Citations
Three-dimensional model adjustment method and device, storage medium and equipment
CN114283266A
Virtual reality VR-based interface display method and device, electronic equipment and medium
CN116755545A
Virtual reality VR-based interface display method and device, electronic equipment and storage medium
CN118115702A
Mapping physical locations to fit virtualized ar and VR environments
US20220383594A1