Skip to content

Commit 71a8654

Browse files
committed
v1.1.0 Updated OpenCVForUnity version to 3.0.0.
1 parent 3ae778e commit 71a8654

38 files changed

+515
-2269
lines changed

Assets/YOLOv8WithOpenCVForUnity/Examples/Scripts/Utils/FpsMonitor/FpsMonitor.cs

Lines changed: 197 additions & 198 deletions
Large diffs are not rendered by default.

Assets/YOLOv8WithOpenCVForUnity/Examples/Scripts/Utils/FpsMonitor/Resources/FpsMonitorCanvas_103.prefab renamed to Assets/YOLOv8WithOpenCVForUnity/Examples/Scripts/Utils/FpsMonitor/Resources/FpsMonitorCanvas_104.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ GameObject:
281281
- component: {fileID: 7224510997022796016}
282282
- component: {fileID: 6277097474618950544}
283283
m_Layer: 0
284-
m_Name: FpsMonitorCanvas_103
284+
m_Name: FpsMonitorCanvas_104
285285
m_TagString: Untagged
286286
m_Icon: {fileID: 0}
287287
m_NavMeshLayer: 0

Assets/YOLOv8WithOpenCVForUnity/Examples/Scripts/Utils/FpsMonitor/Resources/FpsMonitorCanvas_103.prefab.meta renamed to Assets/YOLOv8WithOpenCVForUnity/Examples/Scripts/Utils/FpsMonitor/Resources/FpsMonitorCanvas_104.prefab.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/YOLOv8WithOpenCVForUnity/Examples/YOLOv8ImageClassificationExample/YOLOv8ImageClassificationExample.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
using System.Threading.Tasks;
88
using OpenCVForUnity.CoreModule;
99
using OpenCVForUnity.ImgprocModule;
10-
using OpenCVForUnity.UnityUtils;
11-
using OpenCVForUnity.UnityUtils.Helper;
10+
using OpenCVForUnity.UnityIntegration;
11+
using OpenCVForUnity.UnityIntegration.Helper.Source2Mat;
1212
using UnityEngine;
1313
using UnityEngine.SceneManagement;
1414
using UnityEngine.UI;
@@ -72,7 +72,7 @@ async void Start()
7272
_fpsMonitor = GetComponent<FpsMonitor>();
7373

7474
_multiSource2MatHelper = gameObject.GetComponent<MultiSource2MatHelper>();
75-
_multiSource2MatHelper.outputColorFormat = Source2MatHelperColorFormat.RGBA;
75+
_multiSource2MatHelper.OutputColorFormat = Source2MatHelperColorFormat.RGBA;
7676

7777
// Update GUI state
7878
#if !UNITY_WEBGL || UNITY_EDITOR
@@ -84,21 +84,21 @@ async void Start()
8484

8585
// Asynchronously retrieves the readable file path from the StreamingAssets directory.
8686
if (_fpsMonitor != null)
87-
_fpsMonitor.consoleText = "Preparing file access...";
87+
_fpsMonitor.ConsoleText = "Preparing file access...";
8888

8989
if (!string.IsNullOrEmpty(_classes))
9090
{
91-
_classes_filepath = await Utils.getFilePathAsyncTask(_classes, cancellationToken: _cts.Token);
91+
_classes_filepath = await OpenCVEnv.GetFilePathTaskAsync(_classes, cancellationToken: _cts.Token);
9292
if (string.IsNullOrEmpty(_classes_filepath)) Debug.Log("The file:" + _classes + " did not exist.");
9393
}
9494
if (!string.IsNullOrEmpty(_model))
9595
{
96-
_model_filepath = await Utils.getFilePathAsyncTask(_model, cancellationToken: _cts.Token);
96+
_model_filepath = await OpenCVEnv.GetFilePathTaskAsync(_model, cancellationToken: _cts.Token);
9797
if (string.IsNullOrEmpty(_model_filepath)) Debug.Log("The file:" + _model + " did not exist.");
9898
}
9999

100100
if (_fpsMonitor != null)
101-
_fpsMonitor.consoleText = "";
101+
_fpsMonitor.ConsoleText = "";
102102

