Skip to content

Commit d2ea093

Browse files
committed
Fixed the camera matrix for AR.
1 parent ffba7d7 commit d2ea093

3 files changed

Lines changed: 35 additions & 20 deletions

File tree

Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/HoloLensArUcoExample.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,20 @@ public class HoloLensArUcoExample : MonoBehaviour
129129
/// </summary>
130130
Mat rgbMat;
131131

132-
// Camera matrix value of Holelens camera of 896x504 size. (this value is not generated by camera calibration)
133-
// (can adjust the position of the AR hologram with the values ​​of cx and cy)
134-
private double fx = 1038;
135-
private double fy = 1037;
136-
private double cx = 400;
137-
private double cy = 244;
132+
// Camera matrix value of Hololens camera 896x504 size.
133+
// These values ​​are unique to my device, obtained from "Windows.Media.Devices.Core.CameraIntrinsics" class. (https://docs.microsoft.com/en-us/uwp/api/windows.media.devices.core.cameraintrinsics)
134+
// (can adjust the position of the AR hologram with the values ​​of cx and cy. see http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html)
135+
private double fx = 1035.149;//focal length x.
136+
private double fy = 1034.633;//focal length y.
137+
private double cx = 404.9134;//principal point x.
138+
private double cy = 236.2834;//principal point y.
138139
private MatOfDouble distCoeffs;
139-
private double distCoeffs1 = 0.0;
140-
private double distCoeffs2 = 0.0;
141-
private double distCoeffs3 = 0.0;
142-
private double distCoeffs4 = 0.0;
143-
private double distCoeffs5 = 0.0;
140+
private double distCoeffs1 = 0.2036923;//radial distortion coefficient k1.
141+
private double distCoeffs2 = -0.2035773;//radial distortion coefficient k2.
142+
private double distCoeffs3 = 0.0;//tangential distortion coefficient p1.
143+
private double distCoeffs4 = 0.0;//tangential distortion coefficient p2.
144+
private double distCoeffs5 = -0.2388065;//radial distortion coefficient k3.
145+
144146

145147
private bool detecting = false;
146148
private bool ARTransMatrixUpdated = false;

Assets/HoloLensWithOpenCVForUnityExample/HoloLensArUcoExample/Materials/ArUcoMaterial.mat

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ Material:
77
m_PrefabParentObject: {fileID: 0}
88
m_PrefabInternal: {fileID: 0}
99
m_Name: ArUcoMaterial
10-
m_Shader: {fileID: 30, guid: 0000000000000000f000000000000000, type: 0}
11-
m_ShaderKeywords:
12-
m_LightmapFlags: 5
13-
m_CustomRenderQueue: -1
14-
stringTagMap: {}
10+
m_Shader: {fileID: 4800000, guid: 30a212a88e1063a428c85e50b1e427f2, type: 3}
11+
m_ShaderKeywords: _ALPHABLEND_ON _EMISSION
12+
m_LightmapFlags: 1
13+
m_CustomRenderQueue: 3000
14+
stringTagMap:
15+
RenderType: Transparent
1516
m_SavedProperties:
1617
serializedVersion: 2
1718
m_TexEnvs:
@@ -81,34 +82,46 @@ Material:
8182
second: 1
8283
- first:
8384
name: _DstBlend
84-
second: 0
85+
second: 10
8586
- first:
8687
name: _EmissionScaleUI
8788
second: 0
89+
- first:
90+
name: _GlossMapScale
91+
second: 1
8892
- first:
8993
name: _Glossiness
9094
second: 0.5
95+
- first:
96+
name: _GlossyReflections
97+
second: 1
9198
- first:
9299
name: _Metallic
93100
second: 0
94101
- first:
95102
name: _Mode
96-
second: 0
103+
second: 2
97104
- first:
98105
name: _OcclusionStrength
99106
second: 1
100107
- first:
101108
name: _Parallax
102109
second: 0.02
103110
- first:
104-
name: _SrcBlend
111+
name: _SmoothnessTextureChannel
112+
second: 0
113+
- first:
114+
name: _SpecularHighlights
105115
second: 1
116+
- first:
117+
name: _SrcBlend
118+
second: 5
106119
- first:
107120
name: _UVSec
108121
second: 0
109122
- first:
110123
name: _ZWrite
111-
second: 1
124+
second: 0
112125
m_Colors:
113126
- first:
114127
name: _Color
7.63 KB
Binary file not shown.

0 commit comments

Comments
 (0)