Use a generic USB webcam with Open Wonderland

The Webcam Viewer module for Open Wonderland has typically only worked seamlessly with particular models of Axis webcam. However, recent helpful postings on the Open Wonderland forums have shown that it is indeed possible to use a common garden-variety USB webcam with the module, provided an intermediate application is used to convert the camera output into a HTTP Motion JPEG (MJPEG) stream. Handily, the awesome VLC media player is capable of this.

The below guide outlines how to perform such a conversion on a machine running Windows XP Home. The resulting stream can then be accessed by other Wonderland clients (in my case, on OpenSolaris snv_134 x64). I am using a cheap and good Logitech C600 USB webcam.

First thing to note: use VLC player version 1.1.2 (and presumably later). I was initially using a slightly earlier version of VLC and it just plain didn’t work as it should – and some of the user interface elements and options were confusing to boot. After a quick upgrade, things went smooth as silk.

 

Let’s get started. Attach the webcam, fire up VLC player, and from the “Media” menu item in VLC click “Streaming…”. In the window that appears, click on the “Capture Device” tab, ensure the “Capture mode” is set to “Direct Show”, and that your webcam is selected as the video device (“Logitech Webcam 600” in the below example). Under “Video size”, enter the setting 640×480.

VLC player webcam settings

Click “Stream” to proceed. In the window that appears, check that “Source” is set to dshow://, then click “Next” to proceed:

VLC webcam streaming - more settings

In the window that appears, for the “New destination” setting, select HTTP from the drop down list (as we are setting up streaming over the web). Tick “Display locally” to see a local real-time preview of the stream (once it’s running) if you like – I find this useful.

VLC streaming - setting up HTTP streaming

Click the “Add” button to proceed. In the window that appears, enter the destination path for the stream output (/test.mjpeg in the example). Assuming you are not running another server on port 8080 of the machine you have the webcam attached to (e.g. the Wonderland admin web server…) you can leave the port number at its default. Tick the “Activate Transcoding” option, and select a Motion JPEG (MJPEG) profile. If one does not exist, then you’ll need to create one – covered in the next step:

VLC HTTP streaming settings continued

To create an MJPEG profile, click the right-most button from the row of three visible to the right of the “Profile” drop-down list. In the window that appears, make sure the “Encapsulation” tab is selected, and click the “MJPEG” radio button:

VLC MJPEG settings

Next, click on the “Video codec” tab, tick the “Video” option, and double check that the codec is set to M-JPEG. The other settings may be left at defaults, although once your stream is successfully running the “Frame Rate” setting may be revisited to achieve a suitable quality/performance balance. Give the profile a name (“MJPEG” in the example) and click “Save” to exit back to the “Stream Output” window:

VLC MJPEG settings

Click “Next” and you will be presented with a final group of miscellaneous settings, and text equivalent of the GUI commands you have just executed for power users to manually tinker with. Ignore these for now, and simply press “Stream”. All going well, you should be presented with a real-time preview of the generated stream output (this is blank in the below screengrab as Windows won’t include live video when dumping window output), and at the bottom-left of the player window you should see a status of “Streaming”:

VLC live stream

Now, the fun part – to access the video stream from our virtual world. This assumes you have downloaded and installed the Webcam Viewer module (documentation may be found at http://wiki.java.net/bin/view/Javadesktop/ProjectWonderlandServerAdministration#Managing_Modules) and have dropped the module into your world. Open up the webcam stream using the IP address of the machine the webcam is attached to, being mindful of the port number and the path of the stream output you configured in VLC player. Using IP addresses for now lets us sidestep any potential hostname lookup issues.

For example, my Windows machine running VLC has the IP address 192.168.1.4, and the name of my output stream is test.mjpeg accessible over port 8080 – so the address I enter into the Webcam Viewer app in Wonderland on my OpenSolaris client is http://192.168.1.4:8080/test.mjpeg.

Wonderland in-world webcam

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s