We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Live video feed as texture
Page Index Toggle Pages: 1
Live video feed as texture (Read 976 times)
Live video feed as texture
Dec 7th, 2007, 7:08pm
 
The short version:
How can we get a webcam feed to play smoothly as a texture on multiple vertex shapes in OpenGL? When the texture updates, the whole processing sketch freezes until the update is finished. So with a 5 fps feed we get 5 hickups a second.

The long version:
Hi,
we are working on an interactive installation at Oslo School of Arcitechture and Design (www.aho.no). On our project blog (exhibition-project.blogspot.com) you can follow our progress.

We have had Marius Watz as our processing mentor the last weeks and several weeks earlier this year. He has been very helpful. But we have stumbled into an OpenGL problem that gives us quite a headache.

We are using windows xp, processing 0135 and abstracplane's vdig to get images from a Logitech quickcam pro 9000 (Which added a whole world of trouble on it's own, i.e. getting resolutions above 640x480, wich we still don't get) into processing through the core processing video library. This image is then used as a texture on shapes made by vertexes to make a kaleidoscopic effect.It works nicely in P3D mode, but not in OpenGL. And we need the overhead framerates in OpenGL badly. In OpenGL it works like it should, exept for when the webcam image updates (thats all the time since it is live). During the short update it seems to freeze the processing sketch for one or two frames (at 40 fps) which totally breaks the fluidity we hope for. After browsing the forums i discovered Ben Fry's answer to a related question:

"the video -> opengl texture code is completely unoptimized. you could actually make movies play very nicely by handling your own textures, reading frames from the video and using glUpdateTexture()..."

Which brings hope for a solution that can save us. But it would be great if anyone could explain how to do the texture updating with some code examples, as none of us (including Watz) have worked much with GL textures.

We have tried several machines (mac and windows) to check if it was the hardware, but that is not the case it seems. The installation is due to open next Thursday...

Re: Live video feed as texture
Reply #1 - Dec 8th, 2007, 8:08am
 
Quote:
In OpenGL it works like it should, exept for when the webcam image updates (thats all the time since it is live). During the short update it seems to freeze the processing sketch for one or two frames


Hi, I don't know much about OpenGL textures - and by the way does glUpdateTexture() exist somewhere??? - but how about trying to update the texture (or camera access) in another thread, so it won't delay the draw() method ? Maybe it could solve your freezing problem ?
Re: Live video feed as texture
Reply #2 - Dec 8th, 2007, 2:21pm
 
I would believe that would solve it if it was the cpu that made the hickup. But my feeling is that it is the GPU that makes the hickup (Since P3D works smoothly, but at a lower framrate), would multithreading processing also affect the GPU?
Re: Live video feed as texture
Reply #3 - Dec 8th, 2007, 3:42pm
 
No, if this is really a GPU problem, multi-threading won't solve anything.

Can you post the part of code concerning the texture update? Is it a PImage/PGraphics you pass to the texture() method?
Re: Live video feed as texture
Reply #4 - Dec 10th, 2007, 3:34pm
 
We sort of use PImage. I guess "Capture" from the Video library is an extension of PImage. So the use is sort of like this:

Capture harpCam; // we are making a harp device with cam.
harpCam = new Capture(this, width, height);
harpCam.read();
texture(harpCam);

So is there an better method for doing this with the  OpenGL renderer? P3D works smoothly, but does not reach the potential fps of the OpenGL rendrer.

edit/missed som steps in the capture flow.
Page Index Toggle Pages: 1