在open cv中检测橙色的推荐色彩空间是什么? [英] what are recommended color spaces for detecting orange color in open cv?

查看:901
本文介绍了在open cv中检测橙色的推荐色彩空间是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个合适的色彩空间来检测与红色和黄色非常相似的颜色之上的橙色。我已经尝试了一些色彩空间:RGB HSV& YUV但我要检测的对象,改变它的位置,这意味着环境光随时间变化而变化。这是我的主要问题。

解决方案

HSV是用于颜色检测的良好色彩空间。
这是一个hsv色彩图供参考:



>



x轴表示[0,180]中的Hue,y轴1表示[0,255]中的饱和度,y轴2表示S = 255,而保持V = 255。



要查找颜色,通常只需查找H和S的范围,并将v设置为范围(20,255)。






例如:



  1. 检测橙色


我的另一个答案的详细信息:





  1. 检测两种不同的颜色


如何使用两种不同颜色检测Python-OpenCV中的`cv2.inRange`?




I need a suitable color-space to detect orange color above very similar colors as red and yellow.I have already tried some color-spaces as :RGB HSV & YUV but object i want to detect , changes its position which means the environmental light changes over time & this is my main problem .

解决方案

HSV is a good color space for color detection. This is a hsv colormap for reference:

The x-axis represents Hue in [0,180), the y-axis1 represents Saturation in [0,255], the y-axis2 represents S = 255, while keep V = 255.

To find a color, usually just look up for the range of H and S, and set v in range(20, 255).


For example:

  1. detect orange

Details from my another answer: Choosing the correct upper and lower HSV boundaries for color detection with`cv::inRange` (OpenCV)

To find the orange color, we look up for the map, and find the best range: H :[10, 25], S: [100, 255], and V: [20, 255]. So the mask is cv2.inRange(hsv,(10, 100, 20), (25, 255, 255) )

#!/usr/bin/python3
# 2018.01.21 20:46:41 CST
import cv2

img = cv2.imread("test.jpg")
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
mask = cv2.inRange(hsv,(10, 100, 20), (25, 255, 255) )
cv2.imshow("orange", mask);cv2.waitKey();cv2.destroyAllWindows()

The result:

  1. detect green / yellow/ blue

How to define a threshold value to detect only green colour objects in an image :Opencv

  1. detect two different colors

How to detect two different colors using `cv2.inRange` in Python-OpenCV?

这篇关于在open cv中检测橙色的推荐色彩空间是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