opencv/samples/cpp/tutorial_code/viz/launching_viz.cpp

67 lines
1.7 KiB
C++
Raw Normal View History

2013-09-06 02:53:57 +08:00
/**
* @file launching_viz.cpp
* @brief Launching visualization window
* @author Ozan Cagri Tonkal
*/
2013-09-02 03:43:40 +08:00
#include <opencv2/viz.hpp>
#include <iostream>
using namespace cv;
using namespace std;
2013-09-06 02:53:57 +08:00
/**
* @function help
* @brief Display instructions to use this tutorial program
*/
2013-09-02 03:43:40 +08:00
void help()
{
cout
<< "--------------------------------------------------------------------------" << endl
<< "This program shows how to launch a 3D visualization window. You can stop event loop to continue executing. "
<< "You can access the same window via its name. You can run event loop for a given period of time. " << endl
<< "Usage:" << endl
2013-09-06 02:53:57 +08:00
<< "./launching_viz" << endl
2013-09-02 03:43:40 +08:00
<< endl;
}
2013-09-06 02:53:57 +08:00
/**
* @function main
*/
2013-09-02 03:43:40 +08:00
int main()
{
help();
/// Create a window
viz::Viz3d myWindow("Viz Demo");
2013-09-18 19:50:55 +08:00
2013-09-02 03:43:40 +08:00
/// Start event loop
myWindow.spin();
2013-09-18 19:50:55 +08:00
2013-09-02 03:43:40 +08:00
/// Event loop is over when pressed q, Q, e, E
cout << "First event loop is over" << endl;
2013-09-18 19:50:55 +08:00
2013-09-02 03:43:40 +08:00
/// Access window via its name
viz::Viz3d sameWindow = viz::get("Viz Demo");
2013-09-18 19:50:55 +08:00
2013-09-02 03:43:40 +08:00
/// Start event loop
sameWindow.spin();
2013-09-18 19:50:55 +08:00
2013-09-02 03:43:40 +08:00
/// Event loop is over when pressed q, Q, e, E
cout << "Second event loop is over" << endl;
2013-09-18 19:50:55 +08:00
2013-09-02 03:43:40 +08:00
/// Event loop is over when pressed q, Q, e, E
/// Start event loop once for 1 millisecond
sameWindow.spinOnce(1, true);
while(!sameWindow.wasStopped())
{
2013-09-06 02:53:57 +08:00
/// Interact with window
2013-09-18 19:50:55 +08:00
2013-09-06 02:53:57 +08:00
/// Event loop for 1 millisecond
sameWindow.spinOnce(1, true);
2013-09-02 03:43:40 +08:00
}
2013-09-18 19:50:55 +08:00
2013-09-02 03:43:40 +08:00
/// Once more event loop is stopped
cout << "Last event loop is over" << endl;
return 0;
}