Space distance measurement method and device based on mixed reality

By initializing depth sensors and hand rays in mixed reality measurement technology, monitoring user gestures in real time and processing environmental point cloud data, the problem of insufficient measurement accuracy in dynamic and complex environments in the prior art is solved, and high-precision spatial ranging and virtual information positioning rendering are achieved.

CN119533396BActive Publication Date: 2025-05-16UNIV OF JINAN
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510080312.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-05-16
Estimated Expiration
2045-01-20

AI Technical Summary

Technical Problem

Existing mixed reality measurement technologies are difficult to achieve real-time high-precision measurement in dynamic and complex environments, especially when processing multi-point cloud data and occlusions, which are low in accuracy and cannot meet the needs of high-precision applications.

Method used

By initializing the depth sensor, camera module and hand ray of the mixed reality device, the user's gesture operation is monitored in real time, the depth sensor is used to obtain environmental point cloud data, calculate the normal angle difference value to filter edge points, select the measurement points through the hand ray and correct it, and finally real-time positioning and rendering of virtual information is completed in the mixed reality headset.

Benefits of technology

It significantly improves the measurement accuracy and response speed, and can achieve high-precision geometric data measurement in complex dynamic environments. It is suitable for scenarios such as building measurement, interior design, industrial manufacturing, etc., especially for high-precision acceptance requirements in power transmission and transformation projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119533396B_ABST
    Figure CN119533396B_ABST
Patent Text Reader

Abstract

The present invention discloses a spatial distance measurement method and device based on mixed reality, which belongs to the field of mixed reality and image processing technology. The method includes the following steps: initializing the depth sensor, camera module and hand ray of the mixed reality device; using the global event listener to monitor the user's gesture operation in real time; using the depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment; calculating the normal angle difference of adjacent triangles in the point cloud, and screening out edge points with significant angle changes; selecting the measurement start point and the measurement end point through the hand ray, correcting the measurement point coordinates, and finding the final positions of the measurement start point and the end point; the mixed reality head display completes the virtual information positioning rendering in numerical form according to the final position of the measurement point coordinates. The present invention realizes the precise positioning of the measurement point and the efficient processing of spatial data, and significantly improves the measurement accuracy and response speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a space distance measurement method and device based on mixed reality, belonging to the technical field of mixed reality and image processing. Background Art

[0002] Mixed reality (MR) measurement is an advanced method that combines augmented reality and computer graphics technology for high-precision measurement of spatial geometric data. It is suitable for scenarios that require high-precision on-site acceptance, such as power transmission and transformation projects. In the existing project acceptance process, traditional measurement technology usually relies on laser ranging or manually operated measurement tools, which cannot achieve real-time and accurate collection of on-site data, especially in complex geometric structures and dynamically changing environments. Its measurement accuracy and response speed are difficult to meet high-standard engineering requirements.

[0003] These existing measurement methods often require workers to operate the measurement equipment at close range, and they show significant deficiencies when facing diverse and complex scenes, especially in terms of accuracy and real-time performance, which limits their scope of application. At present, the existing MR measurement technology obtains the posture information of the environment through the equipment's camera, inertial sensor and other hardware, and combines computer graphics methods such as ray detection and collision detection to model the target object in real time, thereby improving the spatial perception ability of the MR equipment and the accuracy of the measurement point selection.

[0004] However, in dynamic and complex environments, existing MR measurement equipment still has shortcomings in real-time data update and accuracy maintenance. For example, existing equipment is difficult to synchronously process the collection and position update of multi-point cloud data, and has low accuracy when dealing with obstructions, resulting in unstable measurement results and unable to fully meet the high-precision measurement requirements of applications such as power transmission and transformation projects. Summary of the invention

[0005] In order to solve the above problems, the present invention proposes a spatial ranging method and device based on mixed reality, which can improve the ranging accuracy and precision in the mixed reality space.

[0006] The technical solution adopted by the present invention to solve the technical problem is:

[0007] In a first aspect, an embodiment of the present invention provides a spatial ranging method based on mixed reality, comprising the following steps:

[0008] Step S1, initializing the depth sensor, camera module and hand ray of the mixed reality device;

[0009] Step S2, using a global event listener to monitor the user's gesture operation in real time;

[0010] Step S3, using a depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment;

[0011] Step S4, calculating the normal angle difference between adjacent triangles in the point cloud, and screening out edge points with significant angle changes;

[0012] Step S5, selecting the measurement start point and the measurement end point through the hand ray, correcting the coordinates of the measurement points, and obtaining the final positions of the measurement start point and the measurement end point;

[0013] Step S6: The mixed reality head display completes the positioning rendering of the virtual information in numerical form according to the final position of the measurement point coordinates.

[0014] As a possible implementation of this embodiment, the step S1, initializing the depth sensor, camera module, and hand ray of the mixed reality device, includes:

[0015] Calibrate the depth sensor, collect the depth information of each point in the environment in real time, and convert the data into three-dimensional coordinates ;

[0016] Initialize the camera's shooting parameters;

[0017] Detect user gestures and generate hand rays.

[0018] The hand ray is generated by the far pointer of the user's hand and can point to and select any point in the virtual space.

[0019] As a possible implementation of this embodiment, the step S2, using a global event listener to monitor the user's gesture operation in real time, includes:

[0020] Start a global event listener to monitor the user's gesture operations in real time and capture the user's interactive actions. The gesture operations include hand cursor pointing and selection.

[0021] Use the direction and position of the hand ray to detect the user's click event and capture the user's click gesture operation;

[0022] When a click or touch event is captured, the event data is recorded.

[0023] As a possible implementation of this embodiment, step S3, using a depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment, includes:

[0024] Activate the environmental scanning capability of the depth sensor to identify and capture three-dimensional spatial information in the environment;

[0025] Adjusting the parameters of the depth sensor to optimize the accuracy and acquisition range of the point cloud data, wherein the parameter adjustment includes setting the scanning range and sampling accuracy;

[0026] Start real-time scanning of the environment to collect 3D point cloud data, including the 3D coordinate information of each point in the 3D point cloud data. The basic 3D model that makes up the environment.

[0027] As a possible implementation of this embodiment, the step S4, calculating the normal angle difference between adjacent triangles in the point cloud and screening out edge points with significant angle changes, includes:

[0028] Pre-generate the real edge point data of a standard cube, set the cube side length to half the unit length (0.5), and generate the 8 vertex coordinates of the cube;

[0029] Define 12 edges, and each edge consists of a vertex pair Indicates that the edge set of a cube is constructed, and each edge in the edge set of the cube corresponds to the bottom, top and side of the cube;

