//--------------------------------------------------------------------------- float ofxKinect::getAccelRoll(){ return ofRadToDeg(asin(getMksAccel().x/OFX_KINECT_GRAVITY)); }
//-------------------------------------------------------------- void ofApp::update(){ kinect.setCameraTiltAngle(kAngle); for(auto p : videoPlayers1) { p->update(); } for(auto p : videoPlayers2) { p->update(); } ofBackground(100, 100, 100); kinect.update(); if(kinect.isFrameNew()) { grayImage.setFromPixels(kinect.getDepthPixels(), kinect.width, kinect.height); grayThreshNear = grayImage; grayThreshFar = grayImage; grayThreshNear.threshold(nearThresh, true); grayThreshFar.threshold(farThresh); cvAnd(grayThreshNear.getCvImage(), grayThreshFar.getCvImage(), grayImage.getCvImage(), NULL); grayImage.flagImageChanged(); } contourFinder.findContours(grayImage, minBlob, maxBlob, 5, false); #ifdef USE_TWO_KINECTS kinect2.update(); #endif if (contourFinder.nBlobs > 0) { ofxCvBlob blob = contourFinder.blobs.at(0); ofVec2f center = blob.centroid; center.y -= blob.boundingRect.height/2; ofSetColor(255, 0, 0); ofCircle(center.x, center.y, 30); meters = kinect.getDistanceAt(blob.centroid.x, blob.centroid.y) / 1000; feet = meters * 3.28083333; if (feet >= 8) { whichThresh = 3; } else if (feet >= 6) { whichThresh = 2; } else if (feet >= 4) { whichThresh = 1; } else { whichThresh = 0; } world = kinect.getWorldCoordinateAt(blob.centroid.x, blob.centroid.y); angle = ofRadToDeg(atan(world.z/world.x)); if (angle == -90.0) { angle = 90.0; } else if (angle < 0) { //angle *= -1; angle += 180; } if (angle <= 90) { whichVid_1 = 0; } else { whichVid_1 = 1; } float vidPos = ofMap(angle, 45, 135, 0, 1,true); //make decisions } else { //No blobs } }