-
Notifications
You must be signed in to change notification settings - Fork 0
/
CVCanvasUtils.cs
126 lines (69 loc) · 1.85 KB
/
CVCanvasUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using UnityEngine;
using System.Collections;
using OpenCVForUnity;
using CVStereoVision;
/*
*
*
*
*
*
*
*
*
*
*
*
* */
namespace CVStereoVision{
public class CVCanvasUtils{
Mat canvasSRTMat = Mat.zeros(3,3,CvType.CV_32FC1);
Vector3 translationVec;
Vector3 rotationVec;
Vector3 scaleVec;
// method for initializing SRT values from Matrix to Vectors
void initSRTMat(Mat srtMat){
translationVec = getTranslationVec (srtMat);
rotationVec = getRotationVec (srtMat);
scaleVec = getScaleVec (srtMat);
}
GameObject createCamCanvas(Mat srtMat){
GameObject newCanvas = new GameObject ();
return newCanvas;
}
public void transformCanvas(Mat transformMat){
}
public GameObject createMonoCamCanvas(Mat srtMat){
GameObject monoCamCanvas = new GameObject ();
return monoCamCanvas;
}
public GameObject createStereoCamCanvas(Mat srtMat){
GameObject stereoCamCanvas = new GameObject ();
return stereoCamCanvas;
}
// stores translation values from SRT Matrix to Vector
Vector3 getTranslationVec(Mat srtMat){
Vector3 transVec;
transVec.x = (float)srtMat.get (0, 0) [0];
transVec.y = (float)srtMat.get (0, 1) [0];
transVec.z = (float)srtMat.get (0, 2) [0];
return transVec;
}
// stores rotation values from SRT Matrix to Vector
Vector3 getRotationVec(Mat srtMat){
Vector3 rotVec;
rotVec.x = (float)srtMat.get (1, 0) [0];
rotVec.y = (float)srtMat.get (1, 1) [0];
rotVec.z = (float)srtMat.get (1, 2) [0];
return rotVec;
}
// stores scale values from SRT Matrix to Vector
Vector3 getScaleVec(Mat srtMat){
Vector3 scaleVec;
scaleVec.x = (float)srtMat.get (2, 0) [0];
scaleVec.y = (float)srtMat.get (2, 1) [0];
scaleVec.z = (float)srtMat.get (2, 2) [0];
return scaleVec;
}
}
}