1 from datetime import datetime
4 path = "/scratch/July-2018/training/"
6 #device = "dlink-plug/self-test"
7 #fileExperiment = "dlink-plug-oct-17-2018.timestamps"
8 #fileDetection = "detection-on-training-device-side"
9 #fileDetection = "detection-on-training-phone-side"
11 device = "arlo-camera/self-test"
12 fileExperiment = "arlo-camera-aug-10-2018.timestamps"
13 fileDetection = "detection-on-training-phone-side"
14 #fileDetection = "detection-on-training-phone-side"
15 TIME_WINDOW = 15 # detection/signature window of 15 seconds
16 #NEG_TIME_WINDOW = -15 # detection/signature window of 15 seconds
18 # Open training timestamps file and store into a list
19 with open(path + device + "/" + fileExperiment, "r") as experiment:
21 for line in experiment:
22 # Format "%m/%d/%Y %I:%M:%S %p"
23 tsE = datetime.strptime(line, "%m/%d/%Y %I:%M:%S %p\n")
24 tsExperimentList.append(tsE)
26 # Open detection timestamps file and store into a list
27 with open(path + device + "/" + fileDetection, "r") as detection:
29 for line in detection:
30 # Format "%b %d, %Y %I:%M:%S %p"
31 tsD = datetime.strptime(line, "%b %d, %Y %I:%M:%S %p\n")
32 tsDetectionList.append(tsD)
34 if (len(tsExperimentList) > len(tsDetectionList)):
35 maxTimestamps = len(tsExperimentList)
37 maxTimestamps = len(tsDetectionList)
41 while i < maxTimestamps:
42 if(len(tsExperimentList) <= i or len(tsDetectionList) <= j):
45 tsE = tsExperimentList[i]
46 tsD = tsDetectionList[j]
47 # Detection is always a bit later than training trigger
50 #print("tsE: " + str(tsE) + " - tsD: " + str(tsD) + " - delta1: " + str(delta1.seconds) + " - delta2: " + str(delta2.seconds))
51 # The following happens when we could detect less triggers than the experiment
52 if (delta1.seconds > TIME_WINDOW and delta2.seconds > TIME_WINDOW):
53 print("Missing trigger at line: " + str(i) + ", t_experiment: " + str(tsE) + " and t_detection: " + str(tsD))
55 # The following should not happen (we have more detected triggers than the experiment)
56 #elif (delta.seconds < NEG_TIME_WINDOW):
57 # print("Mismatch at t_experiment: " + str(tsE) + " and t_detection: " + str(tsD))
62 print("Done parsing: " + str(i) + " lines")