视频颜色识别
来源:互联网 发布:2017淘宝网红排行榜 编辑:程序博客网 时间:2024/05/21 10:45
#include <opencv2/opencv.hpp>#include <iostream>using namespace std;using namespace cv;int minh,maxh,mins,maxs,minv,maxv;void helptext(){ cout << "B——黑色\n"; cout << "H——灰色\n"; cout << "W——白色\n"; cout << "R——红色\n"; cout << "O——橙色\n"; cout << "Y——黄色\n"; cout << "G——绿色\n"; cout << "L——蓝色\n"; cout << "P——紫色\n"; cout << "输入要求识别的颜色对应的字母:" ;}void deal(char color){ switch(color){ case 'B': minh = 0; maxh = 180; mins = 0; maxs = 255; minv = 0; maxv = 46; break; case 'H': minh = 0; maxh = 180; mins = 0; maxs = 43; minv = 46; maxv = 220; break; case 'W': minh = 0; maxh = 180; mins = 0; maxs = 30; minv = 221; maxv = 255; break; case 'R': minh = 0; maxh = 10; mins = 43; maxs = 255; minv = 46; maxv = 255; break; case 'O': minh = 11; maxh = 25; mins = 43; maxs = 255; minv = 46; maxv = 255; break; case 'Y': minh = 26; maxh = 25; mins = 43; maxs = 255; minv = 46; maxv = 255; break; case 'G': minh = 35; maxh = 77; mins = 43; maxs = 255; minv = 46; maxv = 255; break; case 'L': minh = 100; maxh = 124; mins = 43; maxs = 255; minv = 46; maxv = 255; break; case 'P': minh = 125; maxh = 155; mins = 43; maxs = 255; minv = 46; maxv = 255; break; default: cout << "输入错误" << endl; exit(0); }}int main( ){ VideoCapture capture(0); Mat special; helptext(); char color; cin >> color; deal(color); while(1){ Mat frame; //存储每一帧的图像 capture >> frame; //读取当前帧 Mat fhsv; cvtColor(frame,fhsv,COLOR_BGR2HSV); //将图像转换为HSV模型 inRange(fhsv,Scalar(minh,mins,minv),Scalar(maxh,maxs,maxv),special); //找寻在要求区间内的颜色 imshow("ABC",special); if(waitKey(30) >= 0)break; } return 0;}
0 0
- 视频颜色识别
- 颜色识别
- 颜色识别
- 颜色识别
- 颜色识别代码--初版
- opencv 颜色识别
- OpenCV颜色识别
- OpenCV颜色识别
- OpenCV颜色识别
- OpenCV颜色识别
- opencv 颜色识别
- Opencv颜色识别
- OpenCV颜色识别
- opencv颜色识别
- opencv颜色识别一
- OPENCV颜色识别
- opencv 颜色识别
- Java+Opencv 颜色识别
- 八大免费SSL证书-给你的网站免费添加Https安全加密
- 递归算法判断数组是否为一个递增数组
- 二、servlet不同页面共享数据的四中方式
- ROI图像分割
- linux 文件系统简介
- 视频颜色识别
- Redux 入门教程
- 【C解析之四】指针
- CSS3代码编写中有哪些注意事项?
- 单片机基础c语言之条件编译
- 异常总结
- android仿ios弹框,带动画效果
- android bitmap问题
- 【C解析之四】指针