[0030] For each edge, calculate the midpoint position as the edge point, and store the midpoint coordinates in the true edge point list trueEdgePoints;

[0031] After the real edge points are generated, debug information is output to show the number of edge points generated;

[0032] When the spatial grid data changes (such as being added or updated), the latest spatial grid data is processed to filter out edge points with significant angle changes in the latest spatial grid data.

[0033] As a possible implementation of this embodiment, when the spatial grid data changes (such as being added or updated), the latest spatial grid data is processed to screen out edge points with significant angle changes in the latest spatial grid data, including:

[0034] Get the 3D data of the target mesh object. If the isReadable property of the target mesh is true, the edge detection process is allowed to continue; otherwise, a warning is given and a prompt is given to enable the read / write permission of the mesh.

[0035] Get the vertex, normal, and triangle data of the target mesh and create a vertexToTriangles dictionary mapping each vertex to its associated triangle list;

[0036] Traverse the triangle index array triangles, map each vertex index to the corresponding triangle number and store them in the vertexToTriangles dictionary;

[0037] Traverse all vertices in turn, compare the normals of adjacent triangles of each vertex, and for a certain vertex i , all its adjacent triangles are in the adjacentTriangles list, and through double loops, the normal angles of the two adjacent triangles on the vertex are calculated in turn; the angle between the two normal vectors normal1 and normal2 is calculated, and if the angle exceeds the preset angleThreshold value, the vertex is marked as an edge point;

[0038] If the vertex meets the edge condition, that is, the normal angle between a pair of adjacent triangles exceeds the angleThreshold value, the vertex is recorded in the edge point list edgePoints, and the number of detected edge points is output.

[0039] As a possible implementation of this embodiment, step S5, selecting a measurement start point and a measurement end point by hand rays, correcting the coordinates of the measurement points, and obtaining the final positions of the measurement start point and the measurement end point, includes:

[0040] The hand ray performs collision detection on the surface of the object after scene modeling. After the hand ray collides with the object surface, the system records the collision point as the initial measurement point;

[0041] By checking the edge point positions around the initial measurement point, if the distance between the collision point and the nearby edge point is within the set error threshold, the measurement point is adjusted to the nearest edge point position;

[0042] Generate horizontal and vertical auxiliary lines based on the coordinates of the initial measurement points;

[0043] Under the guidance of the auxiliary lines, select the end point, fine-tune the position through edge point correction, and finally determine the start and end point coordinates of the measurement.

[0044] As a possible implementation of this embodiment, generating horizontal and vertical auxiliary lines according to the coordinates of the initial measurement points includes:

[0045] When the user clicks, the coordinates of the measurement point are captured through the hand ray;

[0046] Count the number of valid measurement points. If only one valid starting point is detected, the system will continue to generate auxiliary lines. If there are no valid measurement points, all generated auxiliary lines will be cleared.

[0047] Get the collision point clickPosition where the user clicks through ray detection, and generate the plane plane with the normal of the point hitInfo.normal;

[0048] Centered on the click point clickPosition, based on the plane normal plane.normal, calculate the cross product of the plane normal and Vector3.up to obtain the direction of the horizontal line horizontalDirection, and generate dotted lines in the positive and negative directions to obtain horizontal auxiliary lines;

[0049] The vertical direction verticalDirection is calculated through the plane normal and the horizontal direction, and dotted lines are generated in the positive and negative directions respectively to obtain vertical auxiliary lines.

[0050] As a possible implementation of this embodiment, the position fine-tuning by edge point correction includes:

[0051] Get all edge point data stored in the edge point list edgePoints;

[0052] If the edge point list edgePoints is empty, an error message is recorded and the correction operation is terminated;

[0053] Set the initial distance threshold minDistance (for example, 0.1 meters) to filter the edge points closest to the user-selected point closestPoint, and record the selected point closestPoint and the initial distance threshold;

[0054] Traverse all edge points in the edge point list edgePoints, and perform the following steps for each edge point point: Calculate the distance distance between the user-selected point closestPoint and the current edge point point. If the distance distance is less than the set minDistance threshold, update minDistance and set closestPoint to the current edge point point, indicating that a closer edge point is found;

[0055] After traversing all edge points, update closestPoint to the position of the nearest edge point and record it as the final selected edge point selectedEdgePoint;

[0056] The final selected edge point selectedEdgePoint will be used as the corrected measurement point.

[0057] As a possible implementation of this embodiment, in step S6, the mixed reality head display completes the positioning rendering of virtual information in numerical form according to the final position of the measurement point coordinates, including:

[0058] Set the positions of the start point StartPos and the end point EndPos, activate the dotted line DottedLine, and generate a clear measurement line in the mixed reality environment;

[0059] Calculate the distance Length between the starting point StartPos and the end point EndPos;

[0060] Format the distance Length as meters ("m") or centimeters ("cm") and display it at the midpoint of the measurement line segment;

[0061] Display the measured length in the virtual text box LengthText and adjust its position and direction.

[0062] In a second aspect, an embodiment of the present invention provides a spatial distance measurement device based on mixed reality, including:

[0063] An initialization module, used to initialize the depth sensor, camera module, and hand ray of the mixed reality device;

[0064] The operation monitoring module is used to monitor the user's gesture operation in real time using the global event listener;

[0065] The environment scanning module is used to use the depth sensor to scan the surrounding environment in real time and obtain point cloud data in the environment;

[0066] The edge point screening module is used to calculate the normal angle difference between adjacent triangles in the point cloud and screen out edge points with significant angle changes;

[0067] The position measurement module is used to select the measurement starting point and the measurement end point through the hand ray, correct the coordinates of the measurement point, and calculate the final position of the measurement starting point and the measurement end point;

[0068] The positioning rendering module is used for the mixed reality head display to complete the positioning rendering of virtual information in numerical form according to the final position of the measurement point coordinates.

[0069] The beneficial effects of the technical solution of the embodiment of the present invention are as follows:

