Mercurial > hg > nsaunier > traffic-intelligence
comparison python/metadata.py @ 830:2a5856961933
first working version of feature merging (works with feature grouping)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 29 Jun 2016 17:56:19 -0400 |
| parents | 14e4ad7c7420 |
| children | 7058a40a4bbc |
comparison
equal
deleted
inserted
replaced
| 829:0ddcc41663f5 | 830:2a5856961933 |
|---|---|
| 230 idx = Column(Integer, primary_key=True) | 230 idx = Column(Integer, primary_key=True) |
| 231 name = Column(String) # path relative to the the site name | 231 name = Column(String) # path relative to the the site name |
| 232 startTime = Column(DateTime) | 232 startTime = Column(DateTime) |
| 233 duration = Column(Interval) # video sequence duration | 233 duration = Column(Interval) # video sequence duration |
| 234 databaseFilename = Column(String) # path relative to the the site name | 234 databaseFilename = Column(String) # path relative to the the site name |
| 235 siteIdx = Column(Integer, ForeignKey('sites.idx')) | |
| 236 cameraViewIdx = Column(Integer, ForeignKey('camera_views.idx')) | 235 cameraViewIdx = Column(Integer, ForeignKey('camera_views.idx')) |
| 237 | 236 |
| 238 site = relationship("Site", backref=backref('video_sequences', order_by = idx)) | |
| 239 cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = idx)) | 237 cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = idx)) |
| 240 | 238 |
| 241 def __init__(self, name, startTime, duration, site, cameraView, databaseFilename = None): | 239 def __init__(self, name, startTime, duration, cameraView, databaseFilename = None): |
| 242 '''startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39 | 240 '''startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39 |
| 243 duration is a timedelta object''' | 241 duration is a timedelta object''' |
| 244 self.name = name | 242 self.name = name |
| 245 if isinstance(startTime, str): | 243 if isinstance(startTime, str): |
| 246 self.startTime = datetime.strptime(startTime, datetimeFormat) | 244 self.startTime = datetime.strptime(startTime, datetimeFormat) |
| 247 else: | 245 else: |
| 248 self.startTime = startTime | 246 self.startTime = startTime |
| 249 self.duration = duration | 247 self.duration = duration |
| 250 self.site = site | |
| 251 self.cameraView = cameraView | 248 self.cameraView = cameraView |
| 252 if databaseFilename is None and len(self.name) > 0: | 249 if databaseFilename is None and len(self.name) > 0: |
| 253 self.databaseFilename = removeExtension(self.name)+'.sqlite' | 250 self.databaseFilename = removeExtension(self.name)+'.sqlite' |
| 254 | 251 |
| 255 def getVideoSequenceFilename(self, relativeToSiteFilename = True): | 252 def getVideoSequenceFilename(self, relativeToSiteFilename = True): |
| 256 if relativeToSiteFilename: | 253 if relativeToSiteFilename: |
| 257 return self.site.getFilename()+path.sep+self.name | 254 return self.cameraView.site.getFilename()+path.sep+self.name |
| 258 else: | 255 else: |
| 259 return self.name | 256 return self.name |
| 257 | |
| 258 def getDatabaseFilename(self, relativeToSiteFilename = True): | |
| 259 if relativeToSiteFilename: | |
| 260 return self.cameraView.site.getFilename()+path.sep+self.databaseFilename | |
| 261 else: | |
| 262 return self.databaseFilename | |
| 260 | 263 |
| 261 def getTimeInterval(self): | 264 def getTimeInterval(self): |
| 262 return TimeInterval(self.startTime, self.startTime+self.duration) | 265 return TimeInterval(self.startTime, self.startTime+self.duration) |
| 263 | 266 |
| 264 def containsInstant(self, instant): | 267 def containsInstant(self, instant): |
