本文共 2907 字,大约阅读时间需要 9 分钟。
the install method has been listed in https://github.com/OpenKinect/libfreenect2
After installation, the test project is listed below:
CMakeList.txt
cmake_minimum_required(VERSION 2.8)project(TestLibfreenect2)add_executable(${PROJECT_NAME} "main.cpp")find_package(freenect2 REQUIRED)target_link_libraries(${PROJECT_NAME} ${freenect2_LIBRARIES})main.cpp
#include//#include //#include //#include //#include #include libfreenect2::Freenect2 freenect2;libfreenect2::Freenect2Device *dev = 0;libfreenect2::PacketPipeline *pipeline = 0;int main(){ std::string serial; if(freenect2.enumerateDevices() == 0) { std::cout << "no device connected!" << std::endl; return -1; } if (serial == "") { serial = freenect2.getDefaultDeviceSerialNumber(); std::cout << serial; } return 0;}
the output:
[Info] [Freenect2Impl] enumerating devices...[Info] [Freenect2Impl] 14 usb devices connected[Info] [Freenect2Impl] found valid Kinect v2 @4:8 with serial 016240151047[Info] [Freenect2Impl] found 1 devices016240151047
However, I have been troubled by a problem for a long time. When I run /home/seamanj/libfreenect2/build/bin/Protonect, there was no 4 subwindows poping out and showed some errors like:
libva info: VA-API version 0.39.4libva info: va_getDriverName() returns -1libva error: va_getDriverName() failed with unknown libva error,driver_name=(null)[Error] [VaapiRgbPacketProcessorImpl] vaInitialize(display, &major_ver, &minor_ver): unknown libva error
however, when I used vainfo command, the libva worked normally like:
libva info: VA-API version 0.39.4libva info: va_getDriverName() returns 0libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/nvidia_drv_video.solibva info: Found init function __vaDriverInit_0_39libva info: va_openDriver() returns 0vainfo: VA-API version: 0.39 (libva 1.7.3)vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA-API - 0.7.4vainfo: Supported profile and entrypoints VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointVLD VAProfileMPEG4Simple : VAEntrypointVLD VAProfileMPEG4AdvancedSimple : VAEntrypointVLD VAProfileH264Baseline : VAEntrypointVLD VAProfileH264Main : VAEntrypointVLD VAProfileH264High : VAEntrypointVLD VAProfileVC1Simple : VAEntrypointVLD VAProfileVC1Main : VAEntrypointVLD VAProfileVC1Advanced : VAEntrypointVLD
Finally, I used cmake-gui and figured out the reason which was lacking of libglfw3.
sudo apt-get install libglfw3 libglfw3-dev
When I installed this lib and build again, after I run Protonect the windows came out.
update on 1.11.2018
please don't forget to copy
/libfreenect2/platform/linux/udev/90-kinect2.rules
to
/etc/udev/rules.d
to get permission