comparison python/storage.py @ 393:eaf7765221d9

added code to create bounding boxes and display them (inc scripts)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 26 Jul 2013 02:12:08 -0400
parents 12be4a0cb9aa
children 6567fee37c16
comparison
equal deleted inserted replaced
392:dd4970f4221f 393:eaf7765221d9
305 except sqlite3.OperationalError as error: 305 except sqlite3.OperationalError as error:
306 utils.printDBError(error) 306 utils.printDBError(error)
307 connection.commit() 307 connection.commit()
308 connection.close() 308 connection.close()
309 309
310 def loadBoundingBoxTable(filename):
311 connection = sqlite3.connect(filename)
312 cursor = connection.cursor()
313 boundingBoxes = {} # list of bounding boxes for each instant
314 try:
315 cursor.execute('SELECT name FROM sqlite_master WHERE type=\'table\' AND name=\'boundingbox\'')
316 result = [row for row in cursor]
317 if len(result) > 0:
318 cursor.execute('SELECT * FROM boundingbox')
319 #objId = -1
320 for row in cursor:
321 #if row[0] != objId:
322 boundingBoxes.setdefault(row[1], []).append([moving.Point(row[2], row[3]), moving.Point(row[4], row[5])])
323 except sqlite3.OperationalError as error:
324 utils.printDBError(error)
325 return boundingBoxes
326 connection.close()
327 return boundingBoxes
328
329
310 ######################### 330 #########################
311 # txt files 331 # txt files
312 ######################### 332 #########################
313 333
314 def loadTrajectoriesFromNgsimFile(filename, nObjects = -1, sequenceNum = -1): 334 def loadTrajectoriesFromNgsimFile(filename, nObjects = -1, sequenceNum = -1):