changeset 969:5d788d2e8ffc

work in progress
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 07 Dec 2017 17:03:09 -0500
parents 32a34a143c27
children bf401567a933
files README-Win32.txt python/cvutils.py python/metadata.py python/utils.py scripts/create-metadata.py
diffstat 5 files changed, 62 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/README-Win32.txt	Thu Dec 07 15:13:06 2017 -0500
+++ b/README-Win32.txt	Thu Dec 07 17:03:09 2017 -0500
@@ -1,22 +1,22 @@
-To be able to use traffic intelligence on windows, you will first have to fetch the 3rd party libraries.
-To do this, go in the folder win32-depends and launch win32-depends-installer.bat. It should fetch the library 
-and unarchive them correctly.
-
-Second you will need is the project TrajectoryManagementAndAnalysis available at https://bitbucket.org/trajectories/trajectorymanagementandanalysis
-
-
-
-If you want the sln to work, the project must be in the same folder where you have cloned trafficintelligence.
-To clone the project, use hg clone https://bitbucket.org/trajectories/trajectorymanagementandanalysis
-
-If you've done everything correctly, you should have
-
-/trafficintelligence
-/trafficintelligence/win32-depends/boost/
-/trafficintelligence/win32-depends/klt/
-/trafficintelligence/win32-depends/opencv/
-/trafficintelligence/win32-depends/sqlite/
-/trajectorymanagementandanalysis
-
-
-
+To be able to use traffic intelligence on windows, you will first have to fetch the 3rd party libraries.
+To do this, go in the folder win32-depends and launch win32-depends-installer.bat. It should fetch the library 
+and unarchive them correctly.
+
+Second you will need is the project TrajectoryManagementAndAnalysis available at https://bitbucket.org/trajectories/trajectorymanagementandanalysis
+
+
+
+If you want the sln to work, the project must be in the same folder where you have cloned trafficintelligence.
+To clone the project, use hg clone https://bitbucket.org/trajectories/trajectorymanagementandanalysis
+
+If you've done everything correctly, you should have
+
+/trafficintelligence
+/trafficintelligence/win32-depends/boost/
+/trafficintelligence/win32-depends/klt/
+/trafficintelligence/win32-depends/opencv/
+/trafficintelligence/win32-depends/sqlite/
+/trajectorymanagementandanalysis
+
+
+
--- a/python/cvutils.py	Thu Dec 07 15:13:06 2017 -0500
+++ b/python/cvutils.py	Thu Dec 07 17:03:09 2017 -0500
@@ -26,7 +26,7 @@
 from matplotlib.mlab import find
 from matplotlib.pyplot import imread, imsave
 
-
+videoFilenameExtensions = ['mov', 'avi', 'mp4', 'MOV', 'AVI', 'MP4']
 
 #import aggdraw # agg on top of PIL (antialiased drawing)
 
--- a/python/metadata.py	Thu Dec 07 15:13:06 2017 -0500
+++ b/python/metadata.py	Thu Dec 07 17:03:09 2017 -0500
@@ -1,5 +1,5 @@
 from datetime import datetime, timedelta
-from os import path
+from os import path, listdir, sep
 from math import floor
 
 from numpy import zeros, loadtxt, array
@@ -8,8 +8,8 @@
 from sqlalchemy.orm import relationship, backref, sessionmaker
 from sqlalchemy.ext.declarative import declarative_base
 
-from utils import datetimeFormat, removeExtension
-from cvutils import computeUndistortMaps
+from utils import datetimeFormat, removeExtension, getExtension
+from cvutils import computeUndistortMaps, videoFilenameExtensions
 from moving import TimeInterval
 
 """
@@ -363,7 +363,6 @@
     
     eg somedirectory/montreal/ contains intersection1, intersection2, etc.
     The site names would be somedirectory/montreal/intersection1, somedirectory/montreal/intersection2, etc.'''
-    from os import listdir, path, sep
     sites = []
     cameraViews = []
     names = listdir(directoryName)
@@ -377,3 +376,15 @@
     session.add_all(cameraViews)
     session.commit()
 # TODO crawler for video files?
+
+def initializeVideos(session, site, cameraView, directoryName, startTime = None, datetimeFormat = None):
+    '''Initializes videos with time or tries to guess it from filename
+    directoryName should contain the videos to find and be the relative path from the site location'''
+    names = listdir(directoryName)
+    videoSequences = []
+    for name in names:
+        extension = getExtension(name)
+        print(name, extension)
+        if extension in videoFilenameExtensions:
+            videoSequences.append(VideoSequence(directoryName+sep+name, startTime, None, cameraView, directoryName+sep+'.sqlite'))
+    return videoSequences
--- a/python/utils.py	Thu Dec 07 15:13:06 2017 -0500
+++ b/python/utils.py	Thu Dec 07 17:03:09 2017 -0500
@@ -13,6 +13,8 @@
 
 datetimeFormat = "%Y-%m-%d %H:%M:%S"
 
+sjcamDatetimeFormat = "%Y_%m%d_%H%M%S"#2017_0626_143720
+
 #########################
 # Strings
 #########################
@@ -939,6 +941,14 @@
     else:
         return filename
 
+def getExtension(filename, delimiter = '.'):
+    '''Returns the filename minus the extension (all characters after last .)'''
+    i = filename.rfind(delimiter)
+    if i>0:
+        return filename[i+1:]
+    else:
+        return ''
+
 def cleanFilename(s):
     'cleans filenames obtained when contatenating figure characteristics'
     return s.replace(' ','-').replace('.','').replace('/','-').replace(',','')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/create-metadata.py	Thu Dec 07 17:03:09 2017 -0500
@@ -0,0 +1,14 @@
+#! /usr/bin/env python
+
+import sys, argparse
+import cvutils
+
+
+parser = argparse.ArgumentParser(description='The program displays the video.')
+#parser.add_argument('-d', dest = 'siteDirectory', help = 'name of the directory for the site')#, required = True
+parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the metadata filename')
+parser.add_argument('-s', dest = 'site', help = 'site id')
+
+args = parser.parse_args()
+
+print('Unfinished, look at methods in metadata module')