質問編集履歴

1

ソースコードの添付をやめた

2019/07/15 08:31

投稿

hama1185
hama1185

スコア18

test CHANGED
File without changes
test CHANGED
@@ -15,110 +15,6 @@
15
15
 
16
16
 
17
17
  ```C#
18
-
19
- using System.Collections;
20
-
21
- using System.Collections.Generic;
22
-
23
- using UnityEngine;
24
-
25
- using UnityEngine.XR;
26
-
27
-
28
-
29
- public class CameraController : MonoBehaviour
30
-
31
- {
32
-
33
-
34
-
35
- // Start is called before the first frame update
36
-
37
- Camera mainCam;
38
-
39
- OpenCVCameraParams script;
40
-
41
- void Start()
42
-
43
- {
44
-
45
- mainCam = transform.GetChild(0).GetComponent<Camera>();
46
-
47
- script = mainCam.GetComponent<OpenCVCameraParams>();
48
-
49
- }
50
-
51
-
52
-
53
- // Update is called once per frame
54
-
55
- void Update()
56
-
57
- {
58
-
59
- Vector3 basePos = new Vector3 (
60
-
61
- 0,
62
-
63
- 2,
64
-
65
- 0
66
-
67
- );
68
-
69
- trackingPosition = trackingPos * transform.rotation;
70
-
71
- transform.position = basePos - trackingPos;
72
-
73
- }
74
-
75
- Matrix4x4 PerspectiveMat() {
76
-
77
- var m = new Matrix4x4();
78
-
79
- m[0, 0] = 2 * script.Fx / script.ImageWidth;
80
-
81
- m[0, 1] = 0;
82
-
83
- m[0, 2] = 1 - 2 * script.Cx / script.ImageWidth;
84
-
85
- m[0, 3] = 0;
86
-
87
-
88
-
89
- m[1, 0] = 0;
90
-
91
- m[1, 1] = 2 * script.Fy / script.ImageHeight;
92
-
93
- m[1, 2] = -1 + 2 * script.Cy / script.ImageHeight;
94
-
95
- m[1, 3] = 0;
96
-
97
-
98
-
99
- m[2, 0] = 0;
100
-
101
- m[2, 1] = 0;
102
-
103
- m[2, 2] = -(script.Far + script.Near) / (script.Far - script.Near);
104
-
105
- m[2, 3] = -2 * script.Far * script.Near / (script.Far - script.Near);
106
-
107
-
108
-
109
- m[3, 0] = 0;
110
-
111
- m[3, 1] = 0;
112
-
113
- m[3, 2] = -1;
114
-
115
- m[3, 3] = 0;
116
-
117
- return m;
118
-
119
- }
120
-
121
- }
122
18
 
123
19
 
124
20