# 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
  x2 = min(x2 + border_pixels, difference_image.shape[1])
  y2 = min(y2 + border_pixels, difference_image.shape[0])
  crop = difference_image[y1:y2, x1:x2]
  return crop, (x1, y1, x2 - x1, y2 - y1)


def get_color(image):
  """Get color of a contour."""
  threshold_black = 10
  reds = [0]
  greens = [0]
  blues = [0]

  for x in range(0, image.shape[0]):
    for y in range(0, image.shape[1]):

      if image[x, y][0] > threshold_black:
        blues.append(image[x, y][0])
      if image[x, y][1] > threshold_black:
        greens.append(image[x, y][1])
      if image[x, y][2] > threshold_black:
        reds.append(image[x, y][2])

  return [
      np.percentile(np.array(reds), 90),
      np.percentile(np.array(greens), 90),
      np.percentile(np.array(blues), 90)
  ]



# 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

  x2 = min(x2 + border_pixels, difference_image.shape[1])
  y2 = min(y2 + border_pixels, difference_image.shape[0])
  crop = difference_image[y1:y2, x1:x2]
  return crop, (x1, y1, x2 - x1, y2 - y1)


def get_color(image):
  """Get color of a contour."""
  threshold_black = 10
  reds = [0]
  greens = [0]
  blues = [0]

  for x in range(0, image.shape[0]):
    for y in range(0, image.shape[1]):

      if image[x, y][0] > threshold_black:
        blues.append(image[x, y][0])
      if image[x, y][1] > threshold_black:
        greens.append(image[x, y][1])
      if image[x, y][2] > threshold_black:
        reds.append(image[x, y][2])

  return [
      np.percentile(np.array(reds), 90),
      np.percentile(np.array(greens), 90),
      np.percentile(np.array(blues), 90)
  ]



class AddedObjectTracker(stream_processor.ProcessorBase):