Changed GetCurrentModel to return the model instead of the tuple
This commit is contained in:
@@ -41,10 +41,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 ModelTuple GetCurrentModel()
|
public NNModel GetCurrentModel()
|
||||||
{
|
{
|
||||||
//if(currentModelIndex < models.Find)
|
return models.Find(x => x.model == models[currentModelIndex].model)?.model;
|
||||||
return models.Find(x => x.model == models[currentModelIndex].model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -35,14 +35,17 @@ public class ModelListTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Check if current model can be correctly gotten as current via GetCurrentModel
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
public void TestGetCurrentModel()
|
public void TestGetCurrentModel()
|
||||||
{
|
{
|
||||||
System.Random random = new System.Random();
|
System.Random random = new System.Random();
|
||||||
ModelIndex value = (ModelIndex)random.Next(modelList.models.Count);
|
ModelIndex value = (ModelIndex)random.Next(modelList.models.Count);
|
||||||
modelList.SetCurrentModel(value);
|
modelList.SetCurrentModel(value);
|
||||||
|
|
||||||
Assert.AreEqual(value, modelList.GetCurrentModel().index);
|
Assert.AreEqual(modelList.models[modelList.currentModelIndex].model, modelList.GetCurrentModel());
|
||||||
|
|
||||||
// Check if empty model fails gracefully (returns null)
|
// Check if empty model fails gracefully (returns null)
|
||||||
Assert.IsNull(ScriptableObject.CreateInstance<ModelList>().GetCurrentModel());
|
Assert.IsNull(ScriptableObject.CreateInstance<ModelList>().GetCurrentModel());
|
||||||
|
|||||||
@@ -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.GetCurrentModel().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.GetCurrentModel().model.CreateWorker();
|
worker = modelList.GetCurrentModel().CreateWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user