-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriteDataToFile.cs
73 lines (48 loc) · 1.63 KB
/
writeDataToFile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OpenCVForUnity;
using System.IO;
using UnityEngine.UI;
public class writeDataToFile : MonoBehaviour {
//string fileName = Application.dataPath + "/MyFile.txt";
string dir;
string txtname = "output.csv";
string textPath;
StreamWriter writer;
[SerializeField]
private VideoPlayerManager videoManager;
[SerializeField]
private Text txtSuccess;
public void StartWritingDtata (string filename){
dir = Application.dataPath + "/../";
string mDate = ""; //System.DateTime.Now.ToString ();
textPath = Path.Combine(dir, mDate + txtname);
Debug.Log("Writing file: " + textPath);
writer = new StreamWriter (textPath, false);
txtSuccess.text = "Textfile " + textPath + " created sucessfully";
writer.WriteLine("Video path=" + videoManager.sURL_Video);
}
public void StopWritingDtata (){
writer.Flush();
}
public string sReturtnFileURL(){
return textPath;
}
//this gets called when finished recording // need to add parameters eg pt, pt2, angle etc
public void WriteDataFile(Point pt, Point pt2, Scalar hueColor, Scalar newColor, long frame, float angle, float speed){
//save it!!!!
Debug.Log("Saving Frame " + frame);
writer.WriteLine(
"frame" + "," + frame.ToString()
+",point1 x" + "," + pt.x.ToString()
+",point1 y" + "," + pt.y.ToString()
+ ",point2 x" + "," + pt2.x.ToString()
+ ",point2 y" + "," + pt2.y.ToString()
+ ",hueColor" + "," + hueColor.ToString()
+ ",newColor" + "," + newColor.ToString()
+ ",angle" + "," + angle.ToString()
+ ",speed" + "," + speed.ToString()
);
}
}