Mercurial Hosting > traffic-intelligence
changeset 422:67c7ff5d6b26
added new fields for units, getting filenames
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 21 Oct 2013 18:16:33 -0400 |
parents | 4fce27946c60 |
children | f738fa1b69f0 |
files | python/metadata.py |
diffstat | 1 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/python/metadata.py Wed Oct 09 23:25:51 2013 -0400 +++ b/python/metadata.py Mon Oct 21 18:16:33 2013 -0400 @@ -1,6 +1,7 @@ # from moving import Point from datetime import datetime +from os import path from sqlalchemy import Column, Integer, Float, DateTime, String, ForeignKey from sqlalchemy.orm import relationship, backref @@ -24,6 +25,9 @@ self.xcoordinate = xcoordinate self.ycoordinate = ycoordinate + def getFilename(self): + return self.name + # def __repr__(self): # return "<User('%s','%s', '%s')>" % (self.name, self.fullname, self.password) @@ -52,23 +56,32 @@ __tablename__ = 'camera_views' id = Column(Integer, primary_key=True) frameRate = Column(Float) - homographyFilename = Column(String) # path to homograph filename, relative to SiteId + homographyFilename = Column(String) # path to homograph filename, relative to the site name + cameraCalibrationFilename = Column(String) # path to full camera calibration, relative to the site name siteId = Column(Integer, ForeignKey('sites.id')) - # add distanceUnit related to homography? + homographyDistanceUnit = Column(String, default = 'm') + # TODO default config filename site = relationship("Site", backref=backref('camera_views', order_by = id)) - def __init__(self, frameRate, homographyFilename, site): + def __init__(self, frameRate, homographyFilename, cameraCalibrationFilename, site): self.frameRate = frameRate self.homographyFilename = homographyFilename self.site = site + def getHomographyFilename(self, relativeToSiteFilename = True): + if relativeToSiteFilename: + return self.site.getFilename()+path.sep+self.homographyFilename + else: + return self.homographyFilename + class VideoSequence(Base): __tablename__ = 'video_sequences' id = Column(Integer, primary_key=True) - name = Column(String) # path that can be composed with the site name + name = Column(String) # path relative to the the site name startTime = Column(DateTime) duration = Column(Float) # video sequence duration + durationUnit = Column(String, default = 's') siteId = Column(Integer, ForeignKey('sites.id')) cameraViewId = Column(Integer, ForeignKey('camera_views.id')) @@ -83,6 +96,14 @@ self.site = site self.cameraView = cameraView + def getVideoSequenceFilename(self, relativeToSiteFilename = True): + if relativeToSiteFilename: + return self.site.getFilename()+path.sep+self.name + else: + return self.name + +# add class for Analysis: foreign key VideoSequenceId, dataFilename, configFilename (get the one from camera view by default), mask? (no, can be referenced in the tracking cfg file) + # class SiteDescription(Base): # list of lines and polygons describing the site, eg for sidewalks, center lines # class Analysis(Base): # parameters necessary for processing the data: free form