GPU based live video recorder/looper?


#1

Hello friends,

I’d like to make a simple OF app that records video from a live camera feed and plays them back looping.

I’d like it to:
-Use GPU memory if possible for recording/playback
-Work on a RaspberryPi 3

Can anyone point me to some examples and/or addons out there than can help me in this?

thank you!

a


#2

I should add that I have look at @bakercp and @arturo and @jvcleave et al’s




This seems like the start of what I need but both repos are quite old and I’m getting many errors while trying to build it with 0.98.

Was any of this lovely functionality integrated into OF core in some way or other?


#3

depending on how long of a video you want to record, could you do this with an array for textures (or fbos) or one larger one that you draw multiple frames into?

this functionality is not built into OF but it shouldn’t be hard to make something that records a sequence on GPU and loops it…


#5

Thanks @zach
That is working for me!

I have a c++ syntax question that I can’t seem to sort out.
I’d like to make an vector of vector of textures, and i’d like to initialize the sizes in my .h file.

i’m tried:

#define BUF_COUNT 2
#define BUF_SIZE 100
std::vector< std::vector< ofTexture > > bufArray(BUF_COUNT,std::vector< ofTexture >(BUF_SIZE)); 

but i get the error

<img src="/uploads/default/original/2X/e/ed7c0cee7930439fcba6d5f32f4178a996db4fcb.png"width=“690” height=“28”>

I then tried:

vector< ofTexture > buf;      //array of textures
vector< buf > bufArray;             //array of array of textures

and got this error:

I also tried:

static vector< ofTexture> buf;      //array of textures
vector< buf > bufArray;             //array of array of textures

and got this error:

is this a syntax issue or i have a bigger problem?


#6

If you want to define a type (to make things a little more terse), you can do something like this:

typedef std::vector<ofTexture> BufferType; // This creates an alias for a vector of textures.
std::vector<BufferType> buffArray; // This uses that alias and is eqiv to:

std::vector<std::vector<ofTexture>> buffArray

Template parameters must be concrete types, not variables (buf in your last example is a static variable of type vector<ofTexture> buf;.

I often use this in classes where I’m using a complex type and I don’t want to type it out every time. e.g.


#7

Also, if you are using fixed size std::vector you might also consider the new std::array type, which gives you std::vector like behavior, but is essentially a good old fashioned c++ array.