103103
Run();
104104
}
@@ -107,7 +107,7 @@ async void Start()
107107
protected virtual void Run()
108108
{
109109
//if true, The error log of the Native side OpenCV will be displayed on the Unity Editor Console.
110-
Utils.setDebugMode(true);
110+
OpenCVDebug.SetDebugMode(true);
111111

112112

113113
if (string.IsNullOrEmpty(_model_filepath))
@@ -132,7 +132,7 @@ public virtual void OnSourceToMatHelperInitialized()
132132
Mat rgbaMat = _multiSource2MatHelper.GetMat();
133133

134134
_texture = new Texture2D(rgbaMat.cols(), rgbaMat.rows(), TextureFormat.RGBA32, false);
135-
Utils.matToTexture2D(rgbaMat, _texture);
135+
OpenCVMatUtils.MatToTexture2D(rgbaMat, _texture);
136136

137137
_resultPreview.texture = _texture;
138138
_resultPreview.GetComponent<AspectRatioFitter>().aspectRatio = (float)_texture.width / _texture.height;
@@ -177,7 +177,7 @@ public void OnSourceToMatHelperErrorOccurred(Source2MatHelperErrorCode errorCode
177177

178178
if (_fpsMonitor != null)
179179
{
180-
_fpsMonitor.consoleText = "ErrorCode: " + errorCode + ":" + message;
180+
_fpsMonitor.ConsoleText = "ErrorCode: " + errorCode + ":" + message;
181181
}
182182
}
183183

@@ -262,13 +262,13 @@ protected virtual void Update()
262262
{
263263
sb.AppendLine((i + 1) + ". " + _imageClassifier.GetClassLabel(sortedData[i].ClassId) + ", " + sortedData[i].Confidence);
264264
}
265-
_fpsMonitor.consoleText = sb.ToString();
265+
_fpsMonitor.ConsoleText = sb.ToString();
266266
}
267267
}
268268
}
269269
}
270270

271-
Utils.matToTexture2D(rgbaMat, _texture);
271+
OpenCVMatUtils.MatToTexture2D(rgbaMat, _texture);
272272
}
273273
}
274274

@@ -281,7 +281,7 @@ protected virtual void OnDestroy()
281281

282282
_imageClassifier?.Dispose();
283283

284-
Utils.setDebugMode(false);
284+
OpenCVDebug.SetDebugMode(false);
285285

286286
_cts?.Dispose();
287287
}
@@ -323,7 +323,7 @@ public virtual void OnStopButtonClick()
323323
/// </summary>
324324
public virtual void OnChangeCameraButtonClick()
325325
{
326-
_multiSource2MatHelper.requestedIsFrontFacing = !_multiSource2MatHelper.requestedIsFrontFacing;
326+
_multiSource2MatHelper.RequestedIsFrontFacing = !_multiSource2MatHelper.RequestedIsFrontFacing;
327327
}
328328

329329
/// <summary>
@@ -369,4 +369,4 @@ private void ProcessMainThreadQueue()
369369
}
370370
}
371371
}
372-
#endif
372+
#endif

