def prepTruthData(dataPath, numFrames, normalizeData=False):
"""
Get and preprocess the ground truth drive speeds data.
Args:
dataPath: (str) Path to JSON of ground truths.
numFrames: (int) Number of timesteps to interpolate the data to.
normalizeData: (bool) Normalize the data to [0,1].
Returns:
(list) Linearly interpolated truth values, one for each timestep.
"""
with open(dataPath, "rb") as infile:
driveData = json.load(infile)
# Prep data: make sure it's in order, and use relative position (b/c seconds
# values may be incorrect)
driveData.sort(key = lambda x: x[0])
times = np.zeros(len(driveData))
speeds = np.zeros(len(driveData))
for i, (time, speed) in enumerate(driveData):
times[i] = time
speeds[i] = speed
positions = (times - times.min()) / (times.max() - times.min())
if normalizeData:
speeds = normalize(speeds)
# Linearly interpolate the data to the number of video frames
return np.interp(np.arange(0.0, 1.0, 1.0/numFrames), positions, speeds)
评论列表
文章目录