opencv——inRange
2016-05-24 10:06
471 查看
#include <opencv2\opencv.hpp> #include <iostream> using namespace cv; void callback1(int pos, void*) { std::cout << "hmin" << pos << std::endl; } void callback2(int pos, void*) { std::cout << "smin" << pos << std::endl; } void callback3(int pos, void*) { std::cout << "vmin" << pos << std::endl; } void callback4(int pos, void*) { std::cout << "hmax" << pos << std::endl; } void callback5(int pos, void*) { std::cout << "smax" << pos << std::endl; } void callback6(int pos, void*) { std::cout << "vmax" << pos << std::endl; } int main() { Mat src, hsv, dst; int hmin = 0; int smin = 0; int vmin = 0; int hmax = 255; int smax = 255; int vmax = 255; src = imread("../data/baboon.jpg"); imshow("src", src); cvtColor(src, hsv, CV_RGB2HSV); createTrackbar("hmin", "src", &hmin, 256, callback1); createTrackbar("smin", "src", &smin, 256, callback2); createTrackbar("vmin", "src", &vmin, 256, callback3); createTrackbar("hmax", "src", &hmax, 256, callback4); createTrackbar("smax", "src", &smax, 256, callback5); createTrackbar("vmax", "src", &vmax, 256, callback6); while (1)//循环包裹,刷新图像 { inRange(hsv, Scalar(hmin, smin, vmin), Scalar(hmax, smax, vmax), dst); imshow("dst", dst); int c = waitKey(10); if (c == 'q')break; } }
以上是代码,主要练习inRange函数
createTrackbar可以while循环刷新图像,替代回调函数。
相关文章推荐
- U盘安装CentOS7遇到:init... timeout
- Competition and cooperation between active intra-network and passive extra-network transport process
- Java_ClassLoader内存溢出-从tomcat的reload说起
- 分步LVS: 详解利用Keepalived+Nginx解决站点高可用性
- Linux C语言strlcpy,strlcat函数
- OpenCV自适应阈值
- Ubuntu下映射Linux服务器(Ubuntu服务器)到本地
- linux:档案与档案系统的压缩、打包与备份
- Linux 平台下阅读源码的工具链
- linux命令之------vmstat使用
- linux 下安装gtk的办法
- [Linux] Nutch 2.3.1+ Hbase + Hadoop + Solr 单机指南(二)
- 并发容器CopyOnWriteArrayList
- 一个nginx反向代理, 负载均衡的例子
- CentOS FastDFS配置之常见错误
- 五个知识体系之-Linux常用命令学习
- [Linux] Nutch 2.3.1+ Hbase + Hadoop + Solr 单机指南(一)
- Nginx 之六: Nginx十万并发优化
- linux命令总结
- Linux Wireless架构总结