void HiKinectApp::update() { if( mKinect.checkNewDepthFrame() ) { mDepthTexture = mKinect.getDepthImage(); mDepthSurface = Surface32f( mKinect.getDepthImage() ); mKinectReady = true; if ( !mKinectIR ) { mKinectIR = true; mKinect.setVideoInfrared( true ); } ci::Surface captureSurface = Surface8u( mKinect.getDepthImage() ); ci::Surface outputSurface = captureSurface; mContours->clear(); mSilhouetteDetector->processSurface(&captureSurface, mContours, &outputSurface); } if( mKinect.checkNewColorFrame() ) mColorTexture = mKinect.getVideoImage(); if( mIsMouseDown ) // using small number instead of 0.0 because lights go black after a few seconds when going to 0.0f mDirectional -= ( mDirectional - 0.00001f ) * 0.1f; else mDirectional -= ( mDirectional - 1.0f ) * 0.1f; if (mKinectReady) mGridMesh.updateKinect(mKinect); else mGridMesh.update(); }
void ContoursApp::update() { if ( mKinectReady && !mKinectIR ) mKinect.setVideoInfrared( true ); if( mKinect.checkNewDepthFrame() ) { mDepthTexture = mKinect.getDepthImage(); mDepthSurface = Surface8u( mKinect.getDepthImage() ); mKinectReady = true; ci::Surface captureSurface = Surface8u( mKinect.getDepthImage() ); ci::Surface outputSurface = captureSurface; contours->clear(); silhouetteDetector->processSurface(&captureSurface, contours, &outputSurface); console() << contours->size() << " is the size " << endl; mTexture1 = outputSurface; } if( mKinect.checkNewColorFrame() ) { mTexture2 = gl::Texture( mKinect.getVideoImage() ); } }
void BoidsApp::update() { double deltaT = lastFrameTime - getElapsedSeconds(); //silly variable names, but let's hope it works if(isFullScreen() != shouldBeFullscreen) { setFullScreen(shouldBeFullscreen); } mEye = Vec3f( 0.0f, 0.0f, mCameraDistance ); mCam.lookAt( mEye, mCenter, mUp ); gl::setMatrices( mCam ); gl::rotate( mSceneRotation); // image CODE //gl::enableAlphaBlending(); // glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //gl::enableAdditiveBlending(); //glEnable(GL_BLEND); //glEnable( GL_TEXTURE_2D ); //gl::enableDepthWrite( true ); //gl::enableDepthWrite( true ); //glBlendFunc( GL_ONE, GL_SRC_ALPHA ); if (checkTime()) { //get the next boidRuleset. int boidRuleToUse = (currentBoidRuleNumber++ % boidRulesets.size()); BoidSysPair thisPair = boidRulesets[boidRuleToUse]; flock_one.zoneRadius = thisPair.flockOneProps.zoneRadius; flock_one.lowerThresh = thisPair.flockOneProps.lowerThresh; flock_one.higherThresh = thisPair.flockOneProps.higherThresh; flock_one.attractStrength = thisPair.flockOneProps.attractStrength; flock_one.repelStrength = thisPair.flockOneProps.repelStrength; flock_one.orientStrength = thisPair.flockOneProps.orientStrength; flock_one.silThresh = thisPair.flockOneProps.silThresh; flock_one.silRepelStrength = thisPair.flockOneProps.silRepelStrength; flock_one.gravity = thisPair.flockOneProps.gravity; flock_one.setColor(thisPair.flockOneProps.baseColor); flock_two.zoneRadius = thisPair.flockTwoProps.zoneRadius; flock_two.lowerThresh = thisPair.flockTwoProps.lowerThresh; flock_two.higherThresh = thisPair.flockTwoProps.higherThresh; flock_two.attractStrength = thisPair.flockTwoProps.attractStrength; flock_two.repelStrength = thisPair.flockTwoProps.repelStrength; flock_two.orientStrength = thisPair.flockTwoProps.orientStrength; flock_two.silThresh = thisPair.flockTwoProps.silThresh; flock_two.silRepelStrength = thisPair.flockTwoProps.silRepelStrength; flock_two.gravity = thisPair.flockTwoProps.gravity; flock_two.setColor(thisPair.flockTwoProps.baseColor); imageColor = thisPair.imageColor; } //OpenCV IO //Only do OpenCV business if capture device is open and a new frame is ready if( capture && capture.checkNewFrame() ) { polygons->clear(); ci::Surface captureSurface = capture.getSurface(); ci::Surface outputSurface = captureSurface; silhouetteDetector->processSurface(&captureSurface,polygons,&outputSurface); //this only works because processSurface doesn't retain either pointer texture = outputSurface; flock_one.applySilhouetteToBoids(polygons,&imageToScreenMap); flock_two.applySilhouetteToBoids(polygons,&imageToScreenMap); } flock_one.applyForceToBoids(); if( flock_one.centralGravity ) flock_one.pullToCenter( mCenter ); flock_one.update(deltaT,getElapsedSeconds()); flock_two.applyForceToBoids(); if( flock_two.centralGravity) flock_two.pullToCenter( mCenter); flock_two.update(deltaT,getElapsedSeconds()); }