install libfreenect2 on ubuntu 16.04

来源:互联网 发布:解决80端口被占用 编辑:程序博客网 时间:2024/06/04 01:29

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 <libfreenect2/libfreenect2.hpp>//#include <libfreenect2/frame_listener_impl.h>//#include <libfreenect2/registration.h>//#include <libfreenect2/packet_pipeline.h>//#include <libfreenect2/logger.h>#include <iostream>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.