How To Detect Red Color In OpenCV Python?

后端 未结 2 327
我在风中等你
我在风中等你 2021-01-07 09:11

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 OpenCV Documentation. The code is gi

2条回答
  •  执念已碎
    2021-01-07 10:05

    Running the same code for red seems to work:

    >>> red = numpy.uint8([[[0,0,255]]])
    >>> hsv_red = cv2.cvtColor(red,cv2.COLOR_BGR2HSV)
    >>> print(hsv_red)
    [[[  0 255 255]]]
    

    And then you can try different colors that appear reddish. Beware that the red range includes both numbers slightly greater than 0 and numbers slightly smaller than 179 (e.g. red = numpy.uint8([[[0,31,255]]]) results in [[[ 4 255 255]]] whereas red = numpy.uint8([[[31,0,255]]]) results in [[[176 255 255]]].

提交回复
热议问题