PDA

View Full Version : Video Stream plugin


Brett Lindberg
07-15-2009, 01:15 PM
Does anyone have an example of how to write a plugin to read a camera (say, a webcam): I know it's already in Vizard, but I want to add a different camera.

And is this a sensor, image generator, python plugin, or custom node?

farshizzo
07-16-2009, 10:19 AM
The Vizard SDK comes with an image generator plugin example. It simply generates random RGB data and puts it into a texture. You could use that example and use the image data coming from the camera instead of generating it randomly.

To create a plugin you will need to be familiar with OpenSceneGraph and OpenGL.

An alternative is to create a blank texture and feed the image data into the texture using the texture.setImageData command. This can be all done within the Python script, without needing to write a plugin.

Brett Lindberg
08-13-2009, 03:46 PM
I'm trying to do the second method: is there an easy way to determine the location of the image data, say a buffer in jpg format?

farshizzo
08-13-2009, 04:40 PM
Do you mean accessing the image data of a Vizard texture? If so, you can use the texture.getImageData command to get the raw RGB buffer of a texture. If not, can you be more clear about what exactly you want to do?

Brett Lindberg
08-13-2009, 05:59 PM
After some looking, I think I'm trying to set the image data of a texture to the contents of an OpenGL ARB_pixel_buffer_object. Can that be done using PyOpenGL?

farshizzo
08-18-2009, 09:21 AM
Is the PBO created within the Vizard OpenGL context or a separate context? Either way, it seems inefficient to download the data from a PBO and copy it into a texture then upload it back to the graphics card. Ideally you would want to get direct access to the video source and copy it into the Vizard texture.

Does the video camera provide some sort of API for accessing the data? If so you could create a Python extension that accesses the data and returns it to your script. From there you could use the texture.setImageData command.

Brett Lindberg
08-18-2009, 02:59 PM
Is there an example for the texture.setImageData command?
More precisely, how would you specify the buffer in the "data" parameter?

farshizzo
08-18-2009, 03:06 PM
This knowledge base article (http://kb.worldviz.com/articles/470) describes how to convert a Python Imaging Library image to a Vizard texture. The concept is pretty much the same. The data parameter needs to be a string or buffer object that contains the raw image data.