ofTheo/ofxKinect

ofxKinect::nextAvailableSerial() doesn't work

Closed this issue · 5 comments

if you run this code:

int n = ofxKinect::numTotalDevices();
vector<ofxKinect*> kinects;
while(kinects.size() < n) {
    kinects.push_back(new ofxKinect());
    kinects.back()->init();
    kinects.back()->open(ofxKinect::nextAvailableSerial());
}

the first kinect will work and the rest will have ids of -1

it's not really clear to me why this is happening, but it might be something like... you don't know the serial number of a device until you actually open it? the fact that the serial is set a second time after opening makes me think this is the case. if so, i suggest ofxKinect::nextAvailableSerial() is removed, because it can't ever be used :)

No. It should work. When the kinect context is inited, the device list is built which contains the underlying ids. When you call nextAvailableSerial(), it's basically calls nextAvailableId() then asks freenect for the serial num for that id.

You don't have to open a device to get the serial. But I'll double check this.

Also, why do it this way anyway? It's just another step on top of nextAvilableId().

Also, note that the device list is printed when the Kinect context is inited when verbose is on, so we know the serials are there.

Ok. I can reproduce this. I think it's something wrong with opening using the serial in ofxKinectContext::open(ofxKinect& kinect, string serial).

Thanks for taking a look! Sorry if my original guess was misleading, but I wasn't really sure where it was going wrong. In general you're right, you wouldn't want the code above, but that doesn't mean it shouldn't work :)

awesome, thanks dan!