Assets/YOLOv8WithOpenCVForUnity/Examples/YOLOv8ImageClassificationExample/YOLOv8ImageClassificationExample.unity

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,13 +1201,13 @@ MonoBehaviour:
12011201
m_Script: {fileID: 11500000, guid: 005dcf28c3a6b0a4bb956de333760d9c, type: 3}
12021202
m_Name:
12031203
m_EditorClassIdentifier:
1204-
alignment: 1
1205-
offset: {x: 10, y: 10}
1206-
boxVisible: 1
1207-
boxWidth: 200
1208-
boxHeight: 100
1209-
padding: {x: 10, y: 10}
1210-
consoleHeight: 230
1204+
AlignmentSetting: 1
1205+
Offset: {x: 10, y: 10}
1206+
BoxVisible: 1
1207+
BoxWidth: 180
1208+
BoxHeight: 120
1209+
Padding: {x: 10, y: 10}
1210+
ConsoleHeight: 230
12111211
--- !u!114 &1478462782
12121212
MonoBehaviour:
12131213
m_ObjectHideFlags: 0
@@ -1217,31 +1217,34 @@ MonoBehaviour:
12171217
m_GameObject: {fileID: 1478462775}
12181218
m_Enabled: 1
12191219
m_EditorHideFlags: 0
1220-
m_Script: {fileID: 11500000, guid: e564a549956aebc4d9acef3ff91b0981, type: 3}
1220+
m_Script: {fileID: 11500000, guid: e6710d062e27d084c92efbd532befe37, type: 3}
12211221
m_Name:
12221222
m_EditorClassIdentifier:
1223+
_currentSource2MatHelperClassInterfaces: 66
12231224
_requestedSource2MatHelperClassName: 2
1224-
_currentSource2MatHelperClassInterfaces: 2
12251225
_requestedDeviceName:
12261226
_requestedWidth: 640
12271227
_requestedHeight: 480
12281228
_requestedIsFrontFacing: 0
12291229
_requestedFPS: 30
1230-
_requestedMatUpdateFPS: 30
1231-
_requestedVideoFilePath: YOLOv8WithOpenCVForUnityExample\TestVideos\6130363-sd_960_540_30fps.mp4
1230+
_requestedVideoFilePath: YOLOv8WithOpenCVForUnityExample/TestVideos/6130363-sd_960_540_30fps.mp4
12321231
_loop: 1
12331232
_requestedImageFilePath: YOLOv8WithOpenCVForUnityExample/TestImages/adpDSC_2397_1280.jpg
12341233
_repeat: 1
12351234
_sourceTexture: {fileID: 0}
1235+
_requestedMatUpdateFPS: 30
1236+
_rotate90Degree: 0
1237+
_flipVertical: 0
1238+
_flipHorizontal: 0
12361239
_customClassComponent: {fileID: 0}
12371240
_outputColorFormat: 3
12381241
_timeoutFrameCount: 1500
12391242
_onInitialized:
12401243
m_PersistentCalls:
12411244
m_Calls:
12421245
- m_Target: {fileID: 1478462776}
1243-
m_TargetAssemblyTypeName: YOLOv8WithOpenCVForUnityExample.YOLOv8ClassificationExample,
1244-
Assembly-CSharp
1246+
m_TargetAssemblyTypeName: YOLOv8WithOpenCVForUnityExample.YOLOv8ImageClassificationExample,
1247+
EnoxSoftware.YOLOv8WithOpenCVForUnity
12451248
m_MethodName: OnSourceToMatHelperInitialized
12461249
m_Mode: 1
12471250
m_Arguments:
@@ -1256,8 +1259,8 @@ MonoBehaviour:
12561259
m_PersistentCalls:
12571260
m_Calls:
12581261
- m_Target: {fileID: 1478462776}
1259-
m_TargetAssemblyTypeName: YOLOv8WithOpenCVForUnityExample.YOLOv8ClassificationExample,
1260-
Assembly-CSharp
1262+
m_TargetAssemblyTypeName: YOLOv8WithOpenCVForUnityExample.YOLOv8ImageClassificationExample,
1263+
EnoxSoftware.YOLOv8WithOpenCVForUnity
12611264
m_MethodName: OnSourceToMatHelperDisposed
12621265
m_Mode: 1
12631266
m_Arguments:
@@ -1272,8 +1275,8 @@ MonoBehaviour:
12721275
m_PersistentCalls:
12731276
m_Calls:
12741277
- m_Target: {fileID: 1478462776}
1275-
m_TargetAssemblyTypeName: YOLOv8WithOpenCVForUnityExample.YOLOv8ClassificationExample,
1276-
Assembly-CSharp
1278+
m_TargetAssemblyTypeName: YOLOv8WithOpenCVForUnityExample.YOLOv8ImageClassificationExample,
1279+
EnoxSoftware.YOLOv8WithOpenCVForUnity
12771280
m_MethodName: OnSourceToMatHelperErrorOccurred
12781281
m_Mode: 0
12791282
m_Arguments:

Assets/YOLOv8WithOpenCVForUnity/Examples/YOLOv8InstanceSegmentationExample/YOLOv8InstanceSegmentationExample.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
using System.Threading.Tasks;
77
using OpenCVForUnity.CoreModule;
88
using OpenCVForUnity.ImgprocModule;
9-
using OpenCVForUnity.UnityUtils;
10-
using OpenCVForUnity.UnityUtils.Helper;
9+
using OpenCVForUnity.UnityIntegration;
10+
using OpenCVForUnity.UnityIntegration.Helper.Source2Mat;
1111
using UnityEngine;
1212
using UnityEngine.SceneManagement;
1313
using UnityEngine.UI;
@@ -82,7 +82,7 @@ async void Start()
8282
_fpsMonitor = GetComponent<FpsMonitor>();
8383

8484
_multiSource2MatHelper = gameObject.GetComponent<MultiSource2MatHelper>();
85-
_multiSource2MatHelper.outputColorFormat = Source2MatHelperColorFormat.RGBA;
85+
_multiSource2MatHelper.OutputColorFormat = Source2MatHelperColorFormat.RGBA;
8686