[0070] A spatial distance measurement method based on mixed reality of the technical solution of the embodiment of the present invention comprises the following steps: step S1, initializing the depth sensor, camera module and hand ray of the mixed reality device; step S2, using the global event listener to monitor the user's gesture operation in real time; step S3, using the depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment; step S4, calculating the normal angle difference of adjacent triangles in the point cloud, and screening out edge points with significant angle changes; step S5, selecting the measurement start point and the measurement end point through the hand ray, correcting the measurement point coordinates, and finding the final position of the measurement start point and the end point; step S6, the mixed reality head display completes the virtual information positioning rendering in numerical form according to the final position of the measurement point coordinates. The present invention realizes the precise positioning of the measurement point and the efficient processing of the spatial data by acquiring the device posture information in real time and dynamically updating the environmental data; through the optimization technologies such as multi-source information synchronization, ray detection and collision detection, a three-dimensional model is constructed in the MR environment, and the measurement point position is dynamically adjusted using the point cloud data collected in real time, which significantly improves the measurement accuracy and response speed. In addition, the present invention has excellent spatial computing capabilities, enabling MR devices to complete high-precision geometric data measurement in complex and dynamic environments. It can be applied to scenarios such as architectural measurement, interior design, industrial manufacturing, virtual reality interactive design, and game development, especially the high-precision acceptance requirements for key geometric parameters in power transmission and transformation projects, and other three-dimensional modeling and real-time scene interaction applications that require precise ranging.

[0071] The present invention ensures that users can only select measurement points on the scanned effective scene surface through precise collision detection of hand rays and space perception grids, effectively avoiding the problem of mis-touch or invalid point selection in traditional methods, and solving the technical problems of insufficient accuracy and inconvenient operation of traditional distance measurement technology in dynamic environments. The present invention uses the edge point correction function to automatically adjust the measurement point to the actual edge position of the object, significantly improving the measurement precision and accuracy, and meeting the needs of complex geometric structures.

[0072] The present invention realizes real-time positioning and rendering of virtual information, ensuring that the measurement results can be clearly and intuitively displayed in the mixed reality head display in numerical form. Based on the measurement starting point selected by the user, horizontal and vertical auxiliary lines are automatically generated to help the user accurately select the end point in three-dimensional space, thereby maintaining the consistency of the measurement direction and reducing the angle error. The present invention enhances the user interaction experience, allowing users to obtain a more intuitive and controllable measurement process in a mixed reality environment.

[0073] The present invention has the ability to update data in real time and can dynamically feedback measurement results, ensuring that the measurement data remains highly accurate during user operations and environmental changes. Compared with the existing technology, this proposal has achieved significant improvements in measurement accuracy, real-time response capability, and interactive convenience, providing users with an innovative and reliable solution for high-precision measurement in complex three-dimensional scenes, and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 is a flow chart of a spatial ranging method based on mixed reality according to an exemplary embodiment;

[0075] Figure 2 is a structural schematic diagram of a space distance measurement device based on mixed reality according to an exemplary embodiment;

[0076] Figure 3 It is a specific implementation flow chart of the present invention for performing spatial ranging based on mixed reality. DETAILED DESCRIPTION

[0077] In order to more clearly illustrate the technical features of the solution of the present invention, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings.

[0078] like Figure 1 As shown, a spatial ranging method based on mixed reality provided by an embodiment of the present invention includes the following steps:

[0079] Step S1, initializing the depth sensor, camera module and hand ray of the mixed reality device;

[0080] Step S2, using a global event listener to monitor the user's gesture operation in real time;

[0081] Step S3, using a depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment;

[0082] Step S4, calculating the normal angle difference between adjacent triangles in the point cloud, and screening out edge points with significant angle changes;

[0083] Step S5, selecting the measurement start point and the measurement end point through the hand ray, correcting the coordinates of the measurement points, and obtaining the final positions of the measurement start point and the measurement end point;

[0084] Step S6: The mixed reality head display completes the positioning rendering of the virtual information in numerical form according to the final position of the measurement point coordinates.

[0085] As a possible implementation of this embodiment, the step S1, initializing the depth sensor, camera module, and hand ray of the mixed reality device, includes:

[0086] Calibrate the depth sensor, collect the depth information of each point in the environment in real time, and convert the data into three-dimensional coordinates ;

[0087] Initialize the camera's shooting parameters;

[0088] Detect user gestures and generate hand rays.

[0089] The hand ray is generated by the far pointer of the user's hand and can point to and select any point in the virtual space.

[0090] As a possible implementation of this embodiment, the step S2, using a global event listener to monitor the user's gesture operation in real time, includes:

[0091] Start a global event listener to monitor the user's gesture operations in real time and capture the user's interactive actions. The gesture operations include hand cursor pointing and selection.

[0092] Use the direction and position of the hand ray to detect the user's click event and capture the user's click gesture operation;

[0093] When a click or touch event is captured, the event data is recorded.

[0094] As a possible implementation of this embodiment, step S3, using a depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment, includes:

[0095] Activate the environmental scanning capability of the depth sensor to identify and capture three-dimensional spatial information in the environment;

[0096] Adjusting the parameters of the depth sensor to optimize the accuracy and acquisition range of the point cloud data, wherein the parameter adjustment includes setting the scanning range and sampling accuracy;

[0097] Start real-time scanning of the environment to collect 3D point cloud data, including the 3D coordinate information of each point in the 3D point cloud data. The basic 3D model that makes up the environment.

[0098] As a possible implementation of this embodiment, the step S4, calculating the normal angle difference between adjacent triangles in the point cloud and screening out edge points with significant angle changes, includes:

[0099] Pre-generate the real edge point data of a standard cube, set the cube side length to half the unit length (0.5), and generate the 8 vertex coordinates of the cube;

[0100] Define 12 edges, and each edge consists of a vertex pair Indicates that the edge set of a cube is constructed, and each edge in the edge set of the cube corresponds to the bottom, top and side of the cube;

[0101] For each edge, calculate the midpoint position as the edge point, and store the midpoint coordinates in the true edge point list trueEdgePoints;

[0102] After the real edge points are generated, debug information is output to show the number of edge points generated;

[0103] When the spatial grid data changes (such as being added or updated), the latest spatial grid data is processed to filter out edge points with significant angle changes in the latest spatial grid data.

[0104] As a possible implementation of this embodiment, when the spatial grid data changes (such as being added or updated), the latest spatial grid data is processed to screen out edge points with significant angle changes in the latest spatial grid data, including:

[0105] Get the 3D data of the target mesh object. If the isReadable property of the target mesh is true, the edge detection process is allowed to continue; otherwise, a warning is given and a prompt is given to enable the read / write permission of the mesh.

[0106] Get the vertex, normal, and triangle data of the target mesh and create a vertexToTriangles dictionary mapping each vertex to its associated triangle list;

[0107] Traverse the triangle index array triangles, map each vertex index to the corresponding triangle number and store them in the vertexToTriangles dictionary;

[0108] Traverse all vertices in turn, compare the normals of adjacent triangles of each vertex, and for a certain vertex i , all its adjacent triangles are in the adjacentTriangles list, and through double loops, the normal angles of the two adjacent triangles on the vertex are calculated in turn; the angle between the two normal vectors normal1 and normal2 is calculated, and if the angle exceeds the preset angleThreshold value, the vertex is marked as an edge point;

