-
Notifications
You must be signed in to change notification settings - Fork 0
/
HistoMat2.cs
184 lines (140 loc) · 7.17 KB
/
HistoMat2.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OpenCVForUnity;
using UnityEngine.UI;
public class HistoMat2 : MonoBehaviour {
[SerializeField]
private OpenCVUpdateLoop openCVUpdateLoop2;
[SerializeField]
private RawImage rawHistoImage2;
[SerializeField]
private float xHisto2 = 50.0f;
[SerializeField]
private float yHisto2 = 1000.0f;
[SerializeField]
private float spacing2 = 15.0f;
[SerializeField]
private float heightScaling2 = -10.0f;
[SerializeField]
private int lineThickness2 = 8;
private Mat mat_histo_02;
private Color32[] colors;
private Texture2D inputTexture2D;
private Texture2D outputTexture2D;
// Use this for initialization
void Start () {
mat_histo_02 = new Mat (rawHistoImage2.texture.height, rawHistoImage2.texture.width, CvType.CV_8UC3);
colors = new Color32[(rawHistoImage2.texture.width) * (rawHistoImage2.texture.width)];
inputTexture2D = new Texture2D (rawHistoImage2.texture.width, rawHistoImage2.texture.height, TextureFormat.RGBA32, false);
outputTexture2D = new Texture2D (rawHistoImage2.texture.width, rawHistoImage2.texture.height, TextureFormat.RGBA32, false);
}
// Update is called once per frame
void Update () {
if (openCVUpdateLoop2.Hue0 == null) {
return;
}
//Add Video Texture to rgbaMat
Utils.texture2DToMat (inputTexture2D, mat_histo_02);
Point Point1Fill = new Point(100f, 0f);
Point Point2Fill = new Point(100f, 800f);
Imgproc.line (mat_histo_02, Point1Fill,Point2Fill,new Scalar (0, 0, 0), 1000);
Point Point1 = new Point((double)xHisto2 + spacing2, (double)yHisto2);
Point Point2 = new Point((double)xHisto2 + spacing2, (double)(yHisto2 + (openCVUpdateLoop2.Spe0 * heightScaling2)));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor1, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe1 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor2, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe2 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor3, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe3 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor4, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe4 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor5, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe5 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor6, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe6 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor7, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe7 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor8, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe8 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor9, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe9 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor10, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe10 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor11, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe11 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor12, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe12 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor13, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe13 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor14, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe14 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor15, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe15 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor16, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe16 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor17, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe17 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor18, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe18 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor19, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe19 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor20, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe20 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor21, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe21 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor22, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe22 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor23, lineThickness2);
Point1.x = Point1.x + spacing2;
Point2.x = Point1.x;
Point2.y = (double)(yHisto2 + (openCVUpdateLoop2.Spe23 * heightScaling2));
Imgproc.line (mat_histo_02, Point1,Point2, openCVUpdateLoop2.NewColor24, lineThickness2);
Utils.matToTexture2D (mat_histo_02, outputTexture2D);//rgbaMat
rawHistoImage2.texture = outputTexture2D;
}
}