tvaLib
Public Member Functions | Public Attributes | List of all members
lib.draw.SeqsDataEntry Class Reference
Inheritance diagram for lib.draw.SeqsDataEntry:
lib.draw.DataEntry

Public Member Functions

def __init__ (self, allowed_extensions=['.mp4', avi, args, kwargs)
 
def drawButtonFrame (self, cancel_label, submit_label)
 
def incrementStartTime (self, duration_h=1.0)
 
def decrementStartTime (self, duration_h=1.0)
 
def autoSearchStartTime (self)
 
- Public Member Functions inherited from lib.draw.DataEntry
def __init__ (self, instructions='', instructions2='', submit_label='Enter', cancel_label='Cancel', rows={}, sites=None, config=None, sites_selection_depth=1, dropdowns={}, multiSelectionListBoxes={})
 
def submitCallback (self)
 
def cancelCallback (self)
 
def getEntries (self)
 
def getDropDowns (self)
 
def getMSLBs (self)
 
def getSiteSelection (self)
 
def getCamViewSelection (self)
 
def getSequenceSelection (self)
 
def getSelectedSite (self)
 
def getSelectedCamView (self)
 
def setEntry (self, label, value)
 
def updateCameraOptions (self, index, value, op)
 
def updateSequenceOptions (self, index, value, op)
 
def drawButtonFrame (self, cancel_label, submit_label)
 

Public Attributes

 allowed_extensions
 
 buttonframe
 
- Public Attributes inherited from lib.draw.DataEntry
 root
 
 style
 Style. More...
 
 ttk_style
 
 config
 Data. More...
 
 sites
 
 sites_selection_depth
 
 submit
 
 labels
 Handle regular entries. More...
 
 entryVals
 
 ddlabels
 Handle dropdown menu items. More...
 
 ddVals
 
 mslblabels
 Handle multi-selection lists. More...
 
 mslbVals
 
 mslbScrolls
 
 mslbValsContents
 
 site_option
 
 site_option_menu
 
 camview_option
 
 camview_option_menu
 
 sequence_option
 
 sequence_option_menu
 
 buttonframe
 

Detailed Description

Definition at line 920 of file draw.py.

Constructor & Destructor Documentation

◆ __init__()

def lib.draw.SeqsDataEntry.__init__ (   self,
  allowed_extensions = ['.mp4',
  avi,
  args,
  kwargs 
)

Definition at line 921 of file draw.py.

921  def __init__(self, allowed_extensions=['.mp4', '.avi'], *args, **kwargs):
922  self.allowed_extensions = allowed_extensions
923  DataEntry.__init__(self, *args, **kwargs)
924 
925 

Member Function Documentation

◆ autoSearchStartTime()

def lib.draw.SeqsDataEntry.autoSearchStartTime (   self)

Definition at line 950 of file draw.py.

950  def autoSearchStartTime(self):
951  from datetime import datetime
952  try:
953  for first_file in sorted(os.listdir(os.path.join(self.getSelectedCamView().getBaseDirectory()))):
954  if(os.path.splitext(first_file)[-1].lower() in self.allowed_extensions): break
955  self.setEntry('startTime', datetime.fromtimestamp(os.path.getmtime(os.path.join(self.getSelectedCamView().getBaseDirectory(), first_file))).strftime('%Y-%m-%d %H:%M:%S'))
956  try:
957  import cv2
958  video_capture = cv2.VideoCapture(os.path.join(self.getSelectedCamView().getBaseDirectory(), first_file))
959  video_length = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
960  fps = video_capture.get(cv2.CAP_PROP_FPS)
961  '''count = 0
962  while(True):
963  # Capture frame-by-frame
964  ret, frame = video_capture.read()
965  if(not ret): break
966  count += 1'''
967  video_capture.release()
968  cv2.destroyAllWindows()
969  if(int(video_length/float(fps))):
970  self.setEntry('duration', 'auto ('+str(int(video_length/float(fps)))+')')
971  self.setEntry('durationUnit', 's')
972  except: tvaLib.printWarning('Failed to detect video duration')
973  except: tvaLib.printWarning('Could not find video sequence on disk to auto-fill time information')
974 
975 

◆ decrementStartTime()

def lib.draw.SeqsDataEntry.decrementStartTime (   self,
  duration_h = 1.0 
)

Definition at line 943 of file draw.py.

943  def decrementStartTime(self, duration_h=1.0):
944  from datetime import datetime, timedelta
945  try: t = datetime.strptime(self.getEntries()['startTime'], '%Y-%m-%d %H:%M:%S')
946  except:
947  tvaLib.printWarning('Time format in startTime field is invalid. Use the "2010-01-31 10:00:00" format.')
948  return False
949  self.setEntry('startTime', (t-timedelta(0,0,0,0,0,duration_h)).strftime('%Y-%m-%d %H:%M:%S'))

◆ drawButtonFrame()

def lib.draw.SeqsDataEntry.drawButtonFrame (   self,
  cancel_label,
  submit_label 
)

Definition at line 926 of file draw.py.

926  def drawButtonFrame(self, cancel_label, submit_label):
927  from Tkinter import Button, Frame
928  self.buttonframe = Frame(self.root)
929  self.buttonframe.grid(columnspan=3)
930  Button(self.buttonframe, text='Auto-fill time', command=self.autoSearchStartTime, foreground=self.style.fg, bg=self.style.bgdark).grid(row=0, column=0)
931  Button(self.buttonframe, text='T+h', command=self.incrementStartTime, foreground=self.style.fg, bg=self.style.bgdark).grid(row=0, column=1)
932  Button(self.buttonframe, text='T-h', command=self.decrementStartTime, foreground=self.style.fg, bg=self.style.bgdark).grid(row=0, column=2)
933  Button(self.buttonframe, text=cancel_label, command=self.cancelCallback, foreground=self.style.fg, bg=self.style.bgdark).grid(row=0, column=3)
934  Button(self.buttonframe, text=submit_label, command=self.submitCallback, foreground=self.style.fg, bg=self.style.bgdark).grid(row=0, column=4)
935 

◆ incrementStartTime()

def lib.draw.SeqsDataEntry.incrementStartTime (   self,
  duration_h = 1.0 
)

Definition at line 936 of file draw.py.

936  def incrementStartTime(self, duration_h=1.0):
937  from datetime import datetime, timedelta
938  try: t = datetime.strptime(self.getEntries()['startTime'], '%Y-%m-%d %H:%M:%S')
939  except:
940  tvaLib.printWarning('Time format in startTime field is invalid. Use the "2010-01-31 10:00:00" format.')
941  return False
942  self.setEntry('startTime', (t+timedelta(0,0,0,0,0,duration_h)).strftime('%Y-%m-%d %H:%M:%S'))

Member Data Documentation

◆ allowed_extensions

lib.draw.SeqsDataEntry.allowed_extensions

Definition at line 922 of file draw.py.

◆ buttonframe

lib.draw.SeqsDataEntry.buttonframe

Definition at line 928 of file draw.py.


The documentation for this class was generated from the following file: