opencv - 对KalmanFilter的未定义引用

问题描述 投票:-2回答:1

我有一个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个回答
0
投票

刚刚找到解决方案:

我不得不链接opencv_libs。

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.