comparison python/metadata.py @ 580:1262faae12e7

alignments may be stored in metadata
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 29 Aug 2014 01:32:11 -0400
parents 343cfd185ca6
children 180b6b0231c0
comparison
equal deleted inserted replaced
579:05c927c6d3cf 580:1262faae12e7
11 11
12 Base = declarative_base() 12 Base = declarative_base()
13 13
14 class Site(Base): 14 class Site(Base):
15 __tablename__ = 'sites' 15 __tablename__ = 'sites'
16 id = Column(Integer, primary_key=True) 16 idx = Column(Integer, primary_key=True)
17 name = Column(String) # same as path, relative to the database position 17 name = Column(String) # same as path, relative to the database position
18 description = Column(String) # longer names, eg intersection of road1 and road2 18 description = Column(String) # longer names, eg intersection of road1 and road2
19 xcoordinate = Column(Float) # ideally moving.Point, but needs to be 19 xcoordinate = Column(Float) # ideally moving.Point, but needs to be
20 ycoordinate = Column(Float) 20 ycoordinate = Column(Float)
21 21
32 '''Represents any environmental factors that may affect the results, in particular 32 '''Represents any environmental factors that may affect the results, in particular
33 * changing weather conditions 33 * changing weather conditions
34 * changing road configuration, geometry, signalization, etc. 34 * changing road configuration, geometry, signalization, etc.
35 ex: sunny, rainy, before counter-measure, after counter-measure''' 35 ex: sunny, rainy, before counter-measure, after counter-measure'''
36 __tablename__ = 'environmental_factors' 36 __tablename__ = 'environmental_factors'
37 id = Column(Integer, primary_key=True) 37 idx = Column(Integer, primary_key=True)
38 startTime = Column(DateTime) 38 startTime = Column(DateTime)
39 endTime = Column(DateTime) 39 endTime = Column(DateTime)
40 description = Column(String) # eg sunny, before, after 40 description = Column(String) # eg sunny, before, after
41 siteId = Column(Integer, ForeignKey('sites.id')) 41 siteIdx = Column(Integer, ForeignKey('sites.idx'))
42 42
43 site = relationship("Site", backref=backref('environmental_factors', order_by = id)) 43 site = relationship("Site", backref=backref('environmental_factors', order_by = idx))
44 44
45 def __init__(self, startTime, endTime, description, site): 45 def __init__(self, startTime, endTime, description, site):
46 'startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39' 46 'startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39'
47 self.startTime = datetime.strptime(startTime, datetimeFormat) 47 self.startTime = datetime.strptime(startTime, datetimeFormat)
48 self.endTime = datetime.strptime(endTime, datetimeFormat) 48 self.endTime = datetime.strptime(endTime, datetimeFormat)
49 self.description = description 49 self.description = description
50 self.site = site 50 self.site = site
51 51
52 class CameraView(Base): 52 class CameraView(Base):
53 __tablename__ = 'camera_views' 53 __tablename__ = 'camera_views'
54 id = Column(Integer, primary_key=True) 54 idx = Column(Integer, primary_key=True)
55 frameRate = Column(Float) 55 frameRate = Column(Float)
56 homographyFilename = Column(String) # path to homograph filename, relative to the site name 56 homographyFilename = Column(String) # path to homograph filename, relative to the site name
57 cameraCalibrationFilename = Column(String) # path to full camera calibration, relative to the site name 57 cameraCalibrationFilename = Column(String) # path to full camera calibration, relative to the site name
58 siteId = Column(Integer, ForeignKey('sites.id')) 58 siteIdx = Column(Integer, ForeignKey('sites.idx'))
59 homographyDistanceUnit = Column(String, default = 'm') # make sure it is default in the database 59 homographyDistanceUnit = Column(String, default = 'm') # make sure it is default in the database
60 configurationFilename = Column(String) # path to configuration .cfg file, relative to site name 60 configurationFilename = Column(String) # path to configuration .cfg file, relative to site name
61 61
62 site = relationship("Site", backref=backref('camera_views', order_by = id)) 62 site = relationship("Site", backref=backref('camera_views', order_by = idx))
63 63
64 def __init__(self, frameRate, homographyFilename, cameraCalibrationFilename, site, configurationFilename): 64 def __init__(self, frameRate, homographyFilename, cameraCalibrationFilename, site, configurationFilename):
65 self.frameRate = frameRate 65 self.frameRate = frameRate
66 self.homographyFilename = homographyFilename 66 self.homographyFilename = homographyFilename
67 self.site = site 67 self.site = site
71 if relativeToSiteFilename: 71 if relativeToSiteFilename:
72 return self.site.getFilename()+path.sep+self.homographyFilename 72 return self.site.getFilename()+path.sep+self.homographyFilename
73 else: 73 else:
74 return self.homographyFilename 74 return self.homographyFilename
75 75
76 class Alignment(Base):
77 __tablename__ = 'alignments'
78 idx = Column(Integer, primary_key=True)
79 cameraViewIdx = Column(Integer, ForeignKey('camera_views.idx'))
80
81 cameraView = relationship("CameraView", backref=backref('alignments', order_by = idx))
82
83 def __init__(self, cameraView):
84 self.cameraView = cameraView
85
86 class Point(Base):
87 __tablename__ = 'points'
88 alignmentIdx = Column(Integer, ForeignKey('alignments.idx'), primary_key=True)
89 index = Column(Integer, primary_key=True) # order of points in this alignment
90 x = Column(Float)
91 y = Column(Float)
92
93 alignment = relationship("Alignment", backref=backref('points', order_by = index))
94
95 def __init__(self, alignmentIdx, index, x, y):
96 self.alignmentIdx = alignmentIdx
97 self.index = index
98 self.x = x
99 self.y = y
100
76 class VideoSequence(Base): 101 class VideoSequence(Base):
77 __tablename__ = 'video_sequences' 102 __tablename__ = 'video_sequences'
78 id = Column(Integer, primary_key=True) 103 idx = Column(Integer, primary_key=True)
79 name = Column(String) # path relative to the the site name 104 name = Column(String) # path relative to the the site name
80 startTime = Column(DateTime) 105 startTime = Column(DateTime)
81 duration = Column(Float) # video sequence duration 106 duration = Column(Float) # video sequence duration
82 durationUnit = Column(String, default = 's') 107 durationUnit = Column(String, default = 's')
83 siteId = Column(Integer, ForeignKey('sites.id')) 108 siteIdx = Column(Integer, ForeignKey('sites.idx'))
84 cameraViewId = Column(Integer, ForeignKey('camera_views.id')) 109 cameraViewIdx = Column(Integer, ForeignKey('camera_views.idx'))
85 configurationFilename = Column(String) 110 configurationFilename = Column(String)
86 111
87 site = relationship("Site", backref=backref('video_sequences', order_by = id)) 112 site = relationship("Site", backref=backref('video_sequences', order_by = idx))
88 cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = id)) 113 cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = idx))
89 114
90 def __init__(self, name, startTime, duration, site, cameraView, configurationFilename = None): 115 def __init__(self, name, startTime, duration, site, cameraView, configurationFilename = None):
91 'startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39' 116 'startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39'
92 self.name = name 117 self.name = name
93 self.startTime = datetime.strptime(startTime, datetimeFormat) 118 self.startTime = datetime.strptime(startTime, datetimeFormat)