@@ -22,6 +22,7 @@ enum Source2MatHelperClassNamePreset : int
22
22
WebCamTexture2MatHelper = 0 ,
23
23
VideoCapture2MatHelper ,
24
24
Image2MatHelper ,
25
+ AsyncGPUReadback2MatHelper ,
25
26
}
26
27
27
28
Source2MatHelperClassNamePreset requestedSource2MatHelperClassName = Source2MatHelperClassNamePreset . WebCamTexture2MatHelper ;
@@ -36,6 +37,14 @@ enum Source2MatHelperClassNamePreset : int
36
37
/// </summary>
37
38
public Dropdown requestedSource2MatHelperClassNameDropdown ;
38
39
40
+ //
41
+ /// <summary>
42
+ /// The cube.
43
+ /// </summary>
44
+ [ Space ( 10 ) ]
45
+ public GameObject cube ;
46
+ //
47
+
39
48
/// <summary>
40
49
/// The texture.
41
50
/// </summary>
@@ -118,6 +127,9 @@ public void OnSourceToMatHelperInitialized()
118
127
fpsMonitor . Add ( "image path" , helper . requestedImageFilePath . ToString ( ) ) ;
119
128
fpsMonitor . Add ( "repeat" , helper . repeat . ToString ( ) ) ;
120
129
break ;
130
+ case ITextureSource2MatHelper helper :
131
+ fpsMonitor . Add ( "source texture" , helper . sourceTexture . ToString ( ) ) ;
132
+ break ;
121
133
}
122
134
123
135
if ( multiSourceToMatHelper . source2MatHelper is WebCamTexture2MatHelper webCamHelper )
@@ -192,12 +204,32 @@ void Update()
192
204
// Retrieve the current frame as a Mat object
193
205
Mat rgbaMat = multiSourceToMatHelper . GetMat ( ) ;
194
206
207
+ switch ( requestedSource2MatHelperClassName )
208
+ {
209
+ case Source2MatHelperClassNamePreset . WebCamTexture2MatHelper :
210
+ Imgproc . putText ( rgbaMat , "WebCamTexture => Mat" , new Point ( 5 , 30 ) , Imgproc . FONT_HERSHEY_SIMPLEX , 0.7 , new Scalar ( 255 , 255 , 255 , 255 ) , 2 , Imgproc . LINE_AA , false ) ;
211
+ break ;
212
+ case Source2MatHelperClassNamePreset . VideoCapture2MatHelper :
213
+ Imgproc . putText ( rgbaMat , "Video File => Mat" , new Point ( 5 , 30 ) , Imgproc . FONT_HERSHEY_SIMPLEX , 0.7 , new Scalar ( 255 , 255 , 255 , 255 ) , 2 , Imgproc . LINE_AA , false ) ;
214
+ break ;
215
+ case Source2MatHelperClassNamePreset . Image2MatHelper :
216
+ Imgproc . putText ( rgbaMat , "Image File => Mat" , new Point ( 5 , 30 ) , Imgproc . FONT_HERSHEY_SIMPLEX , 0.7 , new Scalar ( 255 , 255 , 255 , 255 ) , 2 , Imgproc . LINE_AA , false ) ;
217
+ break ;
218
+ case Source2MatHelperClassNamePreset . AsyncGPUReadback2MatHelper :
219
+ Imgproc . putText ( rgbaMat , "Camera => RenderTexture => Mat" , new Point ( 5 , 30 ) , Imgproc . FONT_HERSHEY_SIMPLEX , 0.7 , new Scalar ( 255 , 255 , 255 , 255 ) , 2 , Imgproc . LINE_AA , false ) ;
220
+ break ;
221
+ }
222
+
195
223
// Add text overlay on the frame
196
- // Imgproc.putText (rgbaMat, "W:" + rgbaMat.width () + " H:" + rgbaMat.height () + " SO:" + Screen.orientation, new Point (5, rgbaMat.rows () - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar (255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
224
+ Imgproc . putText ( rgbaMat , "W:" + rgbaMat . width ( ) + " H:" + rgbaMat . height ( ) + " SO:" + Screen . orientation , new Point ( 5 , rgbaMat . rows ( ) - 10 ) , Imgproc . FONT_HERSHEY_SIMPLEX , 1.0 , new Scalar ( 255 , 255 , 255 , 255 ) , 2 , Imgproc . LINE_AA , false ) ;
197
225
198
226
// Convert the Mat to a Texture2D to display it on a texture
199
227
Utils . matToTexture2D ( rgbaMat , texture ) ;
200
228
}
229
+
230
+ //
231
+ cube . transform . Rotate ( new Vector3 ( 90 , 90 , 0 ) * Time . deltaTime , Space . Self ) ;
232
+ //
201
233
}
202
234
203
235
/// <summary>
@@ -270,6 +302,9 @@ public void OnRequestedSource2MatHelperClassNameDropdownValueChanged(int result)
270
302
case Source2MatHelperClassNamePreset . Image2MatHelper :
271
303
multiSourceToMatHelper . requestedSource2MatHelperClassName = MultiSource2MatHelperClassName . Image2MatHelper ;
272
304
break ;
305
+ case Source2MatHelperClassNamePreset . AsyncGPUReadback2MatHelper :
306
+ multiSourceToMatHelper . requestedSource2MatHelperClassName = MultiSource2MatHelperClassName . AsyncGPUReadback2MatHelper ;
307
+ break ;
273
308
}
274
309
275
310
// Way to perform different processing depending on the interface inherited by the helper class.
0 commit comments