# 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 numpy as np
import cv2
from video_processing import stream_processor
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function




class FirstFrameBackgroundImageExtractor(stream_processor.ProcessorBase):
  """Processor that copies the first frame to a background image stream.

  Optionally, if background_image_file_name is set, the image can also be
  written to a file.
  """

  def __init__(self, configuration):
    self._video_stream_name = configuration.get('video_stream_name', 'video')
    self._background_stream_name = configuration.get(
        'background_image_stream_name', 'background_image')
    self._background_file_name = configuration.get('background_image_file_name',
                                                   None)
    self._image_width = 0
    self._image_height = 0
    self._done = False

  def open(self, stream_set):
    headers = stream_set.stream_headers[self._video_stream_name].header_data
    self._image_width = headers.image_width
    self._image_height = headers.image_height
    self._num_frames = headers.num_frames
    stream_set.stream_headers[

# 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/background_image_extractor.py
import numpy as np
import cv2
from video_processing import stream_processor

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function




class FirstFrameBackgroundImageExtractor(stream_processor.ProcessorBase):
  """Processor that copies the first frame to a background image stream.

  Optionally, if background_image_file_name is set, the image can also be
  written to a file.
  """

  def __init__(self, configuration):
    self._video_stream_name = configuration.get('video_stream_name', 'video')
    self._background_stream_name = configuration.get(
        'background_image_stream_name', 'background_image')
    self._background_file_name = configuration.get('background_image_file_name',
                                                   None)
    self._image_width = 0
    self._image_height = 0
    self._done = False

  def open(self, stream_set):
    headers = stream_set.stream_headers[self._video_stream_name].header_data
    self._image_width = headers.image_width
    self._image_height = headers.image_height
    self._num_frames = headers.num_frames
    stream_set.stream_headers[

        self._background_stream_name] = stream_processor.StreamHeader(