Exemple #1
0
//--------------------------------------------------------------
void testApp::setup(){
	// Setup kinect
	kinect.init();
	kinect.setVerbose(true);
	kinect.open();
	
	// Allocate space for all the images
	colorImg.allocate(kinect.width, kinect.height);
	
	grayImage.allocate(kinect.width, kinect.height);
	grayBg.allocate(kinect.width, kinect.height);
	grayDiff.allocate(kinect.width, kinect.height);
	
	// Don't capture the background at startup
	bLearnBakground = false;
	
	// set up sensable defaults for threshold and calibration offsets
	// Note: these are empirically set based on my kinect, they will likely need adjusting
	threshold = 104;
	
	xOff = 13.486656;
	yOff = 34.486656;	
	setCalibrationOffset(xOff, yOff);
	
	// Set depth map so near values are higher (white)
	kinect.enableDepthNearValueWhite(true);
	
	// Setup window
	ofSetFullscreen(true);
	ofSetFrameRate(30);	
}
//--------------------------------------------------------------
void testApp::setup() {

	ofSetLogLevel(OF_LOG_VERBOSE);
	
    // enable depth->rgb image calibration
	kinect.setRegistration(true);
	kinect.init();
	kinect.setVerbose(true);
	//kinect.init(true); // shows infrared instead of RGB video image
	//kinect.init(false, false); // disable video image (faster fps)
	
	kinect.open();

	//kinect.getCalibratedColorAt(60, 230);
	
	//Allocate space for all images
	colorImg.allocate(kinect.width, kinect.height);

	grayImage.allocate(kinect.width, kinect.height);
	grayBg.allocate(kinect.width, kinect.height);
	grayDiff.allocate(kinect.width, kinect.height);
	footDiff.allocate(kinect.width, kinect.height );
	handDiff.allocate(kinect.width, kinect.height );

	grayThreshNear.allocate(kinect.width, kinect.height);
	grayThreshFar.allocate(kinect.width, kinect.height);
	
	// Don't capture the background at startup
	bLearnBakground = false;

	// set up sensable defaults for threshold and calibration offsets
	// Note: these are empirically set based on my kinect, they will likely need adjusting
	threshold = 73;
	
	xOff = 13.486656;
	yOff = 34.486656;	
	setCalibrationOffset(xOff, yOff);

	nearThreshold = 250;
	farThreshold = 70;
	bThreshWithOpenCV = true;
	
	// Set depth map so near values are higher (white)
	kinect.enableDepthNearValueWhite(true);
	ofSetFrameRate(30);
	
	// zero the tilt on startup
	angle = 0;
	kinect.setCameraTiltAngle(angle);
	
	// start from the front
	bDrawPointCloud = false;
	bDrawContourFinder = false;

}
Exemple #3
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
	// set keybindings for capturing the background, manipulating the offset, and tilting the kinect
	switch (key)
	{
		case ' ':
			bLearnBakground = true;
			break;
		case '+':
			threshold++;
			break;
		case '-':
			threshold--;
			break;
		case OF_KEY_UP:
			yOff++;
			setCalibrationOffset(xOff, yOff);
			break;
		case OF_KEY_DOWN:
			yOff--;
			setCalibrationOffset(xOff, yOff);
			break;
		case OF_KEY_LEFT:
			xOff--;
			setCalibrationOffset(xOff, yOff);
			break;
		case OF_KEY_RIGHT:
			xOff++;
			setCalibrationOffset(xOff, yOff);
			break;
		// Note these are currently not enabled in ofxKinect as of 11/23/2010
		case 'h':
			camTilt++;
			kinect.setCameraTiltAngle(camTilt);
			break;
		case 'n':
			camTilt--;
			kinect.setCameraTiltAngle(camTilt);
			break;
	}
}
Exemple #4
0
//--------------------------------------------------------------
void testApp::keyPressed (int key) {
	switch (key) {
		case ' ':
			bThreshWithOpenCV = !bThreshWithOpenCV;
			bDrawColorDiff=false;
			break;	
		case 'b':
			bLearnBakground = true;
			break;
		case'p':
			bDrawPointCloud = !bDrawPointCloud;
			bDrawContourFinder = false;
			bDrawColorDiff=false;
			break;
		case 'c':
			bDrawContourFinder=!bDrawContourFinder;
			bDrawPointCloud = false;
			bDrawColorDiff=false;
			break;
		case'i':
			bDrawColorDiff = !bDrawColorDiff;
			bDrawPointCloud = false;
			bDrawContourFinder = false;
		break;
		case 'x':
			flag=true;
			break;
		case '>':
		case '.':
			farThreshold ++;
			if (farThreshold > 255) farThreshold = 255;
			break;
			
		case '<':
		case ',':
			farThreshold --;
			if (farThreshold < 0) farThreshold = 0;
			break;
			
		case '+':
		case '=':
			nearThreshold ++;
			if (nearThreshold > 255) nearThreshold = 255;
			break;
			
		case '-':
			nearThreshold --;
			if (nearThreshold < 0) nearThreshold = 0;
			break;
			
		case 'w':
			kinect.enableDepthNearValueWhite(!kinect.isDepthNearValueWhite());
			break;
			
		case 'a':
			kinect.setCameraTiltAngle(angle); // go back to prev tilt
			kinect.open();
			break;			
		case 'z':
			kinect.setCameraTiltAngle(0); // zero the tilt
			kinect.close();
			break;
		case 'q':
			physics.newBall(mouseX, mouseY);	
			break;
		case 'h':
			bSetup = !bSetup;
			break;
		case OF_KEY_UP:
			angle++;
			if(angle>30) angle=30;
			kinect.setCameraTiltAngle(angle);
			break;	
		case OF_KEY_DOWN:
			angle--;
			if(angle<-30) angle=-30;
			kinect.setCameraTiltAngle(angle);
			break;
			case '[':
			yOff++;
			setCalibrationOffset(xOff, yOff);
			break;
		case ']':
			yOff--;
			setCalibrationOffset(xOff, yOff);
			break;
		case OF_KEY_LEFT:
			xOff--;
			setCalibrationOffset(xOff, yOff);
			break;
		case OF_KEY_RIGHT:
			xOff++;
			setCalibrationOffset(xOff, yOff);
			break;
	}
}
Exemple #5
0
//--------------------------------------------------------------
void testApp::setup() {

	physics.spheres=0;
	ofSetLogLevel(OF_LOG_VERBOSE);
	
    // enable depth->rgb image calibration
	kinect.setRegistration(true);
	kinect.init();
	kinect.setVerbose(true);
	//kinect.init(true); // shows infrared instead of RGB video image
	//kinect.init(false, false); // disable video image (faster fps)
	
	kinect.open();
	// HAND T.
	/*ofEnableSmoothing(); 
	bWasHandOpen = false;
	oldNumBlobs = 0;
	
	bSetup = true;
	bHandBusy = false;
	for(int i=0; i<20; ++i){draggables.push_back( Draggable() );}

	kinect.getCalibratedColorAt(60, 230);*/
	

	//Allocate space for all images
	colorImg.allocate(kinect.width, kinect.height);
	colorDiff.allocate(kinect.width, kinect.height);
	colorBg.allocate(kinect.width, kinect.height);

	grayImage.allocate(kinect.width, kinect.height);
	grayBg.allocate(kinect.width, kinect.height);
	grayDiff.allocate(kinect.width, kinect.height);
	footDiff.allocate(kinect.width, kinect.height );

	grayThreshNear.allocate(kinect.width, kinect.height);
	grayThreshFar.allocate(kinect.width, kinect.height);
	maskedImg.allocate(kinect.width, kinect.height,GL_RGBA);
	
	// Don't capture the background at startup
	bLearnBakground = false;

	// set up sensable defaults for threshold and calibration offsets
	// Note: these are empirically set based on my kinect, they will likely need adjusting
	threshold = 73;
	
	xOff = 13.486656;
	yOff = 34.486656;	
	setCalibrationOffset(xOff, yOff);

	nearThreshold = 250;
	farThreshold = 70;
	bThreshWithOpenCV = true;
	
	// Set depth map so near values are higher (white)
	kinect.enableDepthNearValueWhite(true);
	// Set which direction virtual camera is animating
	eyeDir = 1;

	ofSetFrameRate(30);
	
	// zero the tilt on startup
	angle = 0;
	kinect.setCameraTiltAngle(angle);
	
	// start from the front
	bDrawPointCloud = false;
	bDrawDepthMap = false;
	bDrawGrayImage = false;
	bDrawContourFinder = false;
	bDrawGrayDiff = false;
	bDrawColorDiff = false;

	physics.reset();
	
}