bool ofxKinectContext::open(ofxKinect& kinect, int id) { // rebuild if necessary (aka new kinects plugged in) buildDeviceList(); if(numConnected() >= numTotal()) { ofLogWarning("ofxKinect") << "no available devices found"; return false; } // is the id available? if(id < 0) { id = nextAvailableId(); } if(isConnected(id)) { ofLogWarning("ofxKinect") << "device " << id << " already connected"; return false; } // open and add to vector if(freenect_open_device(kinectContext, &kinect.kinectDevice, id) < 0) { ofLogError("ofxKinect") << "could not open device " << id; return false; } kinects.insert(pair<int,ofxKinect*>(id, &kinect)); // set kinect id & serial from bus id kinect.deviceId = id; kinect.serial = deviceList[getDeviceIndex(id)].serial; return true; }
bool ofxKinectContext::open(ofxKinect& kinect, string serial) { // rebuild if necessary (aka new kinects plugged in) buildDeviceList(); if(numConnected() >= numTotal()) { ofLogWarning("ofxKinect") << "no available devices found"; return false; } // is the serial available? if(isConnected(serial)) { ofLogWarning("ofxKinect") << "device " << serial << " already connected"; return false; } // open and add to vector if(freenect_open_device_by_camera_serial(kinectContext, &kinect.kinectDevice, serial.c_str()) < 0) { ofLogError("ofxKinect") << "could not open device " << serial; return false; } int index = getDeviceIndex(serial); kinects.insert(pair<int,ofxKinect*>(deviceList[index].id, &kinect)); kinect.deviceId = deviceList[index].id; kinect.serial = serial; return true; }
bool ofxKinectContext::open(ofxKinect& kinect, string serial) { // rebuild if necessary (aka new kinects plugged in) buildDeviceList(); if(numConnected() >= numTotal()) { ofLog(OF_LOG_WARNING, "ofxKinect: No available devices found"); return false; } // is the serial available? if(isConnected(serial)) { ofLog(OF_LOG_WARNING, "ofxKinect: Device %s already connected", serial.c_str()); return false; } // open and add to vector if(freenect_open_device_by_camera_serial(kinectContext, &kinect.kinectDevice, serial.c_str()) < 0) { ofLog(OF_LOG_ERROR, "ofxKinect: Could not open device %s", serial.c_str()); return false; } int id = getDeviceIndex(serial); kinects.insert(pair<int,ofxKinect*>(id, &kinect)); kinect.deviceId = id; kinect.serial = deviceList[id].serial; return true; }
bool ofxKinectContext::open(ofxKinect& kinect, int id) { // rebuild if necessary (aka new kinects plugged in) buildDeviceList(); if(numConnected() >= numTotal()) { ofLog(OF_LOG_WARNING, "ofxKinect: No available devices found"); return false; } // is the id available? if(id < 0) { id = nextAvailableId(); } if(isConnected(id)) { ofLog(OF_LOG_WARNING, "ofxKinect: Device %d already connected", id); return false; } // open and add to vector if(freenect_open_device(kinectContext, &kinect.kinectDevice, id) < 0) { ofLog(OF_LOG_ERROR, "ofxKinect: Could not open device %d", id); return false; } kinects.insert(pair<int,ofxKinect*>(id, &kinect)); // set kinect id & serial from bus id int index = getDeviceIndex(id); kinect.deviceId = id; kinect.serial = deviceList[index].serial; return true; }
//--------------------------------------------------------------------------- void ofxKinectContext::clear() { if(isInited() && numConnected() < 1) { freenect_shutdown(kinectContext); kinectContext = NULL; bInited = false; } }
//--------------------------------------------------------------------------- void ofxKinectContext::clear() { if(isInited() && numConnected() < 1) { freenect_shutdown(kinectContext); kinectContext = NULL; bInited = false; ofLogVerbose("ofxKinect") << "context cleared"; } }
//--------------------------------------------------------------------------- void ofxKinectContext::clear() { if(isInited() && numConnected() < 1) { freenect_shutdown(kinectContext); kinectContext = NULL; bInited = false; ofLog(OF_LOG_VERBOSE, "ofxKinect: Context cleared"); } }