void HodginDidItApp::processDepth()
{
	mPoints.clear();
	Surface::Iter sit = mSurfDepth.getIter(Area(0,0,mDepthW,mDepthH));
	while(sit.line())
	{
		while(sit.pixel())
		{
			float cDepth = (float)mDepthBuffer[sit.y()*mDepthW+sit.x()];
			sit.r() = 0;
			sit.g() = 0;
			sit.b() = 0;
			sit.a() = 0;
			if(cDepth<32000)
			{
				float cScaled = cDepth/1000.0f;
				if(cDepth<300)
				{
					uint8_t v = (uint8_t)lmap<float>(cDepth,0,300,0,255);
					sit.r() = v;
					sit.a() = v;
				}
				if(sit.x()%2==0&&sit.y()%2==0)
					mPoints.push_back(niDepthToWorld(Vec3f(sit.x(),sit.y(),1.0f*cScaled)));

			}
		}
	}
}
Beispiel #2
0
void Video::update()
{
    if( mMovie.checkPlayable() ){
        Area area = mMovie.getSurface().getBounds();
        mFrameSurface = ci::Surface(area.getWidth(), area.getHeight(), true);
		mFrameSurface.copyFrom(mMovie.getSurface(), mFrameSurface.getBounds() );
        
        /*
        mFrameSurface = ci::Surface(mMovie.getSurface());
        mFrameTexture = gl::Texture(mFrameSurface, mFrameFormat);
        */
        
        Surface::Iter iter = mFrameSurface.getIter( mFrameSurface.getBounds() );

        while( iter.line() ) {
            while( iter.pixel() ) {
                //if (iter.b() > 50 && iter.r() < 50 && iter.g() < 50){
                if (iter.g() > 50 && iter.g() > iter.r() && iter.g() > iter.b()){
                    //std::cout << "yes" << std::endl;
                    //iter.r() = 0;
                    //iter.g() = 0;
                    //iter.b() = 0;
                    iter.a() = 0;
                }
                else{
                    iter.a() = 255;
                    //std::cout << "no" << std::endl;
                }
            }
        }
        //mFrameSurface = ci::Surface( loadImage( loadResource( "bomb.png")) );
        mFrameTexture = gl::Texture(mFrameSurface, mFrameFormat);
         
    }
    //mCenteredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
    mCenteredRect = Rectf(-40,0,800,600);
    
   
     
}