Ignacio Gallego
Ignacio Gallego

Reputation: 43

undefined reference to 'cv::viz::Viz3d::Viz3d(std::string&const)'

I have run my opencv code with qtcreator and i have gotten this answer when i tried to use the Viz library.

Code:

#include <opencv2/calib3d/calib3d.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/contrib/contrib.hpp>

#include <opencv2/viz/vizcore.hpp>

    /// Create a window
    viz::Viz3d myWindow("Viz Demo");

    /// Start event loop
    myWindow.spin();

    /// Event loop is over when pressed q, Q, e, E
    printf("First event loop is over\n");

    /// 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
    printf("Second event loop is over\n");

    /// 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
    printf("Last event loop is over\n");

i have installed the 2.4.9 version of opencv with Ubuntu 12.10 and i think they are compatible.

Thanks.

Upvotes: 4

Views: 2149

Answers (2)

Ilja S.
Ilja S.

Reputation: 61

If the library is installed

  • go to Project->Properties->Settings->GCC C++ Linker-> Libraries

  • add opencv_viz to your libraries (screenshot)

screenshot

  • save and build project

Upvotes: 2

jaiprakashgogi
jaiprakashgogi

Reputation: 221

First check if the library libopencv_viz.so is installed properly in your system. If yes, then add -lopencv_viz while compiling the cpp file. Ideally "pkg-config --libs opencv" should include it.

Thanks.

Upvotes: 1

Related Questions