-
Notifications
You must be signed in to change notification settings - Fork 0
/
TracePoints.cs
88 lines (54 loc) · 1.9 KB
/
TracePoints.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OpenCVForUnity;
using System;
public class TracePoints : MonoBehaviour {
private OpenCVUpdateLoop openCVUpdateLoop;
private writeDataToFile dataFileClass;
[SerializeField]
private long MaxParticles = 120000;
[SerializeField]
private VideoPlayerManager videoManager;
List<TracerData> Tracers0;
List<TracerData> TracerRecord;
void Awake(){
openCVUpdateLoop = GetComponent<OpenCVUpdateLoop> ();
dataFileClass = GetComponent<writeDataToFile> ();
CreateStorgaeForTracers ();
}
public void KillDisplayTracers(){
Tracers0 = new List<TracerData> ();
}
public void CreateStorgaeForTracers(){
Tracers0 = new List<TracerData> ();
TracerRecord = new List<TracerData> ();
}
public void AddTracersToStorage (Point pt, Point pt2, Scalar hueColor, Scalar newColor, long frame, float angle, float speed){
Tracers0.Add (new TracerData(pt, pt2, hueColor, newColor, frame, angle, speed));
TracerRecord.Add (new TracerData(pt, pt2, hueColor, newColor, frame, angle, speed));
}
public void AddTracersToMat(Mat DisplayMat, long CurrentVideoFrame){
int iCurrentIndex = 0;
foreach(TracerData T in Tracers0){
openCVUpdateLoop.RenderTracerToScreen (T.mPt, T.mPt2, T.mHue, T.mNew);
iCurrentIndex++;
}
if (Tracers0.Count > MaxParticles) {
Tracers0.RemoveRange (0, 6000);
}
//Tracers0.Clear ();
}
public void FinishedRecordingGiveMeAllTheTracers(){
int iCurrentIndex = 0;
dataFileClass.StartWritingDtata (videoManager.sURL_Video + ".csv");
foreach(TracerData T in TracerRecord){
//Call a function to write to file
dataFileClass.WriteDataFile(T.mPt, T.mPt2, T.mHue, T.mNew, T.mFrame, T.mAngle, T.mSpeed);
//openCVUpdateLoop.RenderTracerToScreen (T.mPt, T.mPt2, T.mHue);
iCurrentIndex++;
}
dataFileClass.StopWritingDtata ();
Debug.Log ("Finished passing data");
}
}