一、下载并传输相关SDK
1、点击下载SDK
2、使用Xftp7将下载下来的压缩包传输至树莓派并解压 ,在Windows下查看解压后文件如下图所示。
二、编译
笔者使用树莓派没有相关依赖,SDK中需要opencv的相关依赖,需要自己手动安装。
例:libgtk-3的安装,安装过程可能遇到两个问题,一是无法下载,找不到包,可尝试换源,第二个问题是提示破坏包之间的依赖关系,安装过程可参考其他包的安装过程,如下。
报错:
E: Unable to correct problems, you have held broken packages.
安装:
sudo apt-get install aptitude
sudo aptitude install libyaml-dev
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libyaml-dev [Not Installed]
Accept this solution? [Y/n/q/? (n)
The following actions will resolve these dependencies:
Downgrade the following packages:
1) libyaml-0-2 [0.1.4-3ubuntu3.1 (now) -> 0.1.4-3ubuntu3 (trusty)]
Accept this solution? [Y/n/q/?] (Y)
相关文件配置:
samples下的CMakelist.txt
samples下sample_build.sh
编译:按照包中Readme.pdf中流程操作,会报如下错误,这是链接不到相应的库导致的。
/usr/bin/ld: /home/pi/openni//samples/samples/SimpleViewer/../ThirdParty/OpenCV420/arm-32/lib/libopencv_core.so: .dynsym local symbol at index 3 (>= sh_info of 2)
在samples/samples/SimpleViewer下的CMakeLists.txt 里面加上,但是直接将这条语句复制进去,不能起作用,需要手动输入,注意fuse和ld前面横线均没有空格。
set(CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS}-fuse-ld=gold”)
make通过,再sudo make install--手动编译,脚本编译添加过后可直接编译。
编译报如下错误:
Draw.cpp:58: error: undefined reference to 'cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
Draw.cpp:60: error: undefined reference to 'cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
因为树莓派无法显示界面,与这两个函数冲突,进入Draw.cpp将两函数注销,根据自己需求操作,如果不是在树莓派环境或者需要显示图像,另行操作。
再次编译显示如下:
成功。