[0109] If the vertex meets the edge condition, that is, the normal angle between a pair of adjacent triangles exceeds the angleThreshold value, the vertex is recorded in the edgePoints list and the number of detected edge points is output.

[0110] As a possible implementation of this embodiment, step S5, selecting a measurement start point and a measurement end point by hand rays, correcting the coordinates of the measurement points, and obtaining the final positions of the measurement start point and the measurement end point, includes:

[0111] The hand ray performs collision detection on the surface of the object after scene modeling. After the hand ray collides with the object surface, the system records the collision point as the initial measurement point;

[0112] By checking the edge point positions around the initial measurement point, if the distance between the collision point and the nearby edge point is within the set error threshold, the measurement point is adjusted to the nearest edge point position;

[0113] Generate horizontal and vertical auxiliary lines based on the coordinates of the initial measurement points;

[0114] Under the guidance of the auxiliary lines, select the end point, fine-tune the position through edge point correction, and finally determine the start and end point coordinates of the measurement.

[0115] As a possible implementation of this embodiment, generating horizontal and vertical auxiliary lines according to the coordinates of the initial measurement points includes:

[0116] When the user clicks, the coordinates of the measurement point are captured through the hand ray;

[0117] Count the number of valid measurement points. If only one valid starting point is detected, the system will continue to generate auxiliary lines. If there are no valid measurement points, all generated auxiliary lines will be cleared.

[0118] Get the collision point clickPosition where the user clicks through ray detection, and generate the plane plane with the normal of the point hitInfo.normal;

[0119] Centered on the click point clickPosition, based on the plane normal plane.normal, calculate the cross product of the plane normal and Vector3.up to obtain the direction of the horizontal line horizontalDirection, and generate dotted lines in the positive and negative directions to obtain horizontal auxiliary lines;

[0120] The vertical direction verticalDirection is calculated through the plane normal and the horizontal direction, and dotted lines are generated in the positive and negative directions respectively to obtain vertical auxiliary lines.

[0121] As a possible implementation of this embodiment, the position fine-tuning by edge point correction includes:

[0122] Get all edge point data stored in the edgePoints list;

[0123] If the edgePoints list is empty, an error message is recorded and the correction operation is terminated;

[0124] Set the initial distance threshold minDistance (for example, 0.1 meters) to filter the edge points closest to the user-selected point closestPoint, and record the selected point closestPoint and the initial distance threshold;

[0125] Traverse all edge points in the edgePoints list and perform the following steps for each edge point: Calculate the distance between the user-selected point closestPoint and the current edge point point. If the distance is less than the set minDistance threshold, update minDistance and set closestPoint to the current edge point point, indicating that a closer edge point is found;

[0126] After traversing all edge points, update closestPoint to the position of the nearest edge point and record it as the final selected edge point selectedEdgePoint.

[0127] The final selected edge point selectedEdgePoint will be used as the corrected measurement point.

[0128] As a possible implementation of this embodiment, in step S6, the mixed reality head display completes the positioning rendering of virtual information in numerical form according to the final position of the measurement point coordinates, including:

[0129] Set the positions of the start point StartPos and the end point EndPos, activate the dotted line DottedLine, and generate a clear measurement line in the mixed reality environment;

[0130] Calculate the distance Length between the starting point StartPos and the end point EndPos;

[0131] Format the distance Length as meters ("m") or centimeters ("cm") and display it at the midpoint of the measurement line segment;

[0132] Display the measured length in the virtual text box LengthText and adjust its position and direction.

[0133] like Figure 2 As shown, an embodiment of the present invention provides a space distance measurement device based on mixed reality, including:

[0134] An initialization module, used to initialize the depth sensor, camera module, and hand ray of the mixed reality device;

[0135] The operation monitoring module is used to monitor the user's gesture operation in real time using the global event listener;

[0136] The environment scanning module is used to use the depth sensor to scan the surrounding environment in real time and obtain point cloud data in the environment;

[0137] The edge point screening module is used to calculate the normal angle difference between adjacent triangles in the point cloud and screen out edge points with significant angle changes;

[0138] The position measurement module is used to select the measurement starting point and the measurement end point through the hand ray, correct the coordinates of the measurement point, and calculate the final position of the measurement starting point and the measurement end point;

[0139] The positioning rendering module is used for the mixed reality head display to complete the positioning rendering of virtual information in numerical form according to the final position of the measurement point coordinates.

[0140] like Figure 3 As shown, the specific implementation process of the present invention for performing spatial ranging based on mixed reality is as follows.

[0141] 1. Start the spatial ranging function and initialize the depth sensor, camera module and hand ray.

[0142] When starting the ranging function, the necessary ranging modules are loaded, including the depth sensor, camera module, and hand ray.

[0143] During the initialization process, the depth sensor is calibrated to ensure alignment with the camera and hand rays. After calibration, the depth sensor begins to collect depth information of each point in the environment in real time and converts the data into three-dimensional coordinates. .

[0144] During initialization, the camera sets its capture parameters to ensure synchronization with the depth sensor's data.

[0145] When the hand ray function is initialized, the gesture recognition module is loaded and the hand ray is generated by detecting the user's gesture movements.

[0146] Second, enable the global event listener to monitor the user's gesture operations in real time, thereby improving the intuitiveness of the distance measurement process.

[0147] By implementing the IMixedRealityPointerHandler interface and starting the global event listener, the user's gesture operations can be monitored in real time to ensure that the user's interactive actions are accurately captured during the ranging process.

[0148] Implement the OnPointerClicked(MixedRealityPointerEventData eventData) method in the IMixedRealityPointerHandler interface to capture the user's click gesture operation. This method uses the direction and position of the hand ray to detect the user's click event and provide the starting trigger condition for subsequent measurement operations.

[0149] When the listener captures a click or touch event, it passes the event data to the core distance measurement module to provide accurate data support and instant feedback for subsequent measurement operations.

[0150] 3. The depth sensor scans the surrounding environment in real time and obtains point cloud data in the environment.

[0151] Enable the spatial perception function through MRTK (Mixed Reality Toolkit) to activate the environmental scanning capability of the depth sensor. Enabling the spatial perception function enables the device to identify and capture three-dimensional spatial information in the environment, providing support for ranging operations.

[0152] After the spatial perception function is enabled, the parameters of the depth sensor are adjusted to optimize the accuracy and acquisition range of the point cloud data. Adjusting the parameters includes setting the scanning range and sampling accuracy to ensure that the point cloud data can meet the accuracy requirements in specific application scenarios.

