title: OpenCv Project Guidance for tracking humans
body: <p>I am currently making a program with OpenCv that detects 2 colours. My next step is to leave a &quot;translucent&quot; path of where both these colours have moved. The idea is that every time they cross over their trail it will get a shade darker.</p>
  <p>Here is my current code:</p>
  <pre><code># required libraries
  import cv2
  import numpy as np
  
  # main function
  
  
  def main():
  
      # returns vid from camera -- cameras are indexed(0 is the front camera, 1 is rear)
      cap = cv2.VideoCapture(0)
  
      # cap is opened if pc is receiving cam data
      if cap.isOpened():
          ret, frame = cap.read()
  
      else:
          ret = False
  
      while ret:
          ret, frame = cap.read()
  
          # setting color range
          hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
          # BLUE color range
          blue_low = np.array([100, 50, 50])
          blue_high = np.array([140, 255, 255])
          # GREEN color range
          green_low = np.array([40, 40, 40])
          green_high = np.array(([80, 255, 255]))
  
          # creating masks
          blue_mask = cv2.inRange(hsv, blue_low, blue_high)
          green_mask = cv2.inRange(hsv, green_low, green_high)
  
          # combination of masks
          blue_green_mask = cv2.bitwise_xor(blue_mask, green_mask)
          blue_green_mask_colored = cv2.bitwise_and(blue_mask, green_mask, mask=blue_green_mask)
  
          # create the masked version (shows the background black and the specified color the color coming through cam)
          output = cv2.bitwise_and(frame, frame, mask=blue_green_mask)
  
          # create/open windows
          cv2.imshow(&quot;image mask&quot;, blue_green_mask)
          cv2.imshow(&quot;orig webcam feed&quot;, frame)
          cv2.imshow(&quot;color tracking&quot;, output)
  
          # if q is pressed the project breaks
          if cv2.waitKey(1) &amp; 0xFF == ord('q'):
              break
      # once broken the program will run remaining instructions (closing windows and stopping cam)
      cv2.destroyAllWindows()
      cap.release
  
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p>My question now is how would I add the trail of where both colours have gone? I have also read that I will run into a problem when the trail is implemented as insignificant objects may be detected as one of the colours and leave an unwanted trail.. meaning I will need to find a way to only trail the largest object of the specified colours.</p>
  <p><strong>EDIT:</strong>
  For further clarification:
  I am using 2 black highlighters (one with a blue cap and one with a green cap).
  With regards to the trail I am referring to something similar to this:..
  <a href="https://i.stack.imgur.com/fUZLQ.png" rel="nofollow noreferrer">trail clarification</a></p>
  <p>This guy did an okay job at explaining it but I was still very confused which is why I came to stack overflow for help.</p>
  <p>with the trails; I would like for them to be 'translucent' and not solid like in the picture above. therefore if the object crosses over its path again that section of the path will become a shade darker.</p>
  <p>hope this helped:)</p>