Mercurial Hosting > traffic-intelligence
diff python/metadata.py @ 420:def795d1120f
first work on video metadata
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 08 Oct 2013 18:26:20 -0400 |
parents | |
children | 4fce27946c60 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/metadata.py Tue Oct 08 18:26:20 2013 -0400 @@ -0,0 +1,62 @@ +# from moving import Point + +from sqlalchemy import create_engine, Column, Integer, Float, DateTime, String, ForeignKey +from sqlalchemy.orm import relationship, backref +from sqlalchemy.ext.declarative import declarative_base + +Base = declarative_base() + +class Site(Base): + __tablename__ = 'sites' + id = Column(Integer, primary_key=True) + name = Column(String) # same as path, relative to the database position + description = Column(String) # longer names, eg intersection of road1 and road2 + xcoordinate = Column(Float) # ideally moving.Point, but needs to be + ycoordinate = Column(Float) + + def __init__(self, name, description = "", xcoordinate = None, ycoordinate = None): + self.name = name + self.description = description + self.xcoordinate = xcoordinate + self.ycoordinate = ycoordinate + + # def __repr__(self): + # return "<User('%s','%s', '%s')>" % (self.name, self.fullname, self.password) + +class EnvironementalFactors(Base): + '''Represents any environmental factors that may affect the results, in particular + * changing weather conditions + * changing road configuration, geometry, signalization, etc. + ex: sunny, rainy, before counter-measure, after counter-measure''' + __tablename__ = 'environmental_factors' + id = Column(Integer, primary_key=True) + startTime = Column(DateTime) + endTime = Column(DateTime) + description = Column(String) # eg sunny, before, after + siteId = Column(Integer, ForeignKey('sites.id')) + + site = relationship("Site", backref=backref('environmental_factors', order_by = id)) + +class CameraView(Base): + __tablename__ = 'camera_views' + id = Column(Integer, primary_key=True) + frameRate = Column(Float) + homographyFilename = Column(String) # path to homograph filename, relative to SiteId + siteId = Column(Integer, ForeignKey('sites.id')) + + site = relationship("Site", backref=backref('camera_views', order_by = id)) + +class VideoSequence(Base): + __tablename__ = 'video_sequences' + id = Column(Integer, primary_key=True) + startTime = Column(DateTime) + name = Column(String) # path that can be composed with the site name + startTime = Column(DateTime) + duration = Column(Float) # video sequence duration + siteId = Column(Integer, ForeignKey('sites.id')) + cameraViewId = Column(Integer, ForeignKey('camera_views.id')) + + site = relationship("Site", backref=backref('video_sequences', order_by = id)) + cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = id)) + +# class SiteDescription(Base): # list of lines and polygons describing the site, eg for sidewalks, center lines