示例#1
0
 def open(self, path):
     self.path = path
     tree = ET.parse(path)
     self.root = tree.getroot()
     
     if len(self.root) == 0:
         raise IOError('XML file is empty.')
     
     if self.root.tag != "dataset":
         raise IOError("Wrong input file, needs a dataset xml file.")
     
     self._frames = {}
     self._at = None
     self._ratio = 1.0
     
     for frm in self.root.findall('frameInformation'):
         num = int(frm.find('frame').attrib['number'])
         if self._at is None:
             self._at = num
         
         objects = {}
         for obj in frm.findall('object'):
             name = obj.attrib['name']
             objects[name] = {}
             objects[name]["box"] = obj.find('boxinfo').attrib
             objects[name]["centre"] = obj.find('centroid').attrib
             
             visible = obj.find("visibility")
             if visible is not None:
                 objects[name]["visibility"] = visible.attrib
                 
             if 'lens' in obj.attrib:
                 objects[name]["lens"] = Theta.resolve(obj.attrib['lens'])
             else:
                 objects[name]["lens"] = Theta.NonDual
         
         self._frames[num] = objects
     
     self.total = len(self._frames)
示例#2
0
    def status(self):
        return "frame: {:0>2d}/{:d} buffer: {:0>2d}/{:0>2d}"\
            .format(self.at(), self.total, self._buff_at+1, self._buff_max)

# testing script
if __name__ == "__main__":
    import sys
    
    # sanity checks
    if len(sys.argv) < 3:
        print "testing script aborted. Requries args"
        print "usage: python2 buff_split_cap.py <video path> <left|right>"
        exit(1)
    
    # open reader, window, etc
    side = Theta.resolve(sys.argv[2])
    cap = BuffSplitCap(sys.argv[1], side=side, rotate=BuffSplitCap.r270)
    
    window_name = "SplitCap test"
    cv2.namedWindow(window_name)
    
    # loop
    while cap.isOpened():
        cv2.imshow(window_name, cap.frame(side))
        sys.stdout.write(cap.status() + "\r")
        sys.stdout.flush()
        
        # controls
        key = cv2.waitKey(0)
        if key == 0xFF & ord('q'):
            break
示例#3
0
        return "frame: {:0>2d}/{:d} buffer: {:0>2d}/{:0>2d}"\
            .format(self.at(), self.total, self._buff_at+1, self._buff_max)


# testing script
if __name__ == "__main__":
    import sys

    # sanity checks
    if len(sys.argv) < 3:
        print "testing script aborted. Requries args"
        print "usage: python2 buff_split_cap.py <video path> <left|right>"
        exit(1)

    # open reader, window, etc
    side = Theta.resolve(sys.argv[2])
    cap = BuffSplitCap(sys.argv[1], side=side, rotate=BuffSplitCap.r270)

    window_name = "SplitCap test"
    cv2.namedWindow(window_name)

    # loop
    while cap.isOpened():
        cv2.imshow(window_name, cap.frame(side))
        sys.stdout.write(cap.status() + "\r")
        sys.stdout.flush()

        # controls
        key = cv2.waitKey(0)
        if key == 0xFF & ord('q'):
            break