Mercurial Hosting > traffic-intelligence
comparison python/storage.py @ 861:f9c9457b60c2
modification of storage of intrinsic camera and distortion parameters
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 04 Nov 2016 11:47:42 -0400 |
parents | 33d296984dd8 |
children | 2d6249fe905a |
comparison
equal
deleted
inserted
replaced
860:07c5eab11eba | 861:f9c9457b60c2 |
---|---|
435 connection.close() | 435 connection.close() |
436 return objects | 436 return objects |
437 | 437 |
438 def deleteFromSqlite(filename, dataType): | 438 def deleteFromSqlite(filename, dataType): |
439 'Deletes (drops) some tables in the filename depending on type of data' | 439 'Deletes (drops) some tables in the filename depending on type of data' |
440 import os | 440 if path.isfile(filename): |
441 if os.path.isfile(filename): | |
442 connection = sqlite3.connect(filename) | 441 connection = sqlite3.connect(filename) |
443 if dataType == 'object': | 442 if dataType == 'object': |
444 dropTables(connection, ['objects', 'objects_features']) | 443 dropTables(connection, ['objects', 'objects_features']) |
445 elif dataType == 'interaction': | 444 elif dataType == 'interaction': |
446 dropTables(connection, ['interactions', 'indicators']) | 445 dropTables(connection, ['interactions', 'indicators']) |
1256 def loadConfigFile(self, filename): | 1255 def loadConfigFile(self, filename): |
1257 from ConfigParser import ConfigParser | 1256 from ConfigParser import ConfigParser |
1258 | 1257 |
1259 config = ConfigParser() | 1258 config = ConfigParser() |
1260 config.readfp(FakeSecHead(openCheck(filename))) | 1259 config.readfp(FakeSecHead(openCheck(filename))) |
1260 # check if path contains directory names | |
1261 dirname = path.split(filename)[0] | |
1262 | |
1261 self.sectionHeader = config.sections()[0] | 1263 self.sectionHeader = config.sections()[0] |
1262 # Tracking/display parameters | 1264 # Tracking/display parameters |
1263 self.videoFilename = config.get(self.sectionHeader, 'video-filename') | 1265 self.videoFilename = config.get(self.sectionHeader, 'video-filename') |
1264 self.databaseFilename = config.get(self.sectionHeader, 'database-filename') | 1266 self.databaseFilename = config.get(self.sectionHeader, 'database-filename') |
1265 self.homographyFilename = config.get(self.sectionHeader, 'homography-filename') | 1267 self.homographyFilename = config.get(self.sectionHeader, 'homography-filename') |
1266 if (path.exists(self.homographyFilename)): | 1268 if (path.exists(self.homographyFilename)): |
1267 self.homography = loadtxt(self.homographyFilename) | 1269 self.homography = loadtxt(self.homographyFilename) |
1268 else: | 1270 else: |
1269 self.homography = None | 1271 self.homography = None |
1270 self.intrinsicCameraFilename = config.get(self.sectionHeader, 'intrinsic-camera-filename') | 1272 self.intrinsicCameraFilename = config.get(self.sectionHeader, 'intrinsic-camera-filename') |
1271 if (path.exists(self.intrinsicCameraFilename)): | 1273 if (path.exists(dirname+path.sep+self.intrinsicCameraFilename)): |
1272 self.intrinsicCameraMatrix = loadtxt(self.intrinsicCameraFilename) | 1274 self.intrinsicCameraMatrix = loadtxt(dirname+path.sep+self.intrinsicCameraFilename) |
1273 else: | 1275 else: |
1274 self.intrinsicCameraMatrix = None | 1276 self.intrinsicCameraMatrix = None |
1275 distortionCoefficients = getValuesFromINIFile(filename, 'distortion-coefficients', '=') | 1277 distortionCoefficients = getValuesFromINIFile(filename, 'distortion-coefficients', '=') |
1276 self.distortionCoefficients = [float(x) for x in distortionCoefficients] | 1278 self.distortionCoefficients = [float(x) for x in distortionCoefficients] |
1277 self.undistortedImageMultiplication = config.getfloat(self.sectionHeader, 'undistorted-size-multiplication') | 1279 self.undistortedImageMultiplication = config.getfloat(self.sectionHeader, 'undistorted-size-multiplication') |