Mercurial > hg > nsaunier > traffic-intelligence
comparison python/metadata.py @ 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 | e74a09bddb6d |
comparison
equal
deleted
inserted
replaced
| 421:4fce27946c60 | 422:67c7ff5d6b26 |
|---|---|
| 1 # from moving import Point | 1 # from moving import Point |
| 2 | 2 |
| 3 from datetime import datetime | 3 from datetime import datetime |
| 4 from os import path | |
| 4 | 5 |
| 5 from sqlalchemy import Column, Integer, Float, DateTime, String, ForeignKey | 6 from sqlalchemy import Column, Integer, Float, DateTime, String, ForeignKey |
| 6 from sqlalchemy.orm import relationship, backref | 7 from sqlalchemy.orm import relationship, backref |
| 7 from sqlalchemy.ext.declarative import declarative_base | 8 from sqlalchemy.ext.declarative import declarative_base |
| 8 | 9 |
| 21 def __init__(self, name, description = "", xcoordinate = None, ycoordinate = None): | 22 def __init__(self, name, description = "", xcoordinate = None, ycoordinate = None): |
| 22 self.name = name | 23 self.name = name |
| 23 self.description = description | 24 self.description = description |
| 24 self.xcoordinate = xcoordinate | 25 self.xcoordinate = xcoordinate |
| 25 self.ycoordinate = ycoordinate | 26 self.ycoordinate = ycoordinate |
| 27 | |
| 28 def getFilename(self): | |
| 29 return self.name | |
| 26 | 30 |
| 27 # def __repr__(self): | 31 # def __repr__(self): |
| 28 # return "<User('%s','%s', '%s')>" % (self.name, self.fullname, self.password) | 32 # return "<User('%s','%s', '%s')>" % (self.name, self.fullname, self.password) |
| 29 | 33 |
| 30 class EnvironementalFactors(Base): | 34 class EnvironementalFactors(Base): |
| 50 | 54 |
| 51 class CameraView(Base): | 55 class CameraView(Base): |
| 52 __tablename__ = 'camera_views' | 56 __tablename__ = 'camera_views' |
| 53 id = Column(Integer, primary_key=True) | 57 id = Column(Integer, primary_key=True) |
| 54 frameRate = Column(Float) | 58 frameRate = Column(Float) |
| 55 homographyFilename = Column(String) # path to homograph filename, relative to SiteId | 59 homographyFilename = Column(String) # path to homograph filename, relative to the site name |
| 60 cameraCalibrationFilename = Column(String) # path to full camera calibration, relative to the site name | |
| 56 siteId = Column(Integer, ForeignKey('sites.id')) | 61 siteId = Column(Integer, ForeignKey('sites.id')) |
| 57 # add distanceUnit related to homography? | 62 homographyDistanceUnit = Column(String, default = 'm') |
| 63 # TODO default config filename | |
| 58 | 64 |
| 59 site = relationship("Site", backref=backref('camera_views', order_by = id)) | 65 site = relationship("Site", backref=backref('camera_views', order_by = id)) |
| 60 | 66 |
| 61 def __init__(self, frameRate, homographyFilename, site): | 67 def __init__(self, frameRate, homographyFilename, cameraCalibrationFilename, site): |
| 62 self.frameRate = frameRate | 68 self.frameRate = frameRate |
| 63 self.homographyFilename = homographyFilename | 69 self.homographyFilename = homographyFilename |
| 64 self.site = site | 70 self.site = site |
| 65 | 71 |
| 72 def getHomographyFilename(self, relativeToSiteFilename = True): | |
| 73 if relativeToSiteFilename: | |
| 74 return self.site.getFilename()+path.sep+self.homographyFilename | |
| 75 else: | |
| 76 return self.homographyFilename | |
| 77 | |
| 66 class VideoSequence(Base): | 78 class VideoSequence(Base): |
| 67 __tablename__ = 'video_sequences' | 79 __tablename__ = 'video_sequences' |
| 68 id = Column(Integer, primary_key=True) | 80 id = Column(Integer, primary_key=True) |
| 69 name = Column(String) # path that can be composed with the site name | 81 name = Column(String) # path relative to the the site name |
| 70 startTime = Column(DateTime) | 82 startTime = Column(DateTime) |
| 71 duration = Column(Float) # video sequence duration | 83 duration = Column(Float) # video sequence duration |
| 84 durationUnit = Column(String, default = 's') | |
| 72 siteId = Column(Integer, ForeignKey('sites.id')) | 85 siteId = Column(Integer, ForeignKey('sites.id')) |
| 73 cameraViewId = Column(Integer, ForeignKey('camera_views.id')) | 86 cameraViewId = Column(Integer, ForeignKey('camera_views.id')) |
| 74 | 87 |
| 75 site = relationship("Site", backref=backref('video_sequences', order_by = id)) | 88 site = relationship("Site", backref=backref('video_sequences', order_by = id)) |
| 76 cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = id)) | 89 cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = id)) |
| 81 self.startTime = datetime.strptime(startTime, datetimeFormat) | 94 self.startTime = datetime.strptime(startTime, datetimeFormat) |
| 82 self.duration = duration | 95 self.duration = duration |
| 83 self.site = site | 96 self.site = site |
| 84 self.cameraView = cameraView | 97 self.cameraView = cameraView |
| 85 | 98 |
| 99 def getVideoSequenceFilename(self, relativeToSiteFilename = True): | |
| 100 if relativeToSiteFilename: | |
| 101 return self.site.getFilename()+path.sep+self.name | |
| 102 else: | |
| 103 return self.name | |
| 104 | |
| 105 # 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) | |
| 106 | |
| 86 # class SiteDescription(Base): # list of lines and polygons describing the site, eg for sidewalks, center lines | 107 # class SiteDescription(Base): # list of lines and polygons describing the site, eg for sidewalks, center lines |
| 87 | 108 |
| 88 # class Analysis(Base): # parameters necessary for processing the data: free form | 109 # class Analysis(Base): # parameters necessary for processing the data: free form |
| 89 # eg bounding box depends on camera view, tracking configuration depends on camera view | 110 # eg bounding box depends on camera view, tracking configuration depends on camera view |
| 90 | 111 |
