comparison python/ubc_utils.py @ 43:6d11d9e7ad4e

methods for trajectories and objects to add and subtract trajectories and extract objects from existing objects, for sub-time intervals
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 14 Jul 2010 14:02:11 -0400
parents 1a2ac2d4f53a
children be3ae926e4e8
comparison
equal deleted inserted replaced
42:1a2ac2d4f53a 43:6d11d9e7ad4e
32 l = lines[0].split(' ') 32 l = lines[0].split(' ')
33 parsedLine = [int(n) for n in l[:4]] 33 parsedLine = [int(n) for n in l[:4]]
34 obj = MovingObject(num = objNum, timeInterval = TimeInterval(parsedLine[1],parsedLine[2])) 34 obj = MovingObject(num = objNum, timeInterval = TimeInterval(parsedLine[1],parsedLine[2]))
35 #add = True 35 #add = True
36 if len(lines) >= 3: 36 if len(lines) >= 3:
37 obj.positions = Trajectory(lines[1], lines[2]) 37 obj.positions = Trajectory.load(lines[1], lines[2])
38 if len(lines) >= 5: 38 if len(lines) >= 5:
39 obj.velocities = Trajectory(lines[3], lines[4]) 39 obj.velocities = Trajectory.load(lines[3], lines[4])
40 if (isObjectFile): 40 if (isObjectFile):
41 obj.userType = parsedLine[3] 41 obj.userType = parsedLine[3]
42 obj.nObjects = float(l[4]) 42 obj.nObjects = float(l[4])
43 obj.featureNumbers = [int(n) for n in l[5:]] 43 obj.featureNumbers = [int(n) for n in l[5:]]
44 44
45 # load contour data if available 45 # load contour data if available
46 if len(lines) >= 6: 46 if len(lines) >= 6:
47 obj.contourType = utils.line2Floats(lines[6]) 47 obj.contourType = utils.line2Floats(lines[6])
48 obj.contourOrigins = Trajectory(lines[7], lines[8]) 48 obj.contourOrigins = Trajectory.load(lines[7], lines[8])
49 obj.contourSizes = Trajectory(lines[9], lines[10]) 49 obj.contourSizes = Trajectory.load(lines[9], lines[10])
50 50
51 if len(lines) != 2: 51 if len(lines) != 2:
52 objects.append(obj) 52 objects.append(obj)
53 objNum+=1 53 objNum+=1
54 else: 54 else: