c – 对’cv :: viz :: Viz3d :: Viz3d(std :: string&const)’的未定义引用

我用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,我认为它们是兼容的.

谢谢.

最佳答案 首先检查库libopencv_viz.so是否已在系统中正确安装.如果是,则在编译cpp文件时添加-lopencv_viz.理想情况下,“pkg-config –libs opencv”应该包含它.

谢谢.

点赞