title: Can't get my multicolor detection array to work(Python & OpenCV)
body: <p>I'm trying to use a numpty array to store certain colors (HSV values) in order to be able to detect them later on by using tests. However, when I run my test it doesn't succeed. Here's the code:</p>
  
  <pre><code>#!/usr/bin/env python
  import cv2
  import numpy as np
  
  class DetectAColor(object):
  
      @staticmethod
      def detect_a_color(image):
          img_hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
  
          boundaries = {
              'red': ([0, 100, 100],[10, 255, 255]),
              'brown': ([14, 100, 100],[15, 255, 255]),
              'orange': ([16, 100, 100],[17, 255, 255]),
              'yellow': ([29, 100, 100],[31, 255, 255]),
              'green': ([50, 100, 100],[60, 255, 255]),
              'lightblue': ([50, 100, 100],[60, 255, 255]),
              'darkblue': ([115, 100, 100],[125, 255, 255]),
              'purple': ([149, 150, 100],[150, 255, 255]),
              'pink': ([149, 100, 150],[149, 100, 150])
              }
  
          for k,v in boundaries.iteritems():
              lower_color = np.array(v[0])
              upper_color = np.array(v[1])
  
              mask = cv2.inRange(img_hsv, lower_color, upper_color)
              amount_not_zero = cv2.countNonZero(mask)
              if amount_not_zero &gt; 9000:
                  return k
              else:
                  return "Not found"
  </code></pre>
  
  <p>I'm testing this code with this simple test (and display the image to be 100% sure):</p>
  
  <pre><code>def test_detect_red(self):
      image = np.zeros((512, 512, 3), np.uint8)
      image[:,0:512] = (0, 0, 255) # B G R values
      color = DetectAColor.detect_a_color(image)
      cv2.imshow('image',image)
      cv2.waitKey(0)
      cv2.destroyAllWindows()
  
      # Controle dat de kleur gevonden wordt
      self.assertEqual("red", color)
  </code></pre>
  
  <p>I find it quite odd that this code isn't working, since at first it was working using the code to just detect 1 color:</p>
  
  <pre><code>#!/usr/bin/env python
  import cv2
  import numpy as np
  
  class DetectAColor(object):
  
      @staticmethod
      def detect_a_color(image):
          img_hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
          TRACK_COLOR_MIN = np.array([0, 100, 100], np.uint8)
          TRACK_COLOR_MAX = np.array([15, 255, 255], np.uint8)
  
          mask = cv2.inRange(img_hsv, TRACK_COLOR_MIN, TRACK_COLOR_MAX)
  
          cv2.imshow('mask',mask)
          cv2.waitKey(0)
          cv2.destroyAllWindows()
  
          amount_not_zero =  cv2.countNonZero(mask)
          if amount_not_zero &gt; 9000:
              return "Found"
          else:
              return "Not found"
  </code></pre>
  
  <p>I understand the the value for H is a bit different, but I tried it with the same value as in the 1 color code and it failed as well. We've already calculated the values we needed and tested them with the 1 color method and it worked. So I need to know why I can't get it to work using the array and for loop.</p>