未定义引用'cv :: viz :: Viz3d :: Viz3d(std :: string& const)'

时间:2014-09-15 16:14:03

标签: c++ qt opencv

我用qtcreator运行我的opencv代码,当我尝试使用Viz库时,我得到了这个答案。

代码:

#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");

我已经使用Ubuntu 12.10安装了2.4.9版本的opencv,我认为它们是兼容的。

感谢。

2 个答案:

答案 0 :(得分:1)

首先检查您的系统中是否正确安装了库 libopencv_viz.so 。如果是,则在编译cpp文件时添加 -lopencv_viz 。理想情况下&#34; pkg-config --libs opencv&#34; 应该包含它。

感谢。

答案 1 :(得分:1)

如果已安装库

  • 转到Project-&gt; Properties-&gt; Settings-&gt; GCC C ++ Linker-&gt;库

  • 将opencv_viz添加到您的库(屏幕截图)

screenshot

  • 保存并构建项目