8787
// Update GUI state
8888
#if !UNITY_WEBGL || UNITY_EDITOR
@@ -94,21 +94,21 @@ async void Start()
9494

9595
// Asynchronously retrieves the readable file path from the StreamingAssets directory.
9696
if (_fpsMonitor != null)
97-
_fpsMonitor.consoleText = "Preparing file access...";
97+
_fpsMonitor.ConsoleText = "Preparing file access...";
9898

9999
if (!string.IsNullOrEmpty(_classes))
100100
{
101-
_classes_filepath = await Utils.getFilePathAsyncTask(_classes, cancellationToken: _cts.Token);
101+
_classes_filepath = await OpenCVEnv.GetFilePathTaskAsync(_classes, cancellationToken: _cts.Token);
102102
if (string.IsNullOrEmpty(_classes_filepath)) Debug.Log("The file:" + _classes + " did not exist.");
103103
}
104104
if (!string.IsNullOrEmpty(_model))
105105
{
106-
_model_filepath = await Utils.getFilePathAsyncTask(_model, cancellationToken: _cts.Token);
106+
_model_filepath = await OpenCVEnv.GetFilePathTaskAsync(_model, cancellationToken: _cts.Token);
107107
if (string.IsNullOrEmpty(_model_filepath)) Debug.Log("The file:" + _model + " did not exist.");
108108
}
109109

110110
if (_fpsMonitor != null)
111-
_fpsMonitor.consoleText = "";
111+
_fpsMonitor.ConsoleText = "";
112112

113113
Run();
114114
}
@@ -117,7 +117,7 @@ async void Start()
117117
protected virtual void Run()
118118
{
119119
//if true, The error log of the Native side OpenCV will be displayed on the Unity Editor Console.
120-
Utils.setDebugMode(true);
120+
OpenCVDebug.SetDebugMode(true);
121121

122122

123123
if (string.IsNullOrEmpty(_model_filepath))
@@ -142,7 +142,7 @@ public virtual void OnSourceToMatHelperInitialized()
142142
Mat rgbaMat = _multiSource2MatHelper.GetMat();
143143

144144
_texture = new Texture2D(rgbaMat.cols(), rgbaMat.rows(), TextureFormat.RGBA32, false);
145-
Utils.matToTexture2D(rgbaMat, _texture);
145+
OpenCVMatUtils.MatToTexture2D(rgbaMat, _texture);
146146

147147
_resultPreview.texture = _texture;
148148
_resultPreview.GetComponent<AspectRatioFitter>().aspectRatio = (float)_texture.width / _texture.height;
@@ -188,7 +188,7 @@ public void OnSourceToMatHelperErrorOccurred(Source2MatHelperErrorCode errorCode
188188

189189
if (_fpsMonitor != null)
190190
{
191-
_fpsMonitor.consoleText = "ErrorCode: " + errorCode + ":" + message;
191+
_fpsMonitor.ConsoleText = "ErrorCode: " + errorCode + ":" + message;
192192
}
193193
}
194194

@@ -274,7 +274,7 @@ void Update()
274274
}
275275
}
276276

277-
Utils.matToTexture2D(rgbaMat, _texture);
277+
OpenCVMatUtils.MatToTexture2D(rgbaMat, _texture);
278278
}
279279
}
280280

@@ -287,7 +287,7 @@ protected virtual void OnDestroy()
287287

288288
_instanceSegmenter?.Dispose();
289289

290-
Utils.setDebugMode(false);
290+
OpenCVDebug.SetDebugMode(false);
291291

292292
_cts?.Dispose();
293293
}
@@ -329,7 +329,7 @@ public virtual void OnStopButtonClick()
329329
/// </summary>
330330
public virtual void OnChangeCameraButtonClick()
331331
{
332-
_multiSource2MatHelper.requestedIsFrontFacing = !_multiSource2MatHelper.requestedIsFrontFacing;
332+
_multiSource2MatHelper.RequestedIsFrontFacing = !_multiSource2MatHelper.RequestedIsFrontFacing;
333333
}
334334

335335
/// <summary>
@@ -375,4 +375,4 @@ private void ProcessMainThreadQueue()
375375
}
376376
}
377377
}
378-
#endif
378+
#endif

0 commit comments

Comments
 (0)