Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the previous webcam frame #27

Open
aatishb opened this issue Sep 25, 2020 · 1 comment
Open

Get the previous webcam frame #27

aatishb opened this issue Sep 25, 2020 · 1 comment

Comments

@aatishb
Copy link

aatishb commented Sep 25, 2020

Hi, I wanted to create an effect where I take the difference of the current and the previous webcam frame to detect motion. I tried something like this:

void main () {

    vec4 w1 = texture2D(channel0, uvN());
    vec4 w2 = texture2D(backbuffer, uvN());
    vec4 test = w1 - w2;

    gl_FragColor = vec4(test) ;
    
}

But this doesn't work because it subtracts the previous output frame (instead of the previous webcam frame) from the current webcam frame, which leads to a flickering effect. So my question is simply, is there a way for me to access the previous webcam frame?

Thanks so much for this tool, it is really fun to play around and learn with.

@shawnlawson
Copy link
Owner

Oh, interesting. I tried drawing to different areas of the frame buffer, but turns out that I have texturing set to clamp to edge, meaning that the edge color stretches across the frame. So even with an overlay blackout, I'm not convinced that method would work either.

I honestly haven't used the camera much as a texture, but sounds like an interesting feature. Should we add it as a feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants