OpenCV  3.0.0-rc1
Open Source Computer Vision
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Launching Viz

Goal

In this tutorial you will learn how to

Code

You can download the code from here.

1 
7 #include <opencv2/viz.hpp>
8 #include <iostream>
9 
10 using namespace cv;
11 using namespace std;
12 
17 void help()
18 {
19  cout
20  << "--------------------------------------------------------------------------" << endl
21  << "This program shows how to launch a 3D visualization window. You can stop event loop to continue executing. "
22  << "You can access the same window via its name. You can run event loop for a given period of time. " << endl
23  << "Usage:" << endl
24  << "./launching_viz" << endl
25  << endl;
26 }
27 
31 int main()
32 {
33  help();
35  viz::Viz3d myWindow("Viz Demo");
36 
38  myWindow.spin();
39 
41  cout << "First event loop is over" << endl;
42 
44  viz::Viz3d sameWindow = viz::get("Viz Demo");
45 
47  sameWindow.spin();
48 
50  cout << "Second event loop is over" << endl;
51 
54  sameWindow.spinOnce(1, true);
55  while(!sameWindow.wasStopped())
56  {
58 
60  sameWindow.spinOnce(1, true);
61  }
62 
64  cout << "Last event loop is over" << endl;
65  return 0;
66 }
bool wasStopped() const
Returns whether the event loop has been stopped.
void spinOnce(int time=1, bool force_redraw=false)
Starts the event loop for a given time.
The Viz3d class represents a 3D visualizer window. This class is implicitly shared. :
Definition: viz3d.hpp:67
void spin()
The window renders and starts the event loop.
int main(int argc, const char *argv[])
Definition: facerec_demo.cpp:67

Explanation

Here is the general structure of the program:

Results

Here is the result of the program.

window_demo.png