Skip to content
Snippets Groups Projects
Commit 6859dcef authored by Alexis Iakovenko's avatar Alexis Iakovenko
Browse files

Separate GestureLoader from Gesture class

parent f2d77e9b
Branches
No related tags found
No related merge requests found
...@@ -118,42 +118,14 @@ public class Gesture ...@@ -118,42 +118,14 @@ public class Gesture
Debug.Log ("[VerifyNormalization] furthestDistance: " + furthestDistance); Debug.Log ("[VerifyNormalization] furthestDistance: " + furthestDistance);
} }
public void Load () public void Load()
{ {
StreamReader reader = new StreamReader(directoryPath + name + ".txt"); states = GestureLoader.Load (FullPath ());
CSVOutputGrid csvGrid = CSVReader.SplitCsvGrid (reader.ReadToEnd ()); }
string[,] csvStrings = csvGrid.grid;
//Debug.Log("csvStrings " + name + " length:" + csvGrid.linesLength);
states = new List<GestureState>();
for (int i = 0; i < csvGrid.linesLength; i++)
{
if (i < 2) //dont take 2 first lines into account
continue;
if (csvStrings == null)
break;
//we need timestamp, x, y, z of palm
string[] line = csvStrings[0,i].Split (' ');
//for now we only save the left palm's coordinates
GestureState state = new GestureState ();
state.timestamp = float.Parse(line [0]);
state.position.x = float.Parse(line [1]);
state.position.y = float.Parse(line [2]);
state.position.z = float.Parse(line [3]);
state.rotation.x = float.Parse(line [4]);
state.rotation.y = float.Parse(line [5]);
state.rotation.z = float.Parse(line [6]);
state.rotation.w = float.Parse(line [7]);
states.Add (state);
//Debug.Log(state);
}
reader.Close();
//Debug.Log("Gesture " + name + " loaded."); private string FullPath()
{
return directoryPath + name + ".txt";
} }
public override string ToString () public override string ToString ()
......
using System.Collections;
using System.Collections.Generic;
using System.IO;
public class GestureLoader
{
public static List<GestureState> Load (string fullpath)
{
StreamReader reader = new StreamReader(fullpath);
CSVOutputGrid csvGrid = CSVReader.SplitCsvGrid (reader.ReadToEnd ());
string[,] csvStrings = csvGrid.grid;
List<GestureState> states = new List<GestureState>();
for (int i = 0; i < csvGrid.linesLength; i++)
{
if (i < 2) //dont take 2 first lines into account
continue;
if (csvStrings == null)
break;
//we need timestamp, x, y, z of palm
string[] line = csvStrings[0,i].Split (' ');
//for now we only save the left palm's coordinates
GestureState state = new GestureState ();
state.timestamp = float.Parse(line [0]);
state.position.x = float.Parse(line [1]);
state.position.y = float.Parse(line [2]);
state.position.z = float.Parse(line [3]);
state.rotation.x = float.Parse(line [4]);
state.rotation.y = float.Parse(line [5]);
state.rotation.z = float.Parse(line [6]);
state.rotation.w = float.Parse(line [7]);
states.Add (state);
}
reader.Close();
return states;
}
}
fileFormatVersion: 2
guid: 61939fbdd2bf91345bc9f441d1980429
timeCreated: 1515598830
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment