- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须区分5种类型的图像,这些图像可能主要是红色,绿色,蓝色,橙色或黄色,而白色或黑色。我必须找到图像中突出的颜色。
图像来源是网络摄像头,因此实际颜色还取决于图像的照明度和距网络摄像头的距离。我的图像的示例可以在这里看到:
http://ian-albert.com/hazmat_placards/placard-2-flammable-gas.png
我正在尝试根据“色相”值计算百分比。我为每种颜色指定了一些范围。我的范围是:
红色: 0-10
绿色: 50-65
黄色: 18-21
蓝色: 100-115
问题:即使显示的图像不是红色,我的红色百分比还是很高。
我的代码如下:
int findRect::checkByHSV(int svmResult, Mat detectedSquare)
{
Mat hsv_img;
cvtColor(detectedSquare,hsv_img,CV_BGR2HSV);
Vec3b pixel;
float totalPixel=0; // to count the total number of pixels in an image---to get the Percentage later
float totalClass[6];// because we want to test for 5 classes+ a garbage class.{{ Class-0 -> Garbage, Class-1->Orange, Class-2->Green, Class-3->Red,
// Class-4->Blue, Class-5->Yellow }}
for(int i=0; i<hsv_img.rows; i++)
{
for (int j=0; j<hsv_img.cols; j++)
{
totalPixel++;
pixel= hsv_img.at<Vec3b>(i,j);
if( pixel[0]>0 && pixel[0]<1 ) totalClass[1]++; // Class-1->Orange
else if ( pixel[0]>50 && pixel[0]<65 ) totalClass[2]++; // To check Green class-2 //svmResult==2 &&
else if ( pixel[0]>0 && pixel[0]<10 ) totalClass[3]++; // Class-3->Red
else if ( pixel[0]>100 && pixel[0]<115 ) totalClass[4]++; // Class-4->Blue
else if ( pixel[0]>18 && pixel[0]<21 ) totalClass[5]++; // Class-5->Yellow
}
}
float percentage[5];
totalClass[0]=0; //Putting zero to the Garbage class
for (int i=0; i<=5; i++)
{
percentage[i] = (totalClass[i] / totalPixel )*100;
}
cout<<"\n Organge: "<<percentage[1]<<" Green: "<<percentage[2]<<" Red: "<<percentage[3]<<" Blue: "<<percentage[4]<<" Yellow: "<<percentage[5]<<"\n \n";
return svmResult;
}
最佳答案
您提到您可以有一些白色和/或一些黑色。
HSV允许您具有H分量的任何值,并且:
关于opencv - 在Opencv中提取图像中颜色(红色,蓝色,绿色,黄色,橙色)的百分比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21462502/
我阅读了 Orange 3 的文档。它说“小部件可以从 (Postgres) SQL 读取数据并传递查询。轴万岁!'。 Orange 3 还会支持 MySQl 编写 Sql 查询吗? 最佳答案 Ora
Eclipse 运行异常。它将每个日志项显示为警告(橙色)。此外,每个人的Time都是'?:??',PID是'?',Tag也是'?'。 截图如下 最佳答案 您的 Eclipse 或 SDK 似乎已过时
是否有 boost::irange 的扩展,它只接受一个 int 参数,使用 0 作为默认的 first 参数和给定的int 作为原始 irange 中的 last 参数? 例如,我已经可以这样做了:
有没有办法轻松地将给定的十六进制颜色代码分配给更一般的类别(红色、绿色、蓝色、黄色、橙色、粉色、黑色、白色、灰色……)? 比如 #ffcc55 -> 橙色,#f0f0f0 -> 白色,... 编辑:甚
如何变换:cut(Orange.class) -> cut(Orange) 剪切函数如下所示: protected T cut(Class fruitClass){ try {
我正尝试在我的 Mac 上使用 Orange3,但出现此错误:ImportError: cannot import name '_variable'。 这是我的设置: $ cd orange_play
我必须区分5种类型的图像,这些图像可能主要是红色,绿色,蓝色,橙色或黄色,而白色或黑色。我必须找到图像中突出的颜色。 图像来源是网络摄像头,因此实际颜色还取决于图像的照明度和距网络摄像头的距离。我的图
我有一个 Orange Pi Zero,我已经在上面刷了 DietPi。它没有 HDMI,所以我需要通过 Putty(或类似的程序)连接到它。问题是我无法获取设备的 IP 地址,这似乎是我通过 Put
我是一名优秀的程序员,十分优秀!