Mercurial Hosting > traffic-intelligence
annotate python/metadata.py @ 821:26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 22 Jun 2016 16:36:12 -0400 |
parents | fc8b3ce629d1 |
children | 6e4357e9116d |
rev | line source |
---|---|
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 # from moving import Point |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
3 from datetime import datetime, timedelta |
422
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
4 from os import path |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
5 from math import floor |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
6 |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
7 from sqlalchemy import orm, create_engine, Column, Integer, Float, DateTime, String, ForeignKey, Boolean, Interval |
426
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
8 from sqlalchemy.orm import relationship, backref, sessionmaker |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
9 from sqlalchemy.ext.declarative import declarative_base |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
10 |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
11 from utils import datetimeFormat, removeExtension |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
12 |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 Base = declarative_base() |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
14 |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 class Site(Base): |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
16 __tablename__ = 'sites' |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
17 idx = Column(Integer, primary_key=True) |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
18 name = Column(String) # same as path, relative to the database position |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
19 description = Column(String) # longer names, eg intersection of road1 and road2 |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
20 xcoordinate = Column(Float) # ideally moving.Point, but needs to be |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
21 ycoordinate = Column(Float) |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
580
diff
changeset
|
22 mapImageFilename = Column(String) # path to filename, relative to site name, ie sitename/mapImageFilename |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
580
diff
changeset
|
23 nUnitsPerPixel = Column(Float) # number of units of distance per pixel in map image |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
24 worldDistanceUnit = Column(String, default = 'm') # make sure it is default in the database |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
25 |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
26 def __init__(self, name, description = "", xcoordinate = None, ycoordinate = None, mapImageFilename = None, nUnitsPerPixel = 1., worldDistanceUnit = 'm'): |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
27 self.name = name |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
28 self.description = description |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
29 self.xcoordinate = xcoordinate |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
30 self.ycoordinate = ycoordinate |
805
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
580
diff
changeset
|
31 self.mapImageFilename = mapImageFilename |
180b6b0231c0
added saving/loading points of interests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
580
diff
changeset
|
32 self.nUnitsPerPixel = nUnitsPerPixel |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
33 self.worldDistanceUnit = worldDistanceUnit |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
34 |
422
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
35 def getFilename(self): |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
36 return self.name |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
37 |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
38 class EnvironementalFactors(Base): |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
39 '''Represents any environmental factors that may affect the results, in particular |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
40 * changing weather conditions |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
41 * changing road configuration, geometry, signalization, etc. |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
42 ex: sunny, rainy, before counter-measure, after counter-measure''' |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
43 __tablename__ = 'environmental_factors' |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
44 idx = Column(Integer, primary_key=True) |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
45 startTime = Column(DateTime) |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
46 endTime = Column(DateTime) |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
47 description = Column(String) # eg sunny, before, after |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
48 siteIdx = Column(Integer, ForeignKey('sites.idx')) |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
49 |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
50 site = relationship("Site", backref=backref('environmental_factors', order_by = idx)) |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
51 |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
52 def __init__(self, startTime, endTime, description, site): |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
53 'startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39' |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
54 self.startTime = datetime.strptime(startTime, datetimeFormat) |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
55 self.endTime = datetime.strptime(endTime, datetimeFormat) |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
56 self.description = description |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
57 self.site = site |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
58 |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
59 class CameraType(Base): |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
60 ''' Represents parameters of the specific camera used. |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
61 |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
62 Taken and adapted from tvalib''' |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
63 __tablename__ = 'camera_types' |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
64 idx = Column(Integer, primary_key=True) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
65 name = Column(String) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
66 resX = Column(Integer) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
67 resY = Column(Integer) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
68 frameRate = Column(Float) |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
69 frameRateTimeUnit = Column(String, default = 's') |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
70 undistort = Column(Boolean) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
71 intrinsicCameraMatrixStr = Column(String) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
72 distortionCoefficientsStr = Column(String) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
73 undistortedImageMultiplication = Column(Float) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
74 |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
75 def __init__(self, name, resX, resY, frameRate, frameRateTimeUnit = 's', trackingConfigurationFilename = None, undistort = None, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = None): |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
76 self.name = name |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
77 self.resX = resX |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
78 self.resY = resY |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
79 self.frameRate = frameRate |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
80 self.frameRateTimeUnit = frameRateTimeUnit |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
81 self.undistort = False |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
82 |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
83 if trackingConfigurationFilename is not None: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
84 from storage import ProcessParameters |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
85 params = ProcessParameters(trackingConfigurationFilename) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
86 if params.undistort: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
87 self.undistort = params.undistort |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
88 self.intrinsicCameraMatrix = params.intrinsicCameraMatrix |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
89 self.distortionCoefficients = params.distortionCoefficients |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
90 self.undistortedImageMultiplication = params.undistortedImageMultiplication |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
91 elif undistort is not None: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
92 self.undistort = undistort |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
93 self.intrinsicCameraMatrix = intrinsicCameraMatrix |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
94 self.distortionCoefficients = distortionCoefficients |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
95 self.undistortedImageMultiplication = undistortedImageMultiplication |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
96 |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
97 # populate the db |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
98 if hasattr(self, 'intrinsicCameraMatrix') and self.intrinsicCameraMatrix is not None\ |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
99 and hasattr(self, 'distortionCoefficients') and self.distortionCoefficients is not None: |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
100 self.intrinsicCameraMatrixStr = ' '.join('{}'.format(x) for x in self.intrinsicCameraMatrix.flatten('C')) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
101 self.distortionCoefficientsStr = ' '.join('{}'.format(x)for x in self.distortionCoefficients) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
102 |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
103 @orm.reconstructor |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
104 def initOnLoad(self): |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
105 from numpy import array |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
106 if len(self.intrinsicCameraMatrixStr) > 0: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
107 self.intrinsicCameraMatrix = array([float(x) for x in self.intrinsicCameraMatrixStr.split(" ")]).reshape(3,3) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
108 if len(self.distortionCoefficientsStr) > 0: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
109 self.distortionCoefficients = [float(x) for x in self.distortionCoefficientsStr.split(" ")] |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
110 |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
111 class CameraView(Base): |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
112 __tablename__ = 'camera_views' |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
113 idx = Column(Integer, primary_key=True) |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
114 description = Column(String) |
422
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
115 homographyFilename = Column(String) # path to homograph filename, relative to the site name |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
116 siteIdx = Column(Integer, ForeignKey('sites.idx')) |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
117 cameraTypeIdx = Column(Integer, ForeignKey('camera_types.idx')) |
424 | 118 homographyDistanceUnit = Column(String, default = 'm') # make sure it is default in the database |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
119 trackingConfigurationFilename = Column(String) # path to configuration .cfg file, relative to site name |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
120 |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
121 site = relationship("Site", backref=backref('sites', order_by = idx)) |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
122 cameraType = relationship('CameraType', backref=backref('camera_views', order_by = idx)) |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
123 |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
124 def __init__(self, description, homographyFilename, site, cameraType, trackingConfigurationFilename): |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
125 self.description = description |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
126 self.homographyFilename = homographyFilename |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
127 self.site = site |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
128 self.cameraType = cameraType |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
129 self.trackingConfigurationFilename = trackingConfigurationFilename |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
130 |
422
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
131 def getHomographyFilename(self, relativeToSiteFilename = True): |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
132 if relativeToSiteFilename: |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
133 return self.site.getFilename()+path.sep+self.homographyFilename |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
134 else: |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
135 return self.homographyFilename |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
136 |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
137 def getTrackingConfigurationFilename(self, relativeToSiteFilename = True): |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
138 if relativeToSiteFilename: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
139 return self.site.getFilename()+path.sep+self.trackingConfigurationFilename |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
140 else: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
141 return self.trackingConfigurationFilename |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
142 |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
143 def getTrackingParameters(self): |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
144 return ProcessParameters(getTrackingConfigurationFilename()) |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
145 |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
146 class Alignment(Base): |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
147 __tablename__ = 'alignments' |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
148 idx = Column(Integer, primary_key=True) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
149 cameraViewIdx = Column(Integer, ForeignKey('camera_views.idx')) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
150 |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
151 cameraView = relationship("CameraView", backref=backref('alignments', order_by = idx)) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
152 |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
153 def __init__(self, cameraView): |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
154 self.cameraView = cameraView |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
155 |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
156 class Point(Base): |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
157 __tablename__ = 'points' |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
158 alignmentIdx = Column(Integer, ForeignKey('alignments.idx'), primary_key=True) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
159 index = Column(Integer, primary_key=True) # order of points in this alignment |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
160 x = Column(Float) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
161 y = Column(Float) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
162 |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
163 alignment = relationship("Alignment", backref=backref('points', order_by = index)) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
164 |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
165 def __init__(self, alignmentIdx, index, x, y): |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
166 self.alignmentIdx = alignmentIdx |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
167 self.index = index |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
168 self.x = x |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
169 self.y = y |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
170 |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
171 class VideoSequence(Base): |
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
172 __tablename__ = 'video_sequences' |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
173 idx = Column(Integer, primary_key=True) |
422
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
174 name = Column(String) # path relative to the the site name |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
175 startTime = Column(DateTime) |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
176 duration = Column(Interval) # video sequence duration |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
177 databaseFilename = Column(String) # path relative to the the site name |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
178 siteIdx = Column(Integer, ForeignKey('sites.idx')) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
179 cameraViewIdx = Column(Integer, ForeignKey('camera_views.idx')) |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
180 |
580
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
181 site = relationship("Site", backref=backref('video_sequences', order_by = idx)) |
1262faae12e7
alignments may be stored in metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
491
diff
changeset
|
182 cameraView = relationship("CameraView", backref=backref('video_sequences', order_by = idx)) |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
183 |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
184 def __init__(self, name, startTime, duration, site, cameraView, databaseFilename = None): |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
185 '''startTime is passed as string in utils.datetimeFormat, eg 2011-06-22 10:00:39 |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
186 duration is a timedelta object''' |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
187 self.name = name |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
188 self.startTime = datetime.strptime(startTime, datetimeFormat) |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
189 self.duration = duration |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
190 self.site = site |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
191 self.cameraView = cameraView |
819
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
192 if databaseFilename is None and len(self.name) > 0: |
fc8b3ce629d1
important modifications to metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
805
diff
changeset
|
193 self.databaseFilename = removeExtension(self.name)+'.sqlite' |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
194 |
422
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
195 def getVideoSequenceFilename(self, relativeToSiteFilename = True): |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
196 if relativeToSiteFilename: |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
197 return self.site.getFilename()+path.sep+self.name |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
198 else: |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
199 return self.name |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
200 |
821
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
201 def containsInstant(self, instant): |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
202 'instant is a datetime' |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
203 return self.startTime <= instant and self.startTime+self.duration |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
204 |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
205 def getFrameNum(self, instant): |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
206 'Warning, there is no check of correct time units' |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
207 if self.containsInstant(instant): |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
208 return int(floor((instant-self.startTime).seconds*self.cameraView.cameraType.frameRate)) |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
209 else: |
26daf35180ad
finished modification and demo script to replay synchronized video (with same frame rate)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
819
diff
changeset
|
210 return None |
424 | 211 |
422
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
212 # 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) |
67c7ff5d6b26
added new fields for units, getting filenames
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
421
diff
changeset
|
213 |
420
def795d1120f
first work on video metadata
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
214 # class SiteDescription(Base): # list of lines and polygons describing the site, eg for sidewalks, center lines |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
215 |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
216 # class Analysis(Base): # parameters necessary for processing the data: free form |
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
217 # eg bounding box depends on camera view, tracking configuration depends on camera view |
424 | 218 # results: sqlite |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
219 |
426
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
220 def createDatabase(filename): |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
221 'creates a session to query the filename' |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
222 engine = create_engine('sqlite:///'+filename) |
421
4fce27946c60
first example of video metadata using sqlalchemy
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
420
diff
changeset
|
223 Base.metadata.create_all(engine) |
426
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
224 Session = sessionmaker(bind=engine) |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
225 return Session() |
425
a31dde19caa8
connect function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
424
diff
changeset
|
226 |
426
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
227 def connectDatabase(filename): |
425
a31dde19caa8
connect function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
424
diff
changeset
|
228 'creates a session to query the filename' |
a31dde19caa8
connect function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
424
diff
changeset
|
229 engine = create_engine('sqlite:///'+filename) |
a31dde19caa8
connect function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
424
diff
changeset
|
230 Session = sessionmaker(bind=engine) |
a31dde19caa8
connect function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
424
diff
changeset
|
231 return Session() |
426
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
232 |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
233 def initializeSites(session, directoryName): |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
234 '''Initializes default site objects and Camera Views |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
235 |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
236 eg somedirectory/montreal/ contains intersection1, intersection2, etc. |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
237 The site names would be somedirectory/montreal/intersection1, somedirectory/montreal/intersection2, etc.''' |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
238 from os import listdir, path |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
239 sites = [] |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
240 cameraViews = [] |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
241 names = listdir(directoryName) |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
242 for name in names: |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
243 if path.isdir(directoryName+'/'+name): |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
244 sites.append(Site(directoryName+'/'+name, None)) |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
245 cameraViews.append(CameraView(-1, None, None, sites[-1], None)) |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
246 session.add_all(sites) |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
247 session.add_all(cameraViews) |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
248 session.commit() |
334e1151828b
corrected creation and connection to database + helper function to generate sites and camera views
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
425
diff
changeset
|
249 # TODO crawler for video files? |