LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Lagz on March 18, 2007, 11:39:10

Title: LWJGL + Webcam
Post by: Lagz on March 18, 2007, 11:39:10
Hi,

Does anyone have experience of using webcams with JOGL. I basically want to link a webcam to an openGL texture. Does anyone know the best way to do this?
Title: Re: LWJGL + Webcam
Post by: princec on March 18, 2007, 12:41:09
I've done this (using LWJGL, not JOGL, but the principle is the same).

It's not as easy as it should be.

Basically the complicated bit is figuring out how to read image data out of the camera - for that, you need either some custom windows media code in C++ to do the job or someone else's prebuilt code (NCTVideo is what I used). There is a possibility the Java Media Framework can do it but I abandoned that years ago because it was so obscure and difficult to code and didn't seem to work.

Once you've got your image data it's a doddle to just blit it straight over to a texture using glTexSubImage2D every frame and then render it however you want.

Cas :)
Title: Re: LWJGL + Webcam
Post by: rainforest on April 17, 2007, 01:06:18
I was wondering how to use this NCTVideo with Java (where can I get it). Is the API (or whatever) license free for the users? Is there any other alternatives?

I wanted to make a scree saver where the user will be able to look in the webcam within a 3D perspective, waiting for your reply ...
Title: Re: LWJGL + Webcam
Post by: princec on April 17, 2007, 20:46:17
http://www.nctsoft.com/products/NCTVideoStudio/

All you need to know is there.

You'll need to write some JNI to interface to it. And no, it won't work on the Mac or Linux, you'll need to find another way to do it.

Cas :)
Title: Re: LWJGL + Webcam
Post by: rainforest on April 17, 2007, 22:48:10
Thank u very much Cas, seems a wonderful activeX controller, bad that it is not written in Java. Im damn 'good' in JNI; I was wondering if anyone here has knowledge about an easy tutorial for learning JNI quickly?
Title: Re: LWJGL + Webcam
Post by: markush on April 18, 2007, 09:19:59
Quote from: princec on April 17, 2007, 20:46:17
http://www.nctsoft.com/products/NCTVideoStudio/

All you need to know is there.

You'll need to write some JNI to interface to it. And no, it won't work on the Mac or Linux, you'll need to find another way to do it.

Cas :)

On Mac you can use quicktime for java to use the webcam. That works on windows, too (if the user has installed quicktime).

Won't work on linux though.