Skip to content

Commit 0531f47

Browse files
committed
Added the HoloLensArUcoCameraCalibrationExample.
Modified it to correspond to the WSA API of the new Unity version.
1 parent bd2ae95 commit 0531f47

19 files changed

+9163
-103
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using UnityEngine;
2+
using System;
3+
using OpenCVForUnity;
4+
5+
namespace HoloLensWithOpenCVForUnityExample
6+
{
7+
[System.Serializable]
8+
public struct CameraParameters
9+
{
10+
public string calibration_date;
11+
public int frames_count;
12+
public int image_width;
13+
public int image_height;
14+
public int calibration_flags;
15+
public double[] camera_matrix;
16+
public double[] distortion_coefficients;
17+
public double avg_reprojection_error;
18+
19+
public CameraParameters (int frames_count, int image_width, int image_height, int calibration_flags, double[] camera_matrix, double[] distortion_coefficients, double avg_reprojection_error)
20+
{
21+
this.calibration_date = DateTime.Now.ToString ();
22+
this.frames_count = frames_count;
23+
this.image_width = image_width;
24+
this.image_height = image_height;
25+
this.calibration_flags = calibration_flags;
26+
this.camera_matrix = camera_matrix;
27+
this.distortion_coefficients = distortion_coefficients;
28+
this.avg_reprojection_error = avg_reprojection_error;
29+
}
30+
31+
public CameraParameters (int frames_count, int image_width, int image_height, int calibration_flags, Mat camera_matrix, Mat distortion_coefficients, double avg_reprojection_error)
32+
{
33+
double[] camera_matrixArr = new double[camera_matrix.total()];
34+
camera_matrix.get (0, 0, camera_matrixArr);
35+
36+
double[] distortion_coefficientsArr = new double[distortion_coefficients.total()];
37+
distortion_coefficients.get (0, 0, distortion_coefficientsArr);
38+
39+
this.calibration_date = DateTime.Now.ToString ();
40+
this.frames_count = frames_count;
41+
this.image_width = image_width;
42+
this.image_height = image_height;
43+
this.calibration_flags = calibration_flags;
44+
this.camera_matrix = camera_matrixArr;
45+
this.distortion_coefficients = distortion_coefficientsArr;
46+
this.avg_reprojection_error = avg_reprojection_error;
47+
}
48+
49+
public Mat GetCameraMatrix ()
50+
{
51+
Mat m = new Mat (3, 3, CvType.CV_64FC1);
52+
m.put (0, 0, camera_matrix);
53+
return m;
54+
}
55+
56+
public Mat GetDistortionCoefficients ()
57+
{
58+
Mat m = new Mat (distortion_coefficients.Length, 1, CvType.CV_64FC1);
59+
m.put (0, 0, distortion_coefficients);
60+
return m;
61+
}
62+
}
63+
}

Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/CameraParameters.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)