HSV to RGB Color Conversion

后端 未结 9 1687
离开以前
离开以前 2020-12-14 01:16

Is there a way to convert HSV color arguments to RGB type color arguments using pygame modules in python? I tried the following code, but it returns ridiculous values.

9条回答
  •  醉酒成梦
    2020-12-14 01:38

    In opencv, use any of their color conversions. Note that BGR and RGB are flipped in cv2 land.

    def convertColor(hsv, conversion):
        return tuple(int(i) for i in cv2.cvtColor(np.uint8([[hsv]]), conversion).flatten())
    

    Usage:

    hsvColor = (0,255,255) #bright red
    bgrColor = convertColor(hsvColor, cv2.COLOR_HSV2BGR)
    

提交回复
热议问题