Skip to content

Programs to calibrate HoloLens front-facing camera, supporting HL1 and HL2

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

qian256/HoloLensCamCalib

Repository files navigation

HoloLens Camera Calibration

Author: Long Qian

Date: 2020-04-19

Overview

This repository guides you to calibrate your HoloLens front-facing camera using OpenCV. It supports both HoloLens 1 and HoloLens 2.

The intrinsics of HoloLens front-facing camera is available with Windows UWP API, but we still want to calibrate it for various reasons. Then it is the right repository for you.

This repository contains:

  • HoloLensFrameSaver/: Unity project to capture and save images for calibration
  • OpenCVCalib/: python scripts to calibrate the camera using saved images
  • CalibFileConverter/: C++ program to convert the OpenCV calibration file to ARToolKit format
  • Examples/: Example calibration files and images for HoloLens 1 and HoloLens 2 (with my device)

How to Calibrate?

  1. Build HoloLensFrameSaver
    • Change the target resolution for the front-facing camera in Unity, available resolution profiles are listed here
    • Apply approriate settings to build the app and deploy to device
  2. Run HoloLensFrameSaver on the device
    • Soon after starting, the camera image should be displayed in the front
    • Prepare a chessboard marker for calibration, e.g. chessboard.pdf
    • Run the python script on the host PC HoloLensFrameSaver\keyboard.py with IP address of HoloLens. The script sends keyboard command to the HoloLens
    • Adjust your head position to look at the chessboard from various angles and distances. Press Space key on the keyboard to trigger HoloLens to save the image locally
  3. Download the images from the Device Portal, FileExplorer\LocalAppData\FrameSaver\RoamingState\
  4. Run the Python script in OpenCVCalib to calibrate the saved images
    • python calibrate.py --square_size 0.03 --pattern_width 7 --pattern_height 5 PATH/TO/IMAGE/*.png
    • If you used your own chessboard marker, change the arguments of the python script
    • You will find the calibration file at output\data.yaml and output\data.json
  5. (Optional) If you come from HoloLensARToolKit, you need to convert the OpenCV format calibration file to ARToolKit format. You can achieve that by using the C++ program in CalibFileConverter/.
    • Modify the parameters in ARToolKitCalibrationFileGenerator.cpp using the results of previous calibration
    • Run the program, and copy the calibration file to HoloLensARToolKit

FAQ

  1. How to I verify the binary ARToolKit calibration file?

Run the src/ARToolKitCalibrationFileGenerator/ARToolKitCalibrationFileReader.py with the specific readFileName parameter.

License

HoloLensCamCalib is open for use in compliance with GNU Lesser General Public License (LGPL v3.0). Please see COPYING and COPYING.LESSER for license details.

About

Programs to calibrate HoloLens front-facing camera, supporting HL1 and HL2

Topics

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published