【问题标题】:opencv - undefined reference to KalmanFilteropencv - 对 KalmanFilter 的未定义引用
【发布时间】:2017-12-16 09:40:45
【问题描述】:

我有一个 opencv 项目,到目前为止一切正常,直到我今天尝试重建我的代码:我收到以下错误:

undefined reference to `cv::KalmanFilter::KalmanFilter(int, int, int, int)'

undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'

undefined reference to `cv::waitKey(int)'

我不确定为什么会出现这个错误,我只能假设它可能与我运行 sudo apt-get autoremovesudo apt-get upgrade 的事实有关。我之前唯一做的另一件事是安装 arduino。

我不知道为什么会出现这个错误,因为我一直能够编译到今天。

卡尔曼滤波器的opencv包含是否已更改?以下是我包含的片段:

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/video/video.hpp> //for kalman filter
//Include headers for OpenCV GUI handling
#include <opencv2/highgui/highgui.hpp>

在我的 CMakeLists.txt 中:

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
)

include_directories(
    ${OpenCV_INCLUDE_DIRS}
    ${OpenCV_LIB_COMPONENTS}
    ${OpenCV_LIBRARIES}

我正在运行 opencv 3.3.1。

【问题讨论】:

标签: cmake opencv3.0 kalman-filter


【解决方案1】:

刚刚找到解决办法:

我必须链接到 opencv_libs。

在我的 CMakeLists.txt 中我添加了:

target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries(example_node ${PROJECT_NAME})

我不确定为什么我的代码以前可以工作,但现在停止工作。无论如何现在它再次编译:)

【讨论】:

    猜你喜欢
    • 2012-06-23
    • 2016-04-02
    • 2014-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-26
    相关资源
    最近更新 更多