tvaLib
Public Member Functions | Public Attributes | List of all members
lib.scene.ObjectSpace Class Reference

Objects containers. More...

Inheritance diagram for lib.scene.ObjectSpace:

Public Member Functions

def __init__ (self, spaceType='cameras', kwargs)
 
def add (self, objects, idx=0, framerate=None, metadata=None)
 
def getAll (self)
 
def getAllSpeeds (self, flatList=False, averagePerUser=False)
 
def getObjByHash (self, hash_)
 
def getSubSpacebyId (self, id)
 
def getSubSpacebyTime (self, start, end)
 
def iterateSequences (self)
 

Public Attributes

 spaceType
 
 idxs
 
 metadatas
 
 hashTable
 

Detailed Description

Objects containers.

Definition at line 1599 of file scene.py.

Constructor & Destructor Documentation

◆ __init__()

def lib.scene.ObjectSpace.__init__ (   self,
  spaceType = 'cameras',
  kwargs 
)
Contains objects lists in memory. 

    Space types include:
    ====================
sites
cameras
sequences

Definition at line 1600 of file scene.py.

1600  def __init__(self, spaceType='cameras', **kwargs):
1601  ''' Contains objects lists in memory.
1602 
1603  Space types include:
1604  ====================
1605  sites
1606  cameras
1607  sequences
1608  '''
1609  tvaLib.Constructors.SuperList.__init__(self, **kwargs)
1610  self.spaceType = spaceType
1611  self.idxs = []
1612  self.metadatas = []
1613  return
1614 

Member Function Documentation

◆ add()

def lib.scene.ObjectSpace.add (   self,
  objects,
  idx = 0,
  framerate = None,
  metadata = None 
)
Add framerate to individual objects in order to track data later on
    when objects become mixed. 

Definition at line 1615 of file scene.py.

1615  def add(self, objects, idx=0, framerate=None, metadata=None):
1616  ''' Add framerate to individual objects in order to track data later on
1617  when objects become mixed.
1618  '''
1619  if(framerate):
1620  for obj in objects: obj.framrate = framerate
1621  self.idxs.append(idx)
1622  self.metadatas.append(metadata)
1623  self.data.append(objects)
1624  if(type(objects) is list): self.hashTable = [obj.hash for obj in objects]
1625  return True
1626 

◆ getAll()

def lib.scene.ObjectSpace.getAll (   self)

Definition at line 1627 of file scene.py.

1627  def getAll(self):
1628  return_ = []
1629  for data in self.data:
1630  if(type(data) is list): return_ += data
1631  else: return_ += data.getAll()
1632  return return_
1633 

◆ getAllSpeeds()

def lib.scene.ObjectSpace.getAllSpeeds (   self,
  flatList = False,
  averagePerUser = False 
)

Definition at line 1634 of file scene.py.

1634  def getAllSpeeds(self, flatList=False, averagePerUser=False):
1635  return_ = []
1636  for data in self.data:
1637  if(type(data) is list):
1638  if(averagePerUser): return_ += [sum(x.getSpeeds())/float(len(x.getSpeeds())) for x in data]
1639  else: return_ += [list(x.getSpeeds()) for x in data]
1640  else: return_ += data.getAllSpeeds(flatList=flatList)
1641  if(flatList): return tvaLib.flatten_list(return_)
1642  else: return return_
1643 

◆ getObjByHash()

def lib.scene.ObjectSpace.getObjByHash (   self,
  hash_ 
)

Definition at line 1644 of file scene.py.

1644  def getObjByHash(self, hash_):
1645  for data in self.data:
1646  if(type(data) is list): return data[self.hashTable.index(hash_)]
1647  else:
1648  search = data.getObjByHash(hash_)
1649  if(search): return search
1650  return False
1651 

◆ getSubSpacebyId()

def lib.scene.ObjectSpace.getSubSpacebyId (   self,
  id 
)

Definition at line 1652 of file scene.py.

1652  def getSubSpacebyId(self, id):
1653  for dataIx in range(len(self.metadatas)):
1654  if(id==self.metadatas[dataIx].idx): return self.data[dataIx]
1655  return None
1656 
1657 

◆ getSubSpacebyTime()

def lib.scene.ObjectSpace.getSubSpacebyTime (   self,
  start,
  end 
)
Returns any object with a START TIME within a start and end time.
    Expects start and end to be datetime.time() objects.
    TODO: Add support for dates as well. 

Definition at line 1658 of file scene.py.

1658  def getSubSpacebyTime(self, start, end):
1659  ''' Returns any object with a START TIME within a start and end time.
1660  Expects start and end to be datetime.time() objects.
1661  TODO: Add support for dates as well. '''
1662  objects = []
1663  for metadata,objs in self.iterateSequences():
1664  for obj in objs:
1665  objStartTime = metadata.getStartTime()+timedelta(seconds=obj.getFirstInstant()/float(metadata.cameraView.camera.frameRate))
1666  if(start < objStartTime.time() and objStartTime.time() < end):
1667  objects.append(obj)
1668  return objects
1669 

◆ iterateSequences()

def lib.scene.ObjectSpace.iterateSequences (   self)
iterate over sequences
    TODO: Needs more work to be generalised. 

Definition at line 1670 of file scene.py.

1670  def iterateSequences(self):
1671  ''' iterate over sequences
1672  TODO: Needs more work to be generalised. '''
1673  metadata = []
1674  data = []
1675 
1676  if(self.spaceType == 'sequences'):
1677  for i in range(len(self)):
1678  metadata.append(self.metadatas[i])
1679  data.append(self.data[i])
1680  elif(self.spaceType == 'cameras'):
1681  for i in range(len(self)):
1682  for j in range(len(self.data[i])):
1683  metadata.append(self.data[i].metadatas[j])
1684  data.append(self.data[i][j])
1685  return zip(metadata,data)
1686 
1687 

Member Data Documentation

◆ hashTable

lib.scene.ObjectSpace.hashTable

Definition at line 1624 of file scene.py.

◆ idxs

lib.scene.ObjectSpace.idxs

Definition at line 1611 of file scene.py.

◆ metadatas

lib.scene.ObjectSpace.metadatas

Definition at line 1612 of file scene.py.

◆ spaceType

lib.scene.ObjectSpace.spaceType

Definition at line 1610 of file scene.py.


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