Mercurial > hg > nsaunier > traffic-intelligence
comparison python/ubc_utils.py @ 42:1a2ac2d4f53a
added loading of the rest of the data for objects
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 01 Jul 2010 10:44:32 -0400 |
| parents | 28e546861263 |
| children | 6d11d9e7ad4e |
comparison
equal
deleted
inserted
replaced
| 41:eb78c6edc0c8 | 42:1a2ac2d4f53a |
|---|---|
| 24 if (not file): | 24 if (not file): |
| 25 return [] | 25 return [] |
| 26 | 26 |
| 27 objects = [] | 27 objects = [] |
| 28 objNum = 0 | 28 objNum = 0 |
| 29 isObjectFile = filename.endswith('objects.txt'); | |
| 29 lines = getLines(file) | 30 lines = getLines(file) |
| 30 while (lines != []) and ((nObjects<0) or (objNum<nObjects)): | 31 while (lines != []) and ((nObjects<0) or (objNum<nObjects)): |
| 31 l = lines[0].split(' ') | 32 l = lines[0].split(' ') |
| 32 parsedLine = [int(n) for n in l[:4]] | 33 parsedLine = [int(n) for n in l[:4]] |
| 33 obj = MovingObject(num = objNum, timeInterval = TimeInterval(parsedLine[1],parsedLine[2])) | 34 obj = MovingObject(num = objNum, timeInterval = TimeInterval(parsedLine[1],parsedLine[2])) |
| 34 add = True | 35 #add = True |
| 35 if (len(lines) >= 3): | 36 if len(lines) >= 3: |
| 36 obj.positions = Trajectory(lines[1], lines[2]) | 37 obj.positions = Trajectory(lines[1], lines[2]) |
| 37 if (len(lines) >= 5): | 38 if len(lines) >= 5: |
| 38 obj.velocities = Trajectory(lines[3], lines[4]) | 39 obj.velocities = Trajectory(lines[3], lines[4]) |
| 40 if (isObjectFile): | |
| 41 obj.userType = parsedLine[3] | |
| 42 obj.nObjects = float(l[4]) | |
| 43 obj.featureNumbers = [int(n) for n in l[5:]] | |
| 44 | |
| 45 # load contour data if available | |
| 46 if len(lines) >= 6: | |
| 47 obj.contourType = utils.line2Floats(lines[6]) | |
| 48 obj.contourOrigins = Trajectory(lines[7], lines[8]) | |
| 49 obj.contourSizes = Trajectory(lines[9], lines[10]) | |
| 39 | 50 |
| 40 if len(lines) != 2: | 51 if len(lines) != 2: |
| 41 objects.append(obj) | 52 objects.append(obj) |
| 42 objNum+=1 | 53 objNum+=1 |
| 43 else: | 54 else: |
