tvaLib
DB-upgrade.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # tvaLib Copyright (c) 2012-2016 Paul G. St-Aubin
3 # Ecole Polytechnique de Montreal, McGill University
4 # Python 2.7; (dt) Spyder Windows 10 64-bit; ipython Ubuntu 15.04 64-bit
5 version = 'R2.3.0 u. 2017-03-22'
6 
7 ''' Dev stuff
8 Insert tasks here to do database maintenance and upgrades
9 '''
10 
11 
12 
15 def main():
16  try:
17 
18 
22  import os, logging
23  from site import addsitedir
24  from time import clock
25  #Add parent library
26  if(os.path.isfile(os.path.join(os.getcwd(), os.pardir, 'main.py'))):
27  addsitedir(os.path.join(os.getcwd(), os.pardir))
28  os.chdir(os.path.join(os.getcwd(), os.pardir))
29 
30  import include.config as tvaConfig
31  import include.local as tvaLocal
32 
33 
36  commands = tvaConfig.commands()
37  config = tvaConfig.Config(readonly=False) #Set this to true if the script is running independantly of the main program
38 
39 
42  try: #Colorama, optional, required for Windows if coloured text is desired
43  from colorama import init as colorama_init
44  colorama_init(strip=False)
45  from colorama import Fore, Back, Style
46  except ImportError:
47  Fore = tvaConfig.Fore()
48  Back = tvaConfig.Back()
49  Style = tvaConfig.Style()
50  if(commands.logging or config.disable_colour):
51  config.disable_colour = True
52  Fore = tvaConfig.Fore(forceOff=True)
53  Back = tvaConfig.Back(forceOff=True)
54  Style = tvaConfig.Style(forceOff=True)
55 
56  import lib.scene as tvaScene
57  import lib.tools as tvaLib
58  import include.runtime as tvaRuntime
59 
60 
63  if(config.debug): logging.basicConfig(level=logging.DEBUG, format='[%(levelname)s] (%(threadName)-10s) %(message)s')
64  if(commands.dir): config.dir = commands.dir
65  if(commands.dbn): config.dbn = commands.dbn
66  if(commands.language): config.language = commands.language
67  local = tvaLocal.Local(config.language)
68  sites = tvaScene.Sites(config)
69  site_analyses = tvaScene.SiteAnalyses(config, sites=sites)
70  analyses = tvaScene.Analyses(dir=config.dir, filename=config.dbn)
71  verbose_child = 2
72 
73 
76  print('Running generic batch worker, version '+version+'.')
77 
78 
79 
83  siteIxs = sites.interpret(commands.site)
84  if(commands.verbose == 1): prog = tvaLib.ProgressBar(0, len(siteIxs), 77)
85  IxIx = 0
86  for siteIx in siteIxs:
87  if(commands.verbose == 1): prog.updateAmount(siteIx)
88  elif(commands.verbose >= 2): print sites[siteIx].name
89 
90 
91  siteList = tvaLib.Parse.list1D(commands.site)
92  cameraList = tvaLib.Parse.list1D(commands.camera)
93  if(len(siteList)>=2 and len(cameraList)==len(siteList)): camIxs = sites[siteIx].interpret(cameraList[IxIx])
94  else: camIxs = sites[siteIx].interpret()
95  for camIx in camIxs:
96  if(commands.verbose >= 2): print(' '+sites[siteIx][camIx].name)
97 
98 
99  sites[siteIx][camIx].getHomography()
100 
101 
102 
103 
106 
107 
108 
111 
112  #pass
113 
114 
117 
118 
121 
122 
123 
126  sites.update()
127 
128  raise Exception, [0003, 'Batch processing complete.']
129 
130 
131 
135  except KeyboardInterrupt:
136  if(commands.verbose): print(Back.GREEN+'==User exited== [0000]'+Back.RESET+'\nRuntime: {0}'.format(round(clock())))
137 
138  except SystemExit, e:
139  try:
140  if(commands.verbose): print(Back.GREEN+'==Execution finished== [0001'+Back.RESET+'\nRuntime: {0}'.format(round(clock())))
141  except UnboundLocalError: pass
142 
143  except Exception, e:
144  if('commands' in dir()): verbose = commands.verbose
145  else: verbose = 1
146  if('config' in dir()): debug = config.debug
147  else: debug = True
148  from include.runtime import debug as tvaRuntime_debug
149  tvaRuntime_debug(e, time, logging=logging, verbose=verbose, force=debug)
150 
151 
154 if __name__ == '__main__':
155  main()
def main()
main()
Definition: DB-upgrade.py:15
def getHomography(homoSrcFrame='', orthoSrcPath='', savePath='homography.txt', tsaiCameraSrcPath='', nPoints=4, unitsPerPixel=0.1, videoPts=None, worldPts=None, pointDrawSize=3, pointTargetDrawSize=7, pointTargetDrawThickness=2, maxDisplayResolutionX=900, fig_name='', verbose=0)
Definition: tools_obj.py:403
Definition: main.py:1