OpenCV学习HighGUI
2016-05-22 08:54
483 查看
// Create windows namedWindow("xuelian", CV_GUI_NORMAL);//WINDOW_NORMAL: 可以改变窗口大小 namedWindow("shihui", WINDOW_AUTOSIZE);//WINDOW_AUTOSIZE: 根据图像大小显示窗口,大小不可改变 // Move window显示窗口的位置 moveWindow("xuelian", 10, 10); moveWindow("shihui", 520, 10); // show images imshow("xuelian", picture1); imshow("shihui", picture2); // Resize window, only non autosize resizeWindow("xuelian", 512, 512); waitKey(0);//等待任意键按下 // Destroy the windows destroyWindow("xuelian"); destroyWindow("shihui"); // Create 10 windows for (int i = 0; i< 10; i++) { ostringstream ss; ss << "shuhui " << i; namedWindow(ss.str()); moveWindow(ss.str(), 20 * i, 20 * i); imshow(ss.str(), picture2); } waitKey(0); // Destroy all windows destroyAllWindows(); return 0;
using namespace std; using namespace cv; Mat img; bool applyGray = false; bool applyBlur = false; bool applySobel = false; void applyFilters(); void grayCallback(int state, void* userData) { applyGray = true; applyFilters(); } void bgrCallback(int state, void* userData) { applyGray = false; applyFilters(); } void blurCallback(int state, void* userData) { applyBlur = (bool)state; applyFilters(); } void sobelCallback(int state, void* userData) { applySobel = !applySobel; applyFilters(); } void applyFilters(){ Mat result; img.copyTo(result); if (applyGray){ cvtColor(result, result, COLOR_BGR2GRAY); } if (applyBlur){ blur(result, result, Size(5, 5)); } if (applySobel){ Sobel(result, result, CV_8U, 1, 1); } imshow("xuelian", result); } int main(int argc, const char** argv) { Mat img = imread("E://VS2013//face//xuelian//jpg//1.jpg");//载入图像 见 // Create windows namedWindow("xuelian"); // create Buttons 每个按钮有5个参数分别是:按钮名字;回调函数;传给回调函数的数据指针;按钮类别;默认的按钮初始化值 createButton("Blur", blurCallback, NULL, QT_CHECKBOX, 0); createButton("Gray", grayCallback, NULL, QT_RADIOBOX, 0); createButton("RGB", bgrCallback, NULL, QT_RADIOBOX, 1); createButton("Sobel", sobelCallback, NULL, QT_PUSH_BUTTON, 0); // wait app for a key to exit waitKey(0); // Destroy the windows destroyWindow("xuelian"); return 0; }
相关文章推荐
- 1626 - Brackets sequence——[动态规划]
- 303. Range Sum Query - Immutable
- [leetcode] 【数组】128. Longest Consecutive Sequence
- 基于Vue.js的表格分页组件
- 关于easyui整合polymer中tab切换页面不匹配的解决(更新中)
- Android中在子线程中更新UI的三种方式
- Android Studio 中build.gradle文件的详细解析
- iOS 3D Touch 实现UITableViewCell 预览
- Ubuntu使用sudo命令出现must be setuid root错误的解决方法
- 60. Permutation Sequence
- LeetCode 63. Unique Paths II(唯一路径)
- LeetCode 62. Unique Paths
- UISplitViewController 分屏控制器
- UITableView初识(1)
- UITableView--多组数据显示
- 从技术实现角度看Android UI设计
- Arduino 和 MQ-135 空气污染气体传感器 实验
- iOS学习之UIView
- 29.UITabBarController
- Hive ORC和Parquet