Skip to content

Instantly share code, notes, and snippets.

@brunokruse
Created November 22, 2011 06:19
Show Gist options
  • Save brunokruse/1385042 to your computer and use it in GitHub Desktop.
Save brunokruse/1385042 to your computer and use it in GitHub Desktop.
steadylabs
//--------------------------------------------------------------
void KinectThread::setupKinect() {
// allocate our images into memory
threImg.allocate(CAM_WIDTH, CAM_HEIGHT);
depthImage.allocate(CAM_WIDTH, CAM_HEIGHT, OF_IMAGE_GRAYSCALE);
depthPixels = new unsigned char[CAM_WIDTH * CAM_HEIGHT];
// setup contour information from gui
contourMinArea = 20;
contourMaxArea = 1;
contourConsidered = 5;
contourHoles = true;
contourApprox = false;
// setup kinect from xml
context.setupUsingXMLFile(ofToDataPath("openni/config/ofxopenni_config.xml", true));
// make sure we have a device plugged in
//checkForKinect();
static xn::NodeInfoList node_info_list;
static xn::NodeInfoList depth_nodes;
static xn::NodeInfoList image_nodes;
// enumerate all devices
XnStatus status = context.getXnContext().EnumerateProductionTrees(XN_NODE_TYPE_DEVICE, NULL, node_info_list);
if (node_info_list.Begin () != node_info_list.End ()) {
cout << "KinectThread::setupKinect there is a kinect connected."<< endl;
hasKinectConnected = true;
}
else if (node_info_list.Begin () == node_info_list.End ()) {
cout << "KinectThread::setupKinect there is no Kinect detected."<< endl;
hasKinectConnected = false;
return;
}
// setup our hand generator
handGen.setup(&context, 4);
handGen.setSmoothing(.3f);
handGen.setFilterFactors(0.2f);
depth.setup(&context); // depth generator for calculations
recordImage.setup(&context); // rgb for the mask
user.setup(&context);
user.setMaxNumberOfUsers(2);
user.setUseMaskPixels(true);
ofAddListener(ofEvents.update, this, &KinectThread::updatePixels);
/*
// make sure we have a device plugged in
if ( checkForKinect() )
{
// setup our hand generator
handGen.setup(&context, 4);
handGen.setSmoothing(.1f);
handGen.setFilterFactors(0.1f);
depth.setup(&context); // depth generator for calculations
recordImage.setup(&context); // rgb for the mask
user.setup(&context);
user.setMaxNumberOfUsers(2);
user.setUseMaskPixels(true);
//setup update
ofAddListener(ofEvents.update, this, &KinectThread::updatePixels);
}
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment