Question

I am trying to setup a simple program to use OpenKinect to connect a Kinect and somehow test the communication to my laptop. I can run the demos fine, but I want to test it through code to make sure I know whats going on. So far I am still unable to connect it. The code as of now is -

#include "/usr/local/include/libfreenect.hpp"
#include <iostream>
using namespace std;
Freenect::FreenectDevice::FreenectDevice* device; 

int main(int argc, char** argv) {
    Freenect::Freenect k;
    device = &k.createDevice<Freenect::FreenectDevice>(0);  //line 8
    cout<<"\ndeviceCount:"<<k.deviceCount();
    return 0;
}

When I compile, it tells me

    In member function ‘ConcreteDevice& Freenect::Freenect::createDevice(int) [with ConcreteDevice = Freenect::FreenectDevice]’:
test_kinect.cpp:8:   instantiated from here

libfreenect.hpp:196: error: cannot allocate an object of abstract type ‘Freenect::FreenectDevice’

So the FreenectDevice class is abstract...well how am I supposed to create a device then? Am I expected to write my own class that inherits this one whenever I want to use OpenKinect? I'm very confused about how to actually use the code this library provides. I have been searching for some kind of basic tutorial, but have found nothing. If someone knows of a good tutorial, that would be the best thing for me right now. Any help is appreciated, thanks.

Was it helpful?

Solution

Well, yes, you'll need to inherit FreenectDevice and implement the two callbacks (VideoCallback and DepthCallback) that will receive the video and depth information that the Kinect registers.

The problem with examples is that there have been API changes over the lifetime of the library, so they may not all be working with the current version. Your best bet for working example code is the C++ wrapper section of the OpenKinect Wiki which has two (hopefully) current samples, and cppview.cpp included in the source distribution of libfreenect itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top