OpenCV Viz 3D Virtual space module _OPENCV

Source: Internet
Author: User

The 3D module was added to the release version of OpenCV2.4.9, which was very simple and beautiful, and the three-dimensional virtual space module was VTK from three-dimensional computer graphics, image processing and visualization, OpenCV3.0 OpenCV The routines in tutorial are as follows:


To configure the results of the Viz operation for the first time:

The source code is as follows:

#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 << "The" "The" "The" "The" "The" "The" "I" << 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 are over" << Endl; Event loop is over when pressed Q, Q, E, e///the Start event loop once for 1 millisecond samewindow.spinonce (1,
    true); while (!samewindow.wasstopped ()) {///Interact with window///Event loop for 1 millisecond s
    Amewindow.spinonce (1, true); ///Once More event loop are stopped cout << "last event loop is Over "<< Endl;
return 0; }


Windows 7 is not the first image is generally black. Other similar routines are as follows:

The source code is as follows:

#include <opencv2/viz.hpp> #include <opencv2/calib3d.hpp> #include <iostream> using namespace CV;

using namespace Std;
	int main () {///Create a window viz::viz3d mywindow ("Coordinate Frame");
	ADD coordinate axes mywindow.showwidget ("Coordinate Widget", viz::wcoordinatesystem ());
	Add line to represent (1,1,1) axis viz::wline axis (point3f ( -1.0f, -1.0f, -1.0f), point3f (1.0f, 1.0f, 1.0f));
	Axis.setrenderingproperty (viz::line_width, 4.0);
	Mywindow.showwidget ("Line Widget", axis); Construct a cube widget Viz::wcube cube_widget (point3f (0.5, 0.5, 0.0), point3f (0.0, 0.0, -0.5), True, Viz::color::blu
	E ());
	Cube_widget.setrenderingproperty (viz::line_width, 4.0);
	Display Widget (update if already displayed) Mywindow.showwidget ("Cube widget", cube_widget);
	Rodrigues vector Mat Rot_vec = Mat::zeros (1, 3, cv_32f);
	float translation_phase = 0.0, translation = 0.0; while (!mywindow.wasstopped ()) {//* rotation using Rodrigues///Rotate Around (1,1,1) rot_vec.at<float> (0, 0) + = Cv_pi * 0.01F;
		Rot_vec.at<float> (0, 1) + = Cv_pi * 0.01F;
		Rot_vec.at<float> (0, 2) + = Cv_pi * 0.01F;
		Shift on (1,1,1) translation_phase + + = Cv_pi * 0.01F;
		translation = sin (translation_phase);
		Mat Rot_mat;
		Rodrigues (Rot_vec, Rot_mat);
		Construct pose affine3f pose (Rot_mat, vec3f (translation, translation, translation));
		Mywindow.setwidgetpose ("Cube Widget", pose);
	Mywindow.spinonce (1, true);
return 0; }





You are need to build VTK 6.1 (download) using the CMake 2.8.x with shared Libs turned. VTK needs to is build as static library and so it can is used to link to OpenCV with the VIZ module.

Build OpenCV with the Viz module turned on using the "src" and "Build" folders for VTK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.