[0153] After the spatial perception function and parameter adjustment are completed, the depth sensor begins to scan the environment in real time and collect 3D point cloud data. The 3D coordinate information of each point The basic three-dimensional model of the environment provides an accurate spatial reference for subsequent ranging operations.

[0154] Fourth, angle threshold detection technology is used to calculate the normal angle difference of adjacent triangles in the point cloud, screen out edge points with significant angle changes, and enhance the recognition ability of complex geometric structures.

[0155] By implementing IMixedRealitySpatialAwarenessObservationHandler <spatialawarenessmeshobject>Interface, event registration is implemented through the OnEnable() method, using CoreServices.SpatialAwarenessSystem.RegisterHandler <IMixedRealitySpatialAwarenessObservationHandler <spatialawarenessmeshobject>>(this);Register the current object as a handler for spatial perception events to ensure that it can receive updates to the environment grid data. At the same time, call the GenerateTrueEdgePoints() method to generate real edge point data for testing the accuracy of the edge detection algorithm.

[0156] In the GenerateTrueEdgePoints() method, the real edge point data of a standard geometric body (cube) is pre-generated. The side length of the cube is set to half the unit length (0.5), and the coordinates of the eight vertices of the cube are generated to ensure that the position of each vertex in space is clear.

[0157] By defining 12 edges, each edge consists of a vertex pair Representation, construct the edge set of the cube. Each edge corresponds to the bottom, top and side of the cube, ensuring that the entire geometric structure is covered and providing a standard reference for edge detection.

[0158] For each edge, calculate the midpoint position as the edge point and store the midpoint coordinates in the trueEdgePoints list. This list represents the true edge points of the standard geometry (cube) and is used to verify the accuracy of the subsequent edge detection algorithm.

[0159] After the real edge points are generated, debugging information is output to show the number of edge points generated so that the user can verify whether the edge point generation process is successful.

[0160] Then when the spatial mesh data changes (such as added or updated), the OnObservationAdded and OnObservationUpdated methods are automatically triggered. In these methods, call ProcessMesh(eventData.SpatialObject); to process the latest spatial mesh data and provide input data for edge detection.

[0161] Start edge detection through the ProcessMesh(SpatialAwarenessMeshObject meshObject) method and obtain the 3D data of the target mesh object. If the isReadable property of the mesh is true, the edge detection process is allowed to continue. Otherwise, a warning will be issued to enable read / write permissions for the mesh.

[0162] The TestEdgeDetectionMethod method is called in the ProcessMesh method to test and evaluate the performance of different edge detection methods. In this implementation, the ExtractEdgePoints method is activated to detect and extract edge points in the mesh. Stopwatch is used to measure the method execution time, and the accuracy of edgePoints (detected edge points) and trueEdgePoints (real edge points) is calculated, and the accuracy and efficiency of the detection are output.

[0163] In the ExtractEdgePoints method, first get the vertex, normal, and triangle data of the mesh and create a vertexToTriangles dictionary to map each vertex to its associated triangle list to simplify the subsequent normal angle calculation.

[0164] Traverse the triangle index array triangles and create a vertexToTriangles dictionary by mapping each vertex index to the corresponding triangle number. This mapping helps to quickly find the triangles adjacent to each vertex and provides a basis for angle calculation for edge detection.

[0165] Traverse all vertices in turn and compare the normals of the adjacent triangles of each vertex. i , all its adjacent triangles are in the adjacentTriangles list. Through a double loop, the normal angles of the two adjacent triangles on the vertex are calculated in turn. Use the Vector3.Angle method to calculate the angle between the normal vectors normal1 and normal2. If the angle exceeds the preset angleThreshold, the vertex is marked as an edge point.

[0166] If the vertex meets the edge condition (that is, the normal angle of a pair of adjacent triangles exceeds angleThreshold), the vertex is recorded in the edgePoints list and the inner loop is jumped out to save computing resources. After all vertices are screened, the number of detected edge points is output.

[0167] In the normal angle calculation, if the normal vector of the adjacent triangle of the vertex and The angle 𝜃 between them satisfies the following conditions:

[0168] ,

[0169] At this time, edgePoints contains the information of all edge points, including the location coordinates and quantity of edge points.

[0170] 5. Select the measurement starting point and measurement end point through the hand ray, correct the measurement point coordinates, and calculate the final positions of the measurement starting point and measurement end point.

[0171] The hand ray function guides the user to select the measurement point and ensures that the hand ray only performs collision detection on the surface of the object after the scene modeling. By calling the GetSpatialMeshMask method, only the ray is allowed to collide with the valid mesh area obtained by the spatial perception scan, thereby avoiding the selection of invalid background areas or blank areas. After the hand ray collides with the object surface, the collision point is recorded as the initial measurement point.

[0172] After recording the initial measurement point, the measurement accuracy is improved by checking the edge point positions around the point. If the distance between the collision point and the nearby edge point is within the set error threshold, the measurement point is automatically adjusted to the nearest edge point position to ensure that the measurement point fits the actual edge of the object.

[0173] When the user determines the first measurement point, horizontal and vertical auxiliary measurement lines are automatically generated to help the user maintain alignment when selecting the second measurement point. These auxiliary lines are generated based on the coordinates of the initial measurement point and extend in the horizontal and vertical directions respectively, providing users with visual references to help them select the precise end point in the next measurement.

[0174] Guided by the auxiliary lines, the user selects the end point and still performs fine-tuning of the position through edge point correction to ultimately determine the coordinates of the start and end points of the measurement, providing basic data for subsequent precise spatial distance measurement calculations.

[0175] The automatic generation of horizontal and vertical auxiliary measurement lines includes:

[0176] In the OnPointerClicked method, when the user clicks, the coordinates of the measurement point are captured through the hand ray;

[0177] Use the CountNonDefaultVector3Elements method to count the number of valid measurement points. If only one valid starting point is detected, the next step will be to generate auxiliary lines. If there are no valid measurement points, all generated auxiliary lines will be cleared to ensure a clean interface;

[0178] The collision point clickPosition where the user clicks is obtained through ray detection, and the plane is generated with the normal of the point hitInfo.normal. The plane is used to determine the direction of the auxiliary line so that the horizontal and vertical dotted reference lines can be generated later.

[0179] In the GenerateLines method, horizontal and vertical auxiliary lines are generated based on the plane normal plane.normal, with the click point clickPosition as the center:

[0180] Horizontal auxiliary line generation: Calculate the cross product of the plane normal and Vector3.up to obtain the direction of the horizontal line horizontalDirection, and then generate dotted lines in the positive and negative directions respectively;

