//-------------------------------------------------------------- void ofxOpenNIDepthThreshold::setMaskPixelFormat(ofPixelFormat format){ maskPixelFormat = format; if(maskPixels.getImageType() != ofGetImageTypeFromGLType(maskPixelFormat)){ maskPixels.allocate(maskPixels.getWidth(), maskPixels.getHeight(), maskPixelFormat); if(bUseMaskTexture) maskTexture.allocate(maskPixels.getWidth(), maskPixels.getHeight(), ofGetGLTypeFromPixelFormat(maskPixelFormat)); } }
//---------------------------------------------------------- void ofTexture::readToPixels(ofFloatPixels & pixels){ #ifndef TARGET_OPENGLES pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glTypeInternal)); bind(); glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_FLOAT,pixels.getPixels()); unbind(); #endif }
Obj(ofFbo & videoFrame) :pixelsChanged(false) ,createdTexPixels(false) { pixels.allocate(videoFrame.getWidth(),videoFrame.getHeight(),ofGetImageTypeFromGLType(videoFrame.getTextureReference().texData.glInternalFormat)); updateTexture(videoFrame); total_num_frames++; }
void ofTexture::readToPixels(ofFloatPixels & pixels) const { #ifndef TARGET_OPENGLES pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glInternalFormat)); ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT,pixels.getWidth(),pixels.getBytesPerChannel(),pixels.getNumChannels()); glBindTexture(texData.textureTarget,texData.textureID); glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_FLOAT,pixels.getData()); glBindTexture(texData.textureTarget,0); #endif }
//---------------------------------------------------------- void ofTexture::readToPixels(ofShortPixels & pixels) const { #ifndef TARGET_OPENGLES pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glTypeInternal)); ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT,pixels.getWidth(),pixels.getBytesPerChannel(),pixels.getNumChannels()); bind(); glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_UNSIGNED_SHORT,pixels.getData()); unbind(); #endif }
//---------------------------------------------------------- void ofFbo::readToPixels(ofFloatPixels & pixels, int attachmentPoint) const{ if(!bIsAllocated) return; #ifndef TARGET_OPENGLES getTexture(attachmentPoint).readToPixels(pixels); #else pixels.allocate(settings.width,settings.height,ofGetImageTypeFromGLType(settings.internalformat)); bind(); int format = ofGetGLFormatFromInternal(settings.internalformat); glReadPixels(0,0,settings.width, settings.height, format, GL_FLOAT, pixels.getData()); unbind(); #endif }
bool fboRecorder::endFrame(bool _showBuffer){ if(!isRecording()) return false; if(!useGrabScreen){ if(!bFrameStarted) return false; fbo.end(); //fbo.getTexture().getTextureData().bFlipTexture = false; bFrameStarted=false; } static ofTexture tmpTex; int w = ofGetWidth(); int h = ofGetHeight(); if(!tmpTex.isAllocated()){ tmpTex.allocate( w, h, GL_RGBA ); } switch(fboRecMode){ case VIDEOREC_MODE_FILE_H264 : case VIDEOREC_MODE_FILE_PNG : { ofPixels pix; pix.allocate(fbo.getWidth(),fbo.getHeight(), ofGetImageTypeFromGLType(GL_RGB)); if(useGrabScreen){ tmpTex.loadScreenData(0, 0, w, h); tmpTex.readToPixels(pix); } else { fbo.readToPixels(pix); } ofxVideoRecorder::addFrame(pix); break; } #ifdef KM_ENABLE_SYPHON case VIDEOREC_MODE_SYPHON: { //fbo.updateTexture( fbo.getTexture().texData.textureID ); if( useGrabScreen ){ //syphonServer.publishScreen(); tmpTex.loadScreenData(0, 0, ofGetWidth(), ofGetHeight()); //tmpTex = fbo.getTexture(); syphonServer.publishTexture( &tmpTex ); } else { //tmpTex = fbo.getTexture(); syphonServer.publishTexture( &fbo.getTexture() ); } break; } #endif default: return false; break; } // flush tmpTex.clear(); if(_showBuffer){ if(!useGrabScreen){ #ifdef KM_ENABLE_SYPHON if( fboRecMode==VIDEOREC_MODE_SYPHON ){ #else if(false){ #endif fbo.draw(0, 0, fbo.getWidth(), fbo.getHeight()); // show recorded image } else { fbo.draw(0, fbo.getHeight(),fbo.getWidth(), -fbo.getHeight()); // show recorded image } } } return true; } // LISTENERS void fboRecorder::beforeDraw( karmaControllerDrawEventArgs& _args ){ beginFrame(); } void fboRecorder::afterDraw( karmaControllerDrawEventArgs& _args ){ endFrame(videoRecShowOutput); }