# Path: video_processing/stream_processor.py
# class Frame(collections.namedtuple('FrameSet', ['index', 'data'])):
# class StreamSet(collections.namedtuple('StreamSet', ['frame_rate_hz',
#                                                      'stream_headers'])):
# class ProcessorBase(object):
#   def __new__(cls, index=0, data=None):
#   def __new__(cls, frame_rate_hz=-1):
#   def __init__(self, configuration):
#   def open(self, stream_set):
#   def process(self, frame_set):
#   def close(self):


import collections
import numpy as np
import cv2
from six.moves import range
from video_processing import stream_processor
    else:
      # If the presenter was writing, we're now confident that they've stopped.
      if self._is_writing:
        self._is_writing = False

        # Now we find out what was added in the period since the presenter
        # started writing, by differencing the start and end frames.
        crop, bounding_box = get_cropped_frame_difference(
            start_frame=self._object_start_image, end_frame=frame,
            cursor_template=self._cursor_image)
        (r, g, b) = get_color(crop)

        # Pass this object on to downstream processors, along with the inferred
        # color, and the path that the cursor took, for future processing.

        # Note that this object data structure is compatible both with the
        # stroke_tracker processor, which will try to more accurately track the
        # strokes within the object, and with the json_writer directly, which
        # will use the tracked cursor locations directly to plot strokes. This
        # latter option is useful for debugging.
        object_data = {
            'start': self._start_timestamp,
            'end': frame_index,
            'strokes': [[list(e) for e in self._cursor_path]],
            'crop': crop,
            'bounding_box': bounding_box,
            'color': (r, g, b)
        }
        # DEBUG
        # cv2.imwrite('/tmp/' + str(frame_index) + '.png', crop)

# Path: video_processing/stream_processor.py
# class Frame(collections.namedtuple('FrameSet', ['index', 'data'])):
# class StreamSet(collections.namedtuple('StreamSet', ['frame_rate_hz',
#                                                      'stream_headers'])):
# class ProcessorBase(object):
#   def __new__(cls, index=0, data=None):
#   def __new__(cls, frame_rate_hz=-1):
#   def __init__(self, configuration):
#   def open(self, stream_set):
#   def process(self, frame_set):
#   def close(self):


# Path: video_processing/processors/added_object_tracker.py
import collections
import numpy as np
import cv2
from six.moves import range
from video_processing import stream_processor

    else:
      # If the presenter was writing, we're now confident that they've stopped.
      if self._is_writing:
        self._is_writing = False

        # Now we find out what was added in the period since the presenter
        # started writing, by differencing the start and end frames.
        crop, bounding_box = get_cropped_frame_difference(
            start_frame=self._object_start_image, end_frame=frame,
            cursor_template=self._cursor_image)
        (r, g, b) = get_color(crop)

        # Pass this object on to downstream processors, along with the inferred
        # color, and the path that the cursor took, for future processing.

        # Note that this object data structure is compatible both with the
        # stroke_tracker processor, which will try to more accurately track the
        # strokes within the object, and with the json_writer directly, which
        # will use the tracked cursor locations directly to plot strokes. This
        # latter option is useful for debugging.
        object_data = {
            'start': self._start_timestamp,
            'end': frame_index,
            'strokes': [[list(e) for e in self._cursor_path]],
            'crop': crop,
            'bounding_box': bounding_box,
            'color': (r, g, b)
        }
        # DEBUG
        # cv2.imwrite('/tmp/' + str(frame_index) + '.png', crop)

        frame_set[self._object_stream_name] = stream_processor.Frame(