ofxOMXCamera: Make a copy of .getTextureReference()

Im using the ofxOMXCamera addon and running the “example-texture-mode” example on a RPI.
I want to make a copy of the texture and store it and im running into problems.

The code is quite simple, ive tested it using videoGrabber on a desktop and it works but the OMXCamera addons clearly works differently. here is the gist of it:

void ofApp::draw()
{
        if (videoGrabber.isTextureEnabled())
        {
                videoGrabber.getTextureReference().copyTo(bufferCopy);
                videoTexture.loadData(bufferCopy, GL_RGBA, GL_UNSIGNED_BYTE);
                videoTexture.draw(45, 75, 640, 430);
        }
}

I have defined and allocated buffers , but the error I get is the following:
“error: ‘class ofTexture’ has no member named ‘copyTo’ videoGrabber.getTextureReference().copyTo(bufferCopy);”

and

" error: no matching function for call to ‘ofTexture::loadData(ofBufferObject&, int, int)’
videoTexture.loadData(bufferCopy, GL_RGBA, GL_UNSIGNED_BYTE); "

Could someone point in the right direction here. I want to make a copy of the texture (texture to texture) using the OMXCamera addon running on a RPI

Thank you

I could be wrong but there may not be a way to do it like this because of OpenGL ES. You should be able to do it with an ofFbo though

yes you can’t copy a texture to a buffer in opengles and even in opengl it’s only used for 1d textures. the right way to copy a texture is to draw it into an fbo

Thank you both for getting back to me.

I’ve used something like this before to test making copies of the texture (this is pseudo code that I remember):

fbo.begin(); // ofFbo defined and allocated in setup
vidGrabber.getTexture().draw(0,0);
fbo.end();

fbo.getTextureReference().copyTo(bufferCopy);  //ofBufferObject defined and allocated in setup - bufferCopy.allocate(camWidth * camHeight * 4, GL_STATIC_DRAW);
videoTexture.loadData(bufferCopy, GL_RGBA, GL_UNSIGNED_BYTE); // ofTexture defined and allocated in setup - videoTexture.allocate(camWidth, camHeight, GL_RGBA);
videoTexture.draw(camWidth, 0);

I’m going to edit the circular buffer class that I found on the forums to use ofTextures and not ofPixels: Real time video delay | port from Processing
But this is the gist of how im going to make the copies of the texture

@arturo I’m new to using fbo’s, is there a way to draw into the fbo without actually drawing into it on screen?
Is this an efficient way to copy the texture?

(The reason i’m not using the circular buffer as-is, is because I want to speed up the app. With the texture-modeonly I get almost double the performance on my RPI)

Thanks Again

just drawing to the fbo should be fine. if it’s an fbo to another fbo then you can also blit it bu i don’t think it’s much faster if at all

1 Like

Thanks a lot