首页 > 代码库 > OpenCV Tutorials —— Launching Viz
OpenCV Tutorials —— Launching Viz
Explanation
- Create a window.
- Start event loop. This event loop will run until user terminates it by pressing e, E, q, Q.
- Access same window via its name. Since windows are implicitly shared, sameWindow is exactly the same withmyWindow. If the name does not exist, a new window is created.
- Start a controlled event loop. Once it starts, wasStopped is set to false. Inside the while loop, in each iteration, spinOnce is called to prevent event loop from completely stopping. Inside the while loop, user can execute other statements including those which interact with the window.
Code
#include <opencv2/viz/vizcore.hpp>#include <iostream>using namespace cv;using namespace std;/*** @function main*/int main(){ /// Create a window viz::Viz3d myWindow("Viz Demo"); /// Start event loop myWindow.spin(); /// Event loop is over when pressed q, Q, e, E cout << "First event loop is over" << endl; /// Access window via its name viz::Viz3d sameWindow = viz::getWindowByName("Viz Demo"); /// Start event loop sameWindow.spin(); /// Event loop is over when pressed q, Q, e, E cout << "Second event loop is over" << endl; /// Event loop is over when pressed q, Q, e, E /// Start event loop once for 1 millisecond sameWindow.spinOnce(1, true); while(!sameWindow.wasStopped()) { /// Interact with window /// Event loop for 1 millisecond sameWindow.spinOnce(1, true); } /// Once more event loop is stopped cout << "Last event loop is over" << endl; return 0;}
OpenCV Tutorials —— Launching Viz
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。