ArUco marker tracking on the HoloLens
Published:
The ArUcoDetectionHoloLens-Unity sample enables marker detection and tracking using the HoloLens photo-video camera and the ArUco library in OpenCV.
Detected marker visualized through the HoloLens display
Marker detection is an important part in implementing an augmented reality solution; enabling the relation of virtual content to real objects in the scene. This occurs through establishing point correspondences between 3D world points and 2D image points and having knowledge of the intrinsic parameters of a camera, K
. With known camera intrinsics, 3D world points and corresponding 2D projections in the image systems can be related through the perspective-n-point relation allowing for estimation of camera pose (position and orientation), [R t]
.
Once the pose of the calibrated camera is known, it becomes possible to align virtual content with real content in the scene.
Running the sample
ArUco marker tracking is made available for use in Unity through IL2CPP Windows Runtime support.
Incorporates:
- HoloLensForCV sample from Microsoft, at personal branch
- ArUco marker detection in OpenCV
Requirements
- Tested with Unity 2018.4 LTS
- Visual Studio 2017
- Minimum RS4, tested with OS Build 17763.678
- Printed (or on screen) ArUco markers. Markers can be readily generated using the following tool
ArUco Detection Sample
- Open HoloLensForCV sample in VS2017 and install included OpenCV.UWP.411 NuGet package to HoloLensForCV project
- Build the HoloLensForCV project (x86, Debug or Release)
- Copy all output files from HoloLensForCV output path (dlls and HoloLensForCV.winmd) to the Assets->Plugins->x86 folder of the ArUcoDetectionHoloLensUnity project
- Open ArUcoDetectionHoloLensUnity Unity project and build using IL2CPP, ensure that unsafe code is allowed under Unity Player Settings->Other Settings
- Open VS solution, build then deploy to device
- When looking at an aruco marker from the correct ArUco dictionary: this sample uses the
6x6 (50, 100, 250, 500) dictionary
by default, a virtual cube, which is scaled to the size of the ArUco marker, should appear on top of the marker