[0181] Vertical auxiliary line generation: Calculate the vertical direction verticalDirection through the plane normal and the horizontal direction, and also generate dotted lines in the positive and negative directions.

[0182] In the CreateDashedLine method, a dashed line segment is created based on the specified starting point start and direction direction (the parameters are given when generating horizontal lines and vertical lines). Each segment is composed of small cubes to form a discontinuous dashed line effect. The total length of the dashed line segment and the length of each segment are defined, and small cube segments are gradually generated in the specified direction; the starting and ending positions of each dashed line segment are set in linePoints, and the material of the line segment is set to red so that users can clearly identify it in a mixed reality environment.

[0183] Before generating new auxiliary lines, clear the existing dashed line segments and destroy the previous objects through the ClearPreviousLines method to ensure a clean interface. The newly generated auxiliary lines are managed through the currentLineSegments collection so that they can be effectively updated when the end point is selected or the auxiliary lines are regenerated.

[0184] The position fine-tuning by edge point correction includes:

[0185] By getting all edge point data stored in the edgePoints list;

[0186] If the edgePoints list is empty, an error message is recorded and the correction operation is terminated;

[0187] Set an initial minimum distance threshold minDistance (for example, 0.1 meters) to filter the edge points closest to the user-selected point closestPoint. Record the selected point closestPoint and the initial distance threshold so that the best match can be found in the edge points later.

[0188] Traverse all edge points in the edgePoints list and perform the following steps for each edge point:

[0189] Calculate the distance between the user-selected point closestPoint and the current edge point point;

[0190] If the distance is less than the set minDistance threshold, minDistance is updated and closestPoint is set to the current edge point, indicating that a closer edge point is found;

[0191] After traversing all edge points, the closestPoint is updated to the position of the nearest edge point and recorded as selectedEdgePoint. The final selected edge point selectedEdgePoint will be used as the corrected measurement point to ensure that the measurement point position is more consistent with the actual edge of the object.

[0192] The choice of whether the measurement end point is on the horizontal and vertical auxiliary lines includes: on the auxiliary measurement horizontal and vertical line segments defined by the PointEvent.linePoints array. If the distance from the measurement end point to a point on the line segment in the same direction (with equal y-axis coordinates) is less than a threshold, the point is considered to be close enough to the line segment and is adsorbed to the nearest point on the line segment. Otherwise, the measurement end point remains unchanged.

[0193] The present invention further provides a method for dynamically obtaining the target position from the spatial perception grid, which can realize the spatial coordinate calculation based on ray detection by calling the static method GetPositionOnSpatialMap(MixedRealityPointerEventData eventData, float maxDistance), and is suitable for the interactive positioning function in the mixed reality scene. Its function description is as follows:

[0194] 1. Input parameters.

[0195] The method receives the event data MixedRealityPointerEventData eventData as input, which contains key information about the pointer position and direction.

[0196] The method supports an optional parameter maxDistance, which is used to limit the maximum range of ray detection. The default value is 10 units in length.

[0197] 2. Ray detection logic.

[0198] The method uses the Physics.Raycast method of the Unity engine, using eventData.Pointer.Position as the starting point of the ray and eventData.Pointer.Rotation*Vector3.forward as the direction of the ray.

[0199] During the detection process, the GetSpatialMeshMask() method is called to obtain the physical layer mask of the spatial grid, thereby limiting the detection range of the ray and acting only on the specified spatial perception grid.

[0200] By calling the static method GetSpatialMeshMask(), the physical layer configuration information of multiple spatial mesh observers can be effectively integrated to generate a unified physical layer mask to support subsequent physical layer operations. The function description of this method is as follows:

[0201] (1) Initial state judgment:

[0202] The method checks whether the static variable mPhysicsLayer is zero to determine whether the current physical layer mask has been calculated. If not, it enters the configuration file parsing and mask calculation process; otherwise, it directly returns the calculated physical layer mask value to avoid repeated calculations and improve operation efficiency;

[0203] (2) Spatial perception configuration file analysis:

[0204] The method obtains the configuration file of the spatial awareness system from the core service interface CoreServices.SpatialAwarenessSystem and verifies the configuration file type. If the configuration file is of the MixedRealitySpatialAwarenessSystemProfile type, it traverses the observer configuration list ObserverConfigurations contained in it;

[0205] (3) Observer configuration extraction and judgment:

[0206] During the traversal process, the method further filters out the configuration file MixedRealitySpatialAwarenessMeshObserverProfile of the mesh observer, and reads the physical layer configuration parameter MeshPhysicsLayer therein;

[0207] (4) Physical layer mask calculation:

[0208] Based on the read MeshPhysicsLayer parameters, the method generates the corresponding physical layer mask value through bitwise operation (1 << MeshPhysicsLayer), and uses the bitwise OR operator |= to gradually integrate the physical layer masks of each mesh viewer into the static variable mPhysicsLayer to achieve the dynamic superposition of multiple physical layers;

[0209] (5)Result return:

[0210] After the method completes the integration of the physical layer mask, it stores the final result in the static variable mPhysicsLayer and outputs it as the return value for external calls.

[0211] 3. Collision point calculation.

[0212] If the raycast is successful (i.e., the ray collides with the spatial mesh), the position information of the collision point hitInfo.point is obtained through RaycastHit.

[0213] The collision point information is represented in the Vector3 type and output as the return value.

[0214] 4. Return result.

[0215] If the raycast is successful, the spatial coordinates of the collision point are returned, representing the intersection position of the pointer on the spatial mesh.

[0216] If the raycast fails (no collision with any spatial mesh), null is returned, indicating that no valid intersection is detected.

[0217] Six. The mixed reality headset completes the virtual information positioning rendering in numerical form according to the final position of the measurement point coordinates.

[0218] Set the positions of the start point StartPos and the end point EndPos in the lineRenderer component, activate the dotted line DottedLine, and generate a clear measurement line in the mixed reality environment;

[0219] Calculate the distance Length between the start point StartPos and the end point EndPos;

[0220] Call the SetLengthInfo method to format the measurement result Length into meters ("m") or centimeters ("cm") and display it at the midpoint position of the measurement line segment;

[0221] Display the measurement length in the virtual text box LengthText, and adjust its position and orientation to clearly present the measurement result.

[0222] Where: In the mixed reality system, the distance measurement formula is based on the three-dimensional space coordinates of the starting point and the end point. Given the starting point StartPos= and end point EndPos= , the Euclidean distance (i.e. straight-line distance) between two points can be calculated using the following formula:

[0223] ,

[0224] in, is the three-dimensional coordinate of the starting point, is the 3D coordinate of the end point, and Length is the distance between the start point and the end point, with the same unit as the coordinate system (usually meters or centimeters).

