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; }
void ompl::control::Syclop::setupRegionEstimates(void) { std::vector<int> numTotal(decomp_->getNumRegions(), 0); std::vector<int> numValid(decomp_->getNumRegions(), 0); base::StateValidityCheckerPtr checker = si_->getStateValidityChecker(); base::StateSamplerPtr sampler = si_->allocStateSampler(); base::State* s = si_->allocState(); for (int i = 0; i < numFreeVolSamples_; ++i) { sampler->sampleUniform(s); int rid = decomp_->locateRegion(s); if (checker->isValid(s)) ++numValid[rid]; ++numTotal[rid]; } si_->freeState(s); for (int i = 0; i < decomp_->getNumRegions(); ++i) { Region& r = graph_[boost::vertex(i, graph_)]; r.volume = decomp_->getRegionVolume(i); if (numTotal[i] == 0) r.percentValidCells = 1.0; else r.percentValidCells = ((double) numValid[i]) / (double)numTotal[i]; r.freeVolume = r.percentValidCells * r.volume; if (r.freeVolume < std::numeric_limits<double>::epsilon()) r.freeVolume = std::numeric_limits<double>::epsilon(); updateRegion(r); } }
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()) { 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::listDevices(bool verbose) { if(!isInited()) init(); stringstream stream; if(numTotal() == 0) { stream << "no devices found"; return; } else if(numTotal() == 1) { stream << 1 << " device found"; } else { stream << deviceList.size() << " devices found"; } if(verbose) { ofLogVerbose("ofxKinect") << stream.str(); } else { ofLogNotice("ofxKinect") << stream.str(); } stream.str(""); for(unsigned int i = 0; i < deviceList.size(); ++i) { stream << " id: " << deviceList[i].id << " serial: " << deviceList[i].serial; if(verbose) { ofLogVerbose("ofxKinect") << stream.str(); } else { ofLogNotice("ofxKinect") << stream.str(); } stream.str(""); } }
void ofxKinectContext::listDevices(bool verbose) { if(!isInited()) init(); stringstream stream; if(numTotal() == 0) { stream << "ofxKinect: No devices found"; return; } else if(numTotal() == 1) { stream << "ofxKinect: " << 1 << " device found"; } else { stream << "ofxKinect: " << deviceList.size() << " devices found"; } if(verbose) { ofLog(OF_LOG_VERBOSE, stream.str()); } else { cout << stream.str() << endl; } stream.str(""); for(int i = 0; i < deviceList.size(); ++i) { stream << " id: " << deviceList[i].id << " serial: " << deviceList[i].serial; if(verbose) { ofLog(OF_LOG_VERBOSE, stream.str()); } else { cout << stream.str() << endl; } stream.str(""); } }