WebcamVideo, how to use it?

I need to integrate webcam streaming into my project, I found out that Panda3D does have this class, but I was unsure how to use that? Is there any available tutorial or code snippet laying around?

This is what I gather from reading the API reference about it:

print "Choose a webcam"
for o in range(WebcamVideo.getNumOptions()):
  option = WebcamVideo.getOption(o)
  print "Option %d, '%s' at %f fps with size %dx%d" % (o, option.getName(), option.getFps(), option.getXSize(), option.getYSize())

o = int(raw_input("option>"))
option = WebcamVideo.getOption(o)
cursor = option.open()

Now, ‘cursor’ should be a MovieVideoCursor instance (see API) you should be able to use.

Note that there is also the OpenCVTexture class which does something similar (and might be somewhat easier to use). If it’s not already exposed, it will be in 1.6.0.

ok, I get that code to work in panda 1.5.2 version. But, how to render that in the window?

Is it work like an node?

Or, it will pop up a window?

This is described in the API docs. You have to create a Texture and set it up with the movie data. Then you can apply it to a model like any other texture. If you don’t have a model, you can create a card:

tex = Texture('movie')
cursor.setupTexture(tex)
cm = CardMaker('card')
card = aspect2d.attachNewNode(cm.generate())
card.setTexture(tex)

David