[0225] The display format is: if Length is greater than or equal to 1 meter, its unit is displayed in meters (m); if Length is less than 1 meter, it is converted to centimeters and displayed by multiplying Length by 100 and presenting it in cm.

[0226] An electronic device provided by an embodiment of the present invention includes a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the device is running, the processor communicates with the memory through the bus, and the processor executes the machine-readable instructions to perform the steps of any of the above-mentioned spatial ranging methods based on mixed reality.

[0227] Specifically, the above-mentioned memory and processor can be general-purpose memory and processor, which are not specifically limited here. When the processor runs the computer program stored in the memory, the above-mentioned spatial ranging method based on mixed reality can be executed.

[0228] Those skilled in the art will appreciate that the structure of the electronic device does not limit the electronic device and may include more or fewer components than shown in the figure, or combine or split certain components, or arrange the components differently.

[0229] In some embodiments, the electronic device may also include a touch screen that can be used to display a graphical user interface (e.g., a startup interface of an application) and receive user operations on the graphical user interface (e.g., startup operations on an application). The specific touch screen may include a display panel and a touch panel. The display panel may be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc. The touch panel may collect the user's contact or non-contact operations on or near it, and generate pre-set operation instructions, for example, the user uses any suitable object such as a finger, stylus, or accessories on or near the touch panel. In addition, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and posture, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into information that the processor can process, and then sends it to the processor, and can receive and execute commands from the processor. In addition, the touch panel can be implemented by various types such as resistive, capacitive, infrared and surface acoustic wave, and any technology developed in the future can also be used to implement the touch panel. Further, the touch panel can cover the display panel, and the user can operate on or near the touch panel covered on the display panel according to the graphical user interface displayed on the display panel. After the touch panel detects the operation on or near it, it is transmitted to the processor to determine the user input, and then the processor provides corresponding visual output on the display panel in response to the user input. In addition, the touch panel and the display panel can be implemented as two independent components or integrated.

[0230] Corresponding to the method for starting the above-mentioned application, an embodiment of the present invention further provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned spatial ranging methods based on mixed reality are executed.

[0231] The application startup device provided in the embodiment of the present application can be specific hardware on the device or software or firmware installed on the device. The device provided in the embodiment of the present application, its implementation principle and the technical effect produced are the same as those in the aforementioned method embodiment. For the sake of brief description, the parts not mentioned in the device embodiment can refer to the corresponding contents in the aforementioned method embodiment. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment, and will not be repeated here.

[0232] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0233] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0234] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0235] In addition, each functional module in the embodiments provided in the present application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0236] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0237] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0238] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0239] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.< / spatialawarenessmeshobject> < / spatialawarenessmeshobject>

Claims

1. A spatial distance measurement method based on mixed reality, characterized in that: The steps include: Step S1, initializing the depth sensor, camera module and hand ray of the mixed reality device; Step S2, using a global event listener to monitor the user's gesture operation in real time; Step S3, using a depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment; Step S4, calculating the normal angle difference between adjacent triangles in the point cloud, and screening out edge points with significant angle changes; Step S5, selecting the measurement start point and the measurement end point through the hand ray, correcting the coordinates of the measurement points, and obtaining the final positions of the measurement start point and the measurement end point; Step S6, the mixed reality head display completes the positioning rendering of virtual information in numerical form according to the final position of the measurement point coordinates; The step S4, calculating the normal angle difference between adjacent triangles in the point cloud and screening out edge points with significant angle changes, includes: Pre-generate the real edge point data of a standard cube, set the cube side length to half the unit length, and generate the 8 vertex coordinates of the cube; Define 12 edges, and each edge consists of a vertex pair Indicates that the edge set of a cube is constructed, and each edge in the edge set of the cube corresponds to the bottom, top and side of the cube; For each edge, calculate the midpoint position as the edge point and store the midpoint coordinates in the real edge point list; After the real edge points are generated, debug information is output to show the number of edge points generated; When the spatial grid data changes, the latest spatial grid data is processed to filter out edge points with significant angle changes in the latest spatial grid data; The step S5, selecting the measurement start point and the measurement end point by hand ray, correcting the measurement point coordinates, and obtaining the final positions of the measurement start point and the measurement end point, includes: The hand ray performs collision detection on the surface of the object after scene modeling. After the hand ray collides with the object surface, the system records the collision point as the initial measurement point; By checking the edge point positions around the initial measurement point, if the distance between the collision point and the nearby edge point is within the set error threshold, the measurement point is adjusted to the nearest edge point position; Generate horizontal and vertical auxiliary lines based on the coordinates of the initial measurement points; Under the guidance of the auxiliary lines, select the end point, fine-tune the position through edge point correction, and finally determine the start and end point coordinates of the measurement.

2. The spatial distance measurement method based on mixed reality according to claim 1, characterized in that: The step S1, initializing the depth sensor, camera module and hand ray of the mixed reality device, includes: Calibrate the depth sensor, collect the depth information of each point in the environment in real time, and convert the data into three-dimensional coordinates ; Initialize the camera's shooting parameters; Detect user gestures and generate hand rays. The hand ray is generated by the far pointer of the user's hand and can point to and select any point in the virtual space.

3. The spatial distance measurement method based on mixed reality according to claim 1, characterized in that: The step S2, using a global event listener to monitor the user's gesture operation in real time, includes: Start a global event listener to monitor the user's gesture operations in real time and capture the user's interactive actions. The gesture operations include hand cursor pointing and selection. Use the direction and position of the hand ray to detect the user's click event and capture the user's click gesture operation; When a click or touch event is captured, the event data is recorded.

4. The spatial distance measurement method based on mixed reality according to claim 1, characterized in that: The step S3, using a depth sensor to scan the surrounding environment in real time to obtain point cloud data in the environment, includes: Activate the environmental scanning capability of the depth sensor to identify and capture three-dimensional spatial information in the environment; Adjusting the parameters of the depth sensor to optimize the accuracy and acquisition range of the point cloud data, wherein the parameter adjustment includes setting the scanning range and sampling accuracy; Start real-time scanning of the environment to collect 3D point cloud data, including the 3D coordinate information of each point in the 3D point cloud data. The basic 3D model that makes up the environment.

