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()) { 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, 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 Serial::listDevices() { buildDeviceList(); for(int k = 0; k < (int)devices.size(); k++) { LOG_INFO << "[" << devices[k].getDeviceID() << "] = "<< devices[k].getDeviceName().c_str(); } }
//---------------------------------------------------------------- bool ofSerial::setup(int deviceNumber, int baud){ buildDeviceList(); if(deviceNumber < (int)devices.size()){ return setup(devices[deviceNumber].devicePath, baud); } else { ofLogError("ofSerial") << "couldn't find device " << deviceNumber << ", only " << devices.size() << " devices found"; return false; } }
//---------------------------------------------------------------- bool ofSerial::setup(int deviceNumber, int baud){ buildDeviceList(); if( deviceNumber < (int)devices.size() ){ return setup(devices[deviceNumber].devicePath, baud); }else{ ofLog(OF_LOG_ERROR,"ofSerial: could not find device %i - only %i devices found", deviceNumber, devices.size()); return false; } }
//--------------------------------------------------------------------------- bool ofxKinectContext::init() { if(freenect_init(&kinectContext, NULL) < 0) { ofLog(OF_LOG_ERROR, "ofxKinect: freenect_init failed"); bInited = false; return false; } bInited = true; ofLog(OF_LOG_VERBOSE, "ofxKinect: Context inited"); buildDeviceList(); listDevices(true); return true; }
//--------------------------------------------------------------------------- bool ofxKinectContext::init() { if(freenect_init(&kinectContext, NULL) < 0) { ofLogError("ofxKinect") << "init(): freenect_init failed"; bInited = false; return false; } #ifdef OFX_KINECT_EXTRA_FW freenect_set_fw_address_nui(kinectContext, ofxKinectExtras::getFWData1473(), ofxKinectExtras::getFWSize1473()); freenect_set_fw_address_k4w(kinectContext, ofxKinectExtras::getFWDatak4w(), ofxKinectExtras::getFWSizek4w()); #endif freenect_set_log_level(kinectContext, FREENECT_LOG_WARNING); freenect_select_subdevices(kinectContext, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); bInited = true; ofLogVerbose("ofxKinect") << "context inited"; buildDeviceList(); listDevices(true); return true; }
//---------------------------------------------------------------- std::vector <ofSerialDeviceInfo> ofSerial::getDeviceList(){ buildDeviceList(); return devices; }
//---------------------------------------------------------------- void ofSerial::listDevices(){ buildDeviceList(); for(int k = 0; k < (int)devices.size(); k++){ printf( "[%d] = %s\n", devices[k].getDeviceID(),devices[k].getDeviceName().c_str()); } }
//---------------------------------------------------------------- void ofSerial::listDevices(){ buildDeviceList(); for(int k = 0; k < (int)devices.size(); k++){ std::cout << "[" << devices[k].getDeviceID() << "] = "<< devices[k].getDeviceName().c_str() << "\r\n"; } }
//---------------------------------------------------------------- vector <SerialDeviceInfo> Serial::getDeviceList() { buildDeviceList(); return devices; }
//---------------------------------------------------------------- void ofSerial::listDevices(){ buildDeviceList(); for(int k = 0; k < (int)devices.size(); k++){ ofLogNotice("ofSerial") << "[" << devices[k].getDeviceID() << "] = "<< devices[k].getDeviceName().c_str(); } }
void Manager::initialize(const std::string & f ) { parseIndexDefinitions( f ); buildDeviceList(); buildIndices(); }
//---------------------------------------------------------------- void ofSerial::listDevices(){ buildDeviceList(); for(auto & device: devices){ ofLogNotice("ofSerial") << "[" << device.getDeviceID() << "] = "<< device.getDeviceName().c_str(); } }