title: OpenCV (Python) Drawing on Videos, Tracking
body: <pre><code># libraries that will be needed
  import numpy as np  # numpy
  import cv2          # opencv
  import imutils      # allows video editing
  import random       
  from imutils.object_detection import non_max_suppression
  from imutils import paths
  import imutils
  import cv2
  
  #default HOG
  hog = cv2.HOGDescriptor()
  hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
  
  
  # function to trak people
  def tracker(cap):
      while True:
          ret, img = cap.read()
  
      # if video stopped playing, quit
      if ret == False:
          break
  
          # resize window
          img = imutils.resize(img, width = 400)
          # convert to graysclae and equalize
          gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
          gray = cv2.equalizeHist(gray)
  
          # detect people
          rects, weights = hog.detectMultiScale(gray, winStride = (8, 8), padding = (8, 8), scale = 1.25)
          # store detected people in array
          rects = np.array([[x, y, x+w, y+h] for(x, y, w, h) in rects] )
          # find largest possible rectangel to avoid detection
          # of same person several times
          biggest = non_max_suppression(rects, probs = None, overlapThresh = 0.65)
  
          # draw largest rectangle
          for (xA, yA, xB, yB) in biggest:
              # create random color
              color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
              cv2.rectangle(img, (xA, yA), (xB, yB), color, 2)        
  
          # show image
          cv2.imshow('Image', img)
  
          k = cv2.waitKey(30) &amp; 0xFF
          if k == 27:
              break
  # run video
  cap = cv2.VideoCapture('NYC.mp4')
  tracker(cap)
  # release frame and destroy windows
  cap.release()
  cv2.destroyAllWindows
  </code></pre>
  
  <p>I am attempting to track multiple people at once using OpenCV. Once a person is detected, I draw a rectangle around them. I am having trouble having a random/different color box for each person while maintaining the same color box for a person after they have been detected.</p>
  
  <p>Currently, a person is detected and a box is drawn. In the next frame, if they are still detected a new colored box is drawn, but I would like to maintain the original color.</p>
  
  <p>Also open to tips/tricks that will improve my code and tracking since I am very new to this.</p>