5. The spatial distance measurement method based on mixed reality according to claim 1, characterized in that: When the spatial grid data changes, the latest spatial grid data is processed to screen out edge points with significant angle changes in the latest spatial grid data, including: Get the 3D data of the target mesh object. If the isReadable property of the target mesh is true, the edge detection process is allowed to continue; otherwise, a warning is given and a prompt is given to enable the read / write permission of the mesh. Get the vertex, normal, and triangle data of the target mesh and create a vertexToTriangles dictionary mapping each vertex to its associated triangle list; Traverse the triangle index array triangles, map each vertex index to the corresponding triangle number and store them in the vertexToTriangles dictionary; Traverse all vertices in turn, compare the normals of adjacent triangles of each vertex, and for a certain vertex i , all its adjacent triangles are in the adjacentTriangles list, and through a double loop, the normal angles of the two adjacent triangles on the vertex are calculated in turn; the angle between the two normal vectors is calculated, and if the angle exceeds the preset angleThreshold value, the vertex is marked as an edge point; If the vertex meets the edge condition, that is, the normal angle between a pair of adjacent triangles exceeds the angleThreshold value, the vertex is recorded in the edge point list and the number of detected edge points is output.

6. The spatial distance measurement method based on mixed reality according to claim 1, characterized in that: The step of generating horizontal and vertical auxiliary lines according to the coordinates of the initial measurement points includes: When the user clicks, the coordinates of the measurement point are captured through the hand ray; Count the number of valid measurement points. If only one valid starting point is detected, the system will continue to generate auxiliary lines. If there are no valid measurement points, all generated auxiliary lines will be cleared. Get the collision point clicked by the user through ray detection, and generate a plane with the normal of the point; With the collision point as the center, based on the plane's normal, calculate the cross product of the plane's normal and Vector3.up to obtain the direction of the horizontal line, and generate dotted lines in the positive and negative directions to obtain horizontal auxiliary lines; The vertical direction is calculated through the plane normal and the horizontal direction, and dotted lines are generated in the positive and negative directions respectively to obtain vertical auxiliary lines; The position fine-tuning by edge point correction includes: Get all edge point data stored in the edge point list; If the edge point list is empty, an error message is recorded and the correction operation is terminated; Set the initial distance threshold to filter the edge points closest to the user's selected point, and record the selected point and the initial distance threshold; Traverse all edge points in the edge point list and perform the following steps for each edge point: calculate the distance between the user-selected point and the current edge point. If the distance is less than the set initial distance threshold, update the initial distance threshold and set the selected point as the current edge point; After traversing all edge points, the selected point is updated to the position of the nearest edge point and recorded as the final selected edge point; The edge points finally selected will be used as the corrected measurement points; In the process of obtaining the collision point clicked by the user through ray detection, the GetSpatialMeshMask() method is called to obtain the physical layer mask of the spatial grid. The GetSpatialMeshMask() method includes: Initial state judgment: Determine whether the current physical layer mask has been calculated by checking whether the static variable mPhysicsLayer is zero; if not calculated, enter the configuration file parsing and mask calculation process; otherwise, directly return the calculated physical layer mask value; Spatial awareness configuration file parsing: Obtain the configuration file of the spatial awareness system from the core service interface CoreServices.SpatialAwarenessSystem and verify the configuration file type; if the configuration file belongs to the MixedRealitySpatialAwarenessSystemProfile type, traverse the observer configuration list ObserverConfigurations it contains; Observer configuration extraction and judgment: During the traversal, further filter out the configuration file MixedRealitySpatialAwarenessMeshObserverProfile of the mesh observer and read the physical layer configuration parameter MeshPhysicsLayer in it; Physical layer mask calculation: Based on the read MeshPhysicsLayer parameter, generate the corresponding physical layer mask value through the bit operation of 1<<MeshPhysicsLayer, and use the bitwise OR operator |= to gradually integrate the physical layer masks of each mesh observer into the static variable mPhysicsLayer to achieve the dynamic superposition of multiple physical layers; Result return: After completing the integration of the physical layer mask, store the final result in the static variable mPhysicsLayer and output it as the return value for external calls.

7. The spatial distance measurement method based on mixed reality according to any one of claims 1 to 6, characterized in that: In step S6, the mixed reality headset completes the virtual information positioning rendering in numerical form according to the final positions of the measurement point coordinates, including: Set the positions of the starting point and the ending point, activate the dotted line DottedLine, and generate a clear measurement line in the mixed reality environment; Calculate the distance between the starting point and the ending point; Format the distance between the starting point and the ending point as meters or centimeters and display it at the midpoint position of the measurement line segment; Display the measurement length in the virtual text box LengthText and adjust its position and orientation.

8. A spatial distance measuring device based on mixed reality, characterized in that: Including: Initialization module, used to initialize the depth sensor, camera module and hand ray of the mixed reality device; Operation monitoring module, used to use the global event listener to monitor the user's gesture operations in real time; Environmental scanning module, used to use the depth sensor to scan the surrounding environment in real time and obtain the point cloud data in the environment; Edge point screening module, used to calculate the normal angle difference between adjacent triangles in the point cloud and screen out the edge points with significant angle changes; Position measurement module, used to select the measurement starting point and the measurement ending point through the hand ray, correct the measurement point coordinates, and obtain the final positions of the measurement starting point and the ending point; Positioning rendering module, used for the mixed reality headset to complete the virtual information positioning rendering in numerical form according to the final positions of the measurement point coordinates; The edge point screening module calculates the normal angle difference of adjacent triangles in the point cloud and screens out edge points with significant angle changes, including: Pre-generate the real edge point data of a standard cube, set the cube side length to half the unit length, and generate the 8 vertex coordinates of the cube; Define 12 edges, and each edge consists of a vertex pair Indicates that the edge set of a cube is constructed, and each edge in the edge set of the cube corresponds to the bottom, top and side of the cube; For each edge, calculate the midpoint position as the edge point and store the midpoint coordinates in the real edge point list; After the real edge points are generated, debug information is output to show the number of edge points generated; When the spatial grid data changes, the latest spatial grid data is processed to filter out edge points with significant angle changes in the latest spatial grid data; The position measurement module selects the measurement start point and the measurement end point through the hand ray, corrects the coordinates of the measurement point, and obtains the final position of the measurement start point and the measurement end point, including: The hand ray performs collision detection on the surface of the object after scene modeling. After the hand ray collides with the object surface, the system records the collision point as the initial measurement point; By checking the edge point positions around the initial measurement point, if the distance between the collision point and the nearby edge point is within the set error threshold, the measurement point is adjusted to the nearest edge point position; Generate horizontal and vertical auxiliary lines based on the coordinates of the initial measurement points; Under the guidance of the auxiliary lines, select the end point, fine-tune the position through edge point correction, and finally determine the start and end point coordinates of the measurement.

Citation Information

Patent Citations

  • Spatial distance measurement method and system based on HoloLens equipment

    CN113589929A