Mercurial > hg > movesynth
view of/testApp.cpp @ 17:803b8f3b70b4
have added printing of the head data - you will NEED TO PUT the franklin font into ->bin->data for this to work - this is also include here in of
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Thu, 17 Feb 2011 17:03:39 +0000 |
parents | 36e3faa5e9d4 |
children | 7b6dfc67d51e e71aad40a068 |
line wrap: on
line source
#include "testApp.h" //-------------------------------------------------------------- void testApp::setup(){ drawIt=false; // load the default ofxOpenNI config settings // see bin/data/openni/config/ofxopenni_config.xml context.setupUsingXMLFile(); // uncomment this to see what open ni is doing inside //context.enableLogging(OF_LOG_VERBOSE); // setup resources depth.setup(&context); image.setup(&context); user.setup(&context, &depth); // Davy.loadImage("images/davy.jpg"); ofEnableSmoothing(); ofSetBackgroundAuto(false); ofBackground(238,238,224); ofEnableAlphaBlending(); ofSetLineWidth(12); franklinBook.loadFont("frabk.ttf", 32); } //-------------------------------------------------------------- void testApp::update(){ // update the open ni context and user tracker context.update(); user.update(); } void testApp::getCoordinates(ofxTrackedUser* tracked, int userID){ //tracked = user.getTrackedUser(i); head[userID][0] = tracked->neck.begin.x; head[userID][1] = tracked->neck.begin.y; head[userID][2] = tracked->neck.begin.z; ofSetColor(0x00FF00); outputString = "HeadX : "; outputString += ofToString(head[0][0]); franklinBook.drawString(outputString, 100,600); } //-------------------------------------------------------------- void testApp::draw(){ // draw depth and rgb images //depth.draw(); if (drawIt != true) { image.draw(); user.draw(); } // draw all the users automatically? stringstream info; info << "number of tracked users: " << user.getNumTrackedUsers() << endl; // draw the neck positions of each user for(int i = 0; i < user.getNumTrackedUsers(); ++i) { ofxTrackedUser* tracked = user.getTrackedUser(i); if(tracked != NULL) { //getCoordinates(tracked, i); //andrews code int userID = i; if (userID < 6){ head[userID][0] = tracked->neck.begin.x; head[userID][1] = tracked->neck.begin.y; head[userID][2] = tracked->neck.begin.z; ofSetColor(0x000000); outputString = "HeadX : "; outputString += ofToString(head[userID][0]); outputString += " HeadY : "; outputString += ofToString(head[userID][1]); outputString += " HeadZ : "; outputString += ofToString(head[userID][2]); //outputString += ofToString(head[0][0]); franklinBook.drawString(outputString, 100,600+userID*40); } //end andrew info << i << " neck pos: " << tracked->left_lower_arm.end.x << " " << tracked->left_lower_arm.end.y << " " << tracked->neck.begin.z << endl; if (tracked->neck.begin.x != 0) ofSetColor(139,0,0,100); ofNoFill(); float w = ofGetWidth(); float h = ofGetHeight(); ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->left_lower_arm.begin.x,tracked->left_lower_arm.begin.y,tracked->left_lower_arm.end.x,/*tracked->left_lower_arm.end.y*/ w); ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->right_lower_arm.begin.x,tracked->right_lower_arm.begin.y,tracked->right_lower_arm.end.x,/*tracked->right_lower_arm.end.y*/ w); ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->left_lower_leg.begin.x,tracked->left_lower_leg.begin.y,tracked->left_lower_leg.end.x,/*tracked->left_lower_leg.end.y*/ h); ofBezier(tracked->neck.begin.x,tracked->neck.begin.y,tracked->neck.end.x,tracked->neck.end.y,tracked->right_lower_leg.begin.x,tracked->right_lower_leg.begin.y,tracked->right_lower_leg.end.x,/*tracked->right_lower_leg.end.y*/ h); ofFill(); ofSetColor(255,255,100); ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,30); ofSetColor(0); ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,35); ofSetColor(255,255,100); ofCircle(tracked->neck.begin.x,tracked->neck.begin.y,30); ofSetColor(0); ofCircle(tracked->neck.begin.x+10.0f,tracked->neck.begin.y,6); ofCircle(tracked->neck.begin.x-10.0f,tracked->neck.begin.y,6); } } ofFill(); ofSetColor(238,238,224,20); ofRect(0,0,ofGetWidth(),ofGetHeight()); ofDrawBitmapString(info.str(), 10, 500); } //-------------------------------------------------------------- void testApp::keyPressed(int key){ ofSetColor(238,238,224); ofRect(0,0,ofGetWidth(),ofGetHeight()); drawIt =!drawIt; ofToggleFullscreen(); } //-------------------------------------------------------------- void testApp::keyReleased(int key){ } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ ofSetColor(238,238,224); ofFill(); ofRect(0,0,ofGetWidth(),ofGetHeight()); } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ }