Implemented MR feedback
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// This enum is used to identify each of the SignLanguage models
|
||||
/// </summary>
|
||||
public enum ModelIndex
|
||||
{
|
||||
FINGERSPELLING,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -8,6 +9,23 @@ using Unity.Barracuda;
|
||||
[CreateAssetMenu(menuName = "Create new Scriptable/ModelList")]
|
||||
public class ModelList : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Small class to link a model to a courseIndex irrespective of its position in a list
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ModelTuple
|
||||
{
|
||||
/// <summary>
|
||||
/// ModelIndex to which the model corresponds
|
||||
/// </summary>
|
||||
public ModelIndex index;
|
||||
/// <summary>
|
||||
/// The model itself
|
||||
/// </summary>
|
||||
public NNModel model;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index of the currently active model
|
||||
/// </summary>
|
||||
@@ -23,9 +41,10 @@ public class ModelList : ScriptableObject
|
||||
/// </summary>
|
||||
/// <param name="modelIndex">ModelIndex of the model</param>
|
||||
/// <returns>Model associated with this index, null if no model was found</returns>
|
||||
public NNModel GetCurrentModel()
|
||||
public ModelTuple GetCurrentModel()
|
||||
{
|
||||
return models[currentModelIndex].model;
|
||||
//if(currentModelIndex < models.Find)
|
||||
return models.Find(x => x.model == models[currentModelIndex].model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Unity.Barracuda;
|
||||
/// <summary>
|
||||
/// Small class to link a model to a courseIndex irrespective of its position in a list
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ModelTuple
|
||||
{
|
||||
/// <summary>
|
||||
/// ModelIndex to which the model corresponds
|
||||
/// </summary>
|
||||
public ModelIndex index;
|
||||
/// <summary>
|
||||
/// The model itself
|
||||
/// </summary>
|
||||
public NNModel model;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bce8507dcb30db447b69708ad4f5f962
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -26,7 +26,7 @@ public class ModelListTest
|
||||
{
|
||||
ModelIndex value = (ModelIndex)field.GetValue(null);
|
||||
string name = field.Name;
|
||||
ModelTuple model = new ModelTuple();
|
||||
ModelList.ModelTuple model = new ModelList.ModelTuple();
|
||||
// This is all we will need to distinguish
|
||||
model.index = value;
|
||||
|
||||
@@ -36,11 +36,23 @@ public class ModelListTest
|
||||
}
|
||||
}
|
||||
|
||||
public void TestGetCurrentModel()
|
||||
{
|
||||
System.Random random = new System.Random();
|
||||
ModelIndex value = (ModelIndex)random.Next(modelList.models.Count);
|
||||
modelList.SetCurrentModel(value);
|
||||
|
||||
Assert.AreEqual(value, modelList.GetCurrentModel().index);
|
||||
|
||||
// Check if empty model fails gracefully (returns null)
|
||||
Assert.IsNull(ScriptableObject.CreateInstance<ModelList>().GetCurrentModel());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if all courses can be correctly gotten and set as current via SetCurrentCourse
|
||||
/// Check if all models can be correctly set as current via SetCurrentModel
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestGetSetCurrentModel()
|
||||
public void TestSetCurrentModel()
|
||||
{
|
||||
foreach (var field in typeof(ModelIndex).GetFields())
|
||||
{
|
||||
@@ -50,12 +62,16 @@ public class ModelListTest
|
||||
string name = field.Name;
|
||||
modelList.SetCurrentModel(value);
|
||||
|
||||
// Fetch the current course and check if its name is the same as the one we made into the current one
|
||||
ModelTuple m = modelList.models[modelList.currentModelIndex];
|
||||
// Fetch the current model and check if its name is the same as the one we made into the current one
|
||||
ModelList.ModelTuple m = modelList.models[modelList.currentModelIndex];
|
||||
|
||||
Assert.AreEqual(m.index, value);
|
||||
Assert.IsTrue(m.model is NNModel || m.model is null);
|
||||
}
|
||||
}
|
||||
ModelList emptyList = ScriptableObject.CreateInstance<ModelList>();
|
||||
emptyList.SetCurrentModel(ModelIndex.FINGERSPELLING);
|
||||
|
||||
Assert.IsTrue(emptyList.currentModelIndex == -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace Mediapipe.Unity.Tutorial
|
||||
|
||||
// check if model exists at path
|
||||
//var model = ModelLoader.Load(Resources.Load<NNModel>("Models/Fingerspelling/model_A-L"));
|
||||
worker = modelList.GetCurrentModel().CreateWorker();
|
||||
worker = modelList.GetCurrentModel().model.CreateWorker();
|
||||
|
||||
StartCoroutine(SignRecognitionCoroutine());
|
||||
StartCoroutine(MediapipeCoroutine());
|
||||
@@ -223,7 +223,7 @@ namespace Mediapipe.Unity.Tutorial
|
||||
worker?.Dispose();
|
||||
|
||||
// Add a new worker for the new model
|
||||
worker = modelList.GetCurrentModel().CreateWorker();
|
||||
worker = modelList.GetCurrentModel().model.CreateWorker();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user