title: How To Detect Red Color In OpenCV Python?
body: <p>I am trying to detect red color from the video that's being taken from my webcam. The following code example given below is taken from <a href="http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_colorspaces/py_colorspaces.html" rel="nofollow">OpenCV Documentation.</a> 
  The code is given below:</p>
  
  <pre><code>import cv2
  import numpy as np
  
  cap = cv2.VideoCapture(0)
  
  while(1):
  
      # Take each frame
      _, frame = cap.read()
  
      # Convert BGR to HSV
      hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
  
      # define range of blue color in HSV
      lower_blue = np.array([110,50,50])
      upper_blue = np.array([130,255,255])
  
      # Threshold the HSV image to get only blue colors
      mask = cv2.inRange(hsv, lower_blue, upper_blue)
  
      # Bitwise-AND mask and original image
      res = cv2.bitwise_and(frame,frame, mask= mask)
  
      cv2.imshow('frame',frame)
      cv2.imshow('mask',mask)
      cv2.imshow('res',res)
      k = cv2.waitKey(5) &amp; 0xFF
      if k == 27:
          break
  
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>The line <code>lower_blue = np.array([110,50,50])</code> has the lower range Blue HSV value and the line <code>upper_blue = np.array([130,255,255])</code> has the higher range Blue HSV value. I have looked for the upper value and lower value of Red color on internet but I couldn't find it. It would be very helpful if anyone could tell the HSV value of Red for OpenCV (OpenCV H value ranges from 0 - 179). 
  Thanks a lot for help (In Advance). </p>
  
  <p>I have also tried running the following to find the range of Red but I was unable to pick proper value maybe. What I tried was this(for red):</p>
  
  <pre><code>&gt;&gt;&gt; green = np.uint8([[[0,255,0 ]]])
  &gt;&gt;&gt; hsv_green = cv2.cvtColor(green,cv2.COLOR_BGR2HSV)
  &gt;&gt;&gt; print hsv_green
  [[[ 60 255 255]]]
  </code></pre>
  
  <p>This was also taken from OpenCV documentation.
  Please tell me or help me find the RANGE of RED COLOR for OpenCV.</p>