Tested new implementation for models
This commit is contained in:
9
Assets/MediaPipeUnity/Scripts/ModelIndex.cs
Normal file
9
Assets/MediaPipeUnity/Scripts/ModelIndex.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum ModelIndex
|
||||
{
|
||||
FINGERSPELLING,
|
||||
NONE
|
||||
}
|
||||
11
Assets/MediaPipeUnity/Scripts/ModelIndex.cs.meta
Normal file
11
Assets/MediaPipeUnity/Scripts/ModelIndex.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dbd5e1100bc81648b52206df369d0a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/MediaPipeUnity/Scripts/ModelList.cs
Normal file
39
Assets/MediaPipeUnity/Scripts/ModelList.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Unity.Barracuda;
|
||||
/// <summary>
|
||||
/// This scriptable will hold tupples of Courseindices and models
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Create new Scriptable/ModelList")]
|
||||
public class ModelList : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of the currently active model
|
||||
/// </summary>
|
||||
public int currentModelIndex = 0;
|
||||
|
||||
/// <summary>
|
||||
/// A list of all the models
|
||||
/// </summary>
|
||||
public List<ModelTuple> models = new List<ModelTuple>();
|
||||
|
||||
/// <summary>
|
||||
/// Get a model by modelindex
|
||||
/// </summary>
|
||||
/// <param name="modelIndex">ModelIndex of the model</param>
|
||||
/// <returns>Model associated with this index, null if no model was found</returns>
|
||||
public NNModel GetModelByIndex(ModelIndex modelIndex)
|
||||
{
|
||||
return models.Find((m) => m.index == modelIndex).model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to find a model-index in the list based on its index
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
public void SetCurrentModel(ModelIndex index)
|
||||
{
|
||||
currentModelIndex = models.FindIndex((m) => m.index == index);
|
||||
}
|
||||
}
|
||||
11
Assets/MediaPipeUnity/Scripts/ModelList.cs.meta
Normal file
11
Assets/MediaPipeUnity/Scripts/ModelList.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78a3f61c93a08c04496c49ffd10b9021
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/MediaPipeUnity/Scripts/ModelTuple.cs
Normal file
18
Assets/MediaPipeUnity/Scripts/ModelTuple.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
}
|
||||
11
Assets/MediaPipeUnity/Scripts/ModelTuple.cs.meta
Normal file
11
Assets/MediaPipeUnity/Scripts/ModelTuple.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bce8507dcb30db447b69708ad4f5f962
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,6 +18,9 @@ namespace Mediapipe.Unity.Tutorial
|
||||
{
|
||||
public class SignPredictor : MonoBehaviour
|
||||
{
|
||||
|
||||
public ModelList modelList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the model used in the SignPredictor
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user