Mercurial Hosting > traffic-intelligence
comparison python/storage.py @ 784:30bd0f2223b7 dev
tweaking curvilinear trajectory loading
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 03 Mar 2016 14:31:13 -0500 |
parents | f1040d739bbf |
children | 180b6b0231c0 |
comparison
equal
deleted
inserted
replaced
783:f1040d739bbf | 784:30bd0f2223b7 |
---|---|
265 cursor.execute('SELECT * from curvilinear_positions order by trajectory_id, frame_number') | 265 cursor.execute('SELECT * from curvilinear_positions order by trajectory_id, frame_number') |
266 except sqlite3.OperationalError as error: | 266 except sqlite3.OperationalError as error: |
267 printDBError(error) | 267 printDBError(error) |
268 return [] | 268 return [] |
269 | 269 |
270 missingObjectNumbers = [] | |
270 objNum = None | 271 objNum = None |
271 for row in cursor: | 272 for row in cursor: |
272 if objNum != row[0]: | 273 if objNum != row[0]: |
273 objNum = row[0] | 274 objNum = row[0] |
274 if objNum < len(objects): | 275 if objNum in objects: |
275 objects[objNum].curvilinearPositions = moving.CurvilinearTrajectory() | 276 objects[objNum].curvilinearPositions = moving.CurvilinearTrajectory() |
276 else: | 277 else: |
277 print('There are more curvilinear trajectories than objects') | 278 missingObjectNumbers.append(objNum) |
278 break | 279 if objNum in objects: |
279 objects[objNum].curvilinearPositions.addPositionSYL(row[2],row[3],row[4]) | 280 objects[objNum].curvilinearPositions.addPositionSYL(row[2],row[3],row[4]) |
281 if len(missingObjectNumbers) > 0: | |
282 print('List of missing objects to attach corresponding curvilinear trajectories: {}'.format(missingObjectNumbers)) | |
280 | 283 |
281 def saveTrajectoriesToSqlite(outputFilename, objects, trajectoryType, withFeatures = False): | 284 def saveTrajectoriesToSqlite(outputFilename, objects, trajectoryType, withFeatures = False): |
282 '''Writes features, ie the trajectories positions (and velocities if exist) | 285 '''Writes features, ie the trajectories positions (and velocities if exist) |
283 with their instants to a specified sqlite file | 286 with their instants to a specified sqlite file |
284 Either feature positions (and velocities if they exist) | 287 Either feature positions (and velocities if they exist) |