Updated getter in ModelList and cleaned Assembly

This commit is contained in:
CoudronJerome
2023-03-28 08:52:02 +02:00
parent be7457236c
commit dfdb2ab10b
4 changed files with 8 additions and 25 deletions

View File

@@ -23,9 +23,9 @@ public class ModelList : ScriptableObject
/// </summary> /// </summary>
/// <param name="modelIndex">ModelIndex of the model</param> /// <param name="modelIndex">ModelIndex of the model</param>
/// <returns>Model associated with this index, null if no model was found</returns> /// <returns>Model associated with this index, null if no model was found</returns>
public NNModel GetModelByIndex(ModelIndex modelIndex) public NNModel GetCurrentModel()
{ {
return models.Find((m) => m.index == modelIndex).model; return models[currentModelIndex].model;
} }
/// <summary> /// <summary>

View File

@@ -6,8 +6,7 @@
"GUID:63c63e721f65ebb7d871cb9ef49f4752", "GUID:63c63e721f65ebb7d871cb9ef49f4752",
"GUID:1631ed2680c61245b8211d943c1639a8", "GUID:1631ed2680c61245b8211d943c1639a8",
"GUID:5c2b5ba89f9e74e418232e154bc5cc7a", "GUID:5c2b5ba89f9e74e418232e154bc5cc7a",
"GUID:7f2d0ee6dd21e1d4eb25b71b7a749d25", "GUID:7f2d0ee6dd21e1d4eb25b71b7a749d25"
"GUID:d0b6b39a21908f94fbbd9f2c196a9725"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View File

@@ -37,27 +37,10 @@ public class ModelListTest
} }
/// <summary> /// <summary>
/// Check if getModelByIndex returns the NMModel or return null if there is no model /// Check if all courses can be correctly gotten and set as current via SetCurrentCourse
/// </summary> /// </summary>
[Test] [Test]
public void TestGetModelByIndex() public void TestGetSetCurrentModel()
{
foreach (var field in typeof(ModelIndex).GetFields())
{
if (field.IsLiteral)
{
ModelIndex value = (ModelIndex)field.GetValue(null);
string name = field.Name;
Assert.IsTrue(modelList.GetModelByIndex(value) is NNModel || modelList.GetModelByIndex(value) is null);
}
}
}
/// <summary>
/// Check if all courses can be correctly set as current via SetCurrentCourse
/// </summary>
[Test]
public void TestSetCurrentModel()
{ {
foreach (var field in typeof(ModelIndex).GetFields()) foreach (var field in typeof(ModelIndex).GetFields())
{ {
@@ -71,6 +54,7 @@ public class ModelListTest
ModelTuple m = modelList.models[modelList.currentModelIndex]; ModelTuple m = modelList.models[modelList.currentModelIndex];
Assert.AreEqual(m.index, value); Assert.AreEqual(m.index, value);
Assert.IsTrue(m.model is NNModel || m.model is null);
} }
} }
} }

View File

@@ -210,7 +210,7 @@ namespace Mediapipe.Unity.Tutorial
// check if model exists at path // check if model exists at path
//var model = ModelLoader.Load(Resources.Load<NNModel>("Models/Fingerspelling/model_A-L")); //var model = ModelLoader.Load(Resources.Load<NNModel>("Models/Fingerspelling/model_A-L"));
worker = modelList.models[modelList.currentModelIndex].model.CreateWorker(); worker = modelList.GetCurrentModel().CreateWorker();
StartCoroutine(SignRecognitionCoroutine()); StartCoroutine(SignRecognitionCoroutine());
StartCoroutine(MediapipeCoroutine()); StartCoroutine(MediapipeCoroutine());
@@ -223,7 +223,7 @@ namespace Mediapipe.Unity.Tutorial
worker?.Dispose(); worker?.Dispose();
// Add a new worker for the new model // Add a new worker for the new model
worker = modelList.models[modelList.currentModelIndex].model.CreateWorker(); worker = modelList.GetCurrentModel().CreateWorker();
} }
/// <summary> /// <summary>