我想使用r200和OpenCV启动计算机视觉项目。我正在使用旧版librealsense库,并且已经成功运行了示例。
不幸的是,我是C ++和Cmake的新手,所以我正在努力适当地导入东西。
我的项目结构如下:
-Project
-build
-librealsense //this is the directory that contains the code to run the r200
-main.cpp //my main working file
-CMakeLists.txt //what i'm working on
当我从构建目录执行../ cmake时,我的CMakeLists.txt运行成功,并且看起来像这样:
cmake_minimum_required(VERSION 3.10)
project(Project)
set(CMAKE_CXX_STANDARD 11)
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_subdirectory(librealsense)
# add the executable
add_executable(Project main.cpp librealsense/examples/example.hpp)
target_link_libraries( Project ${OpenCV_LIBS})
target_link_libraries(Project realsense2)
请注意,目前我只是从示例中试用代码,而librealsense / examples / example.hpp是我正在复制的示例中使用的example.hpp标头之一的相对路径。
我在main.cpp中使用的导入如下:
#include <librealsense2/rs.hpp>
#include "librealsense/examples/example.hpp"
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
它以非常冗长的错误消息作为响应,并显示以下内容:
...
"_rs2_start_processing", referenced from:
void rs2::processing_block::start<rs2::frame_queue>(rs2::frame_queue) in main.cpp.o
"_rs2_stream_to_string", referenced from:
texture::show(rect const&) const in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Project] Error 1
make[1]: *** [CMakeFiles/Project.dir/all] Error 2
make: *** [all] Error 2
我的问题是我实际上如何导入OpenCV和librealsense库!!!
任何有关此指南和CMake的指导都将使我永远感激不已!