在整个图像上使用opencv检测颜色 [英] Detect a color with opencv on an entire image

查看:311
本文介绍了在整个图像上使用opencv检测颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I would like to detect color on an entire image, instead of just doing this in a specific place, so that the app can tell if the color exists on the entire image.
I am using openCV for android.
Thanks.





我的尝试:



我目前有一个使用openCV检测颜色的应用程序,但是在触摸时,我需要更改它并在一个间隔内检测整个图像上的颜色。

谢谢。



What I have tried:

I currently have an application that detects colors with openCV, but on touch, and I need to change this and detect colors on an entire image with an interval.
Thanks.

推荐答案

Unfortunately, OpenCV doesn't provide any sort of indication as to the color space in the IplImage structure, so if you blindly pick up an IplImage from somewhere there is just no way to know how it was encoded. Furthermore, no algorithm can definitively tell you if an image should be interpreted as HSV vs. RGB - it's all just a bunch of bytes to the machine (should this be HSV or RGB?). I recommend you wrap your IplImages in another struct (or even a C++ class with templates!) to help you keep track of this information. If you're really desperate and you're dealing only with a certain type of images (outdoor scenes, offices, faces, etc.) you could try computing some statistics on your images (e.g. build histogram statistics for natural RGB images and some for natural HSV images), and then try to classify your totally unknown image by comparing which color space your image is closer to.


这篇关于在整个图像上使用opencv检测颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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