Yes, your observation is correct. The HoloLens 2 does not directly provide a vergence distance/point calculation. Here's a breakdown of the situation and potential workarounds:
Why vergence distance is likely not supported:
Hardware Limitations: Unlike some advanced VR/AR headsets, the HoloLens 2 might not have the precise eye-tracking sensors to accurately calculate the convergence point of the eyes.
Focus on Holograms: The HoloLens 2 is primarily designed for interacting with holographic content. Direct vergence distance may be less of a priority, especially if the primary use case is focusing on objects in the user's environment.
Alternative approaches:
- Estimating Vergence Point: Your idea of manually intersecting eye gaze rays is a viable approach. Here's what you'd need to consider:
- Accuracy: The accuracy depends on the precision of your eye-tracking data. You might need to implement some smoothing or calibration to reduce noise.
- Computation: Real-time ray intersection calculations can add some overhead. Optimize if performance is critical.
- Spatial Mesh Raycasting: Your point about the coarse mesh is valid. Here are some ways to address that:
- Refinement: Explore options to increase the spatial mesh resolution or create a custom, higher-detail invisible mesh purely for eye-tracking.
- Interpolation: If you hit the spatial mesh, use surrounding points to refine the gaze position estimate through interpolation.
- Hybrid Approach: Combine the strengths of both:
Use spatial mesh raycasting as a general guide to determine where the user is roughly looking.
If the mesh hit is imprecise, fall back to your ray intersection method for finer gaze estimation.
Extracting 2D Gaze Coordinates:
Once you have a vergence point (real or estimated) here's how to obtain 2D screen space coordinates:
- Camera Model: Know your camera's intrinsic parameters (focal length, principal point, etc.)
- Head Pose: Get the HoloLens 2's position and orientation in world space.
- Projection: Project the vergence point using the camera model and head pose onto the image plane to get screen space coordinates.
Libraries/Tools
- MRTK: The Mixed Reality Toolkit likely has helper functions for camera projections and raycasting.
- OpenCV: OpenCV's computer vision capabilities could be useful for eye-tracking calibration or refining spatial mesh data.
Important Note: Eye-tracking on the HoloLens 2, particularly for precise gaze coordinate calculation, is still an area of active research and development. You might have to experiment to find the best solution for your needs.