Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Using hardware post and replies

Return to the Using hardware thread
Login to post to this thread

Using your WebCam with EJS - Feb 2, 2013 at 12:16PM
Francisco Esquembre
121 Posts

EJS has two twin new View elements that can read the input from your laptop or web camera and display it on a DrawingPanel 3D. Both elements work similarly, if only the one for the local camera requires extra software. The icons for these elements are in the 3D Drawables -> Tools and utils palette and look like a circle with the AR letters inside them.

Using the whole AR (Augmented Reality) system is a bit complicated, and we (the authors of this new element) are planning to write a paper on it. But if you feel adventurous, here are the steps to run the attached example:

1- Download the GStreamer runtime libraries and unzip them to your EJS workspace "export" directory. This should create a gstreamer directory with four subdirectories inside it. You only need to keep the one that corresponds to your operating system (though I keep them all, just in case). The copy I use of these libraries is a 100 MB file you can download from my site at  http://fem.um.es/EjsWiki/uploads/Download/ARsystem/gstreamer.zip

These libraries are needed to run properly the AR view element that uses your local camera.

2.- Download the 500KB data.zip file at http://fem.um.es/EjsWiki/uploads/Download/ARsystem/data.zip

This file has alternative configuration files for your particular camera. The one in the example works well for the buil-in camera for the latest 15'' Retina Mac Book Pro.

The file also has a directory with the patterns that the AR system can recognize. Print the ejs.pdf file in a white piece of paper.

(Begin Update)
3.- Edit the "Port" property of the ARSystem View element to match the camera you want to use.
- On a Mac, Port should be "0" for the built-in camera, "1" for a USB camera.
- On a Windows machine, you can get the exact name for your camera from the "Control panel -> Device administrator -> Image devices". (I am freely translating these names, since my Windows is in Spanish. :-) )
(End Update)

4.- Now, run the EJS example attached, and hold the EJS marker (the one you printed) in front of your laptop camera. The program main panel should show the video from your camera showing you, the EJS marker you hold in your hand, and a red rectangle surrounding the EJS marker.

Phew! That was a long explanation.

Good luck!

Paco

Post edited February 3, 2013 at 11:31 AM EST.

Attached File: ejs_MatchTheMotion.zip


Replies to Using your WebCam with EJS

Re: Using your WebCam with EJS - Feb 02 2013 6:44PM
Diego Racero
11 Posts

I couldn't see the webcam, the simulation run without any errors, but nothing appeared.

¿is there some misconfiguration?

I running windows 7, 32 bits version.

Thanks in advance.



Re: Re: Using your WebCam with EJS - Feb 03 2013 7:00AM
Francisco Esquembre
121 Posts

Hi Diego,

I forgot something important. You need to edit the "Port" property of the ARSystem View element to match your system camera.

In my example, the Port property reads "0", meaning the built-in camera of my MacOSX laptop. ("1" would be a camera connected to a USB port.)

For a Windows computer, you need to change this to read the exact name of your integrated or USB camera.

You can get the exact name for your camera from the Windows "Control panel -> Device administrator -> Image devices". (I am freely translating these names, since my Windows is in Spanish. :-) )

I tried this on my Window Virtual Machine running under MacOSX and it does not work. But my Windows colleague who wrote this code with me says that he sets the Port property to "Integrated Webcam" (that is the name of his built-in camera on his laptop) and it works just fine.

Let me know if it works for you.

Paco

Post edited February 3, 2013 at 11:27 AM EST.



Re: Re: Re: Using your WebCam with EJS - Feb 03 2013 11:28AM
Francisco Esquembre
121 Posts

Diego,

I have updated my previous reply. In case you read my old reply, please read it again.

Paco



Re: Re: Re: Re: Using your WebCam with EJS - Feb 08 2013 7:32PM
Diego Racero
11 Posts

Thank you very much Paco, I fallowed your instructions read the name of the web cam in Windows device administrator and get the program working.
For my particular case the name is WebCam SC-0311139N, I just replace the name in port and works perfectly.

Thank you very much for your help.



Re: Using your WebCam with EJS - Feb 15 2013 5:57PM
Diego Racero
11 Posts

Franciso, I puted the pattern number one and the number 76 that and found in data folder but I could not see the red rectangle around the printed graphic.
May be is there still any problem with AR module configuration, the only thing that I noted is that It says "ejs:76" in the pattern option of AR module, Is this Ok?.

Thanks in advance for your help.

Post edited February 15, 2013 at 5:57 PM EST.



Re: Re: Using your WebCam with EJS - Feb 15 2013 6:39PM
Francisco Esquembre
121 Posts

Does the image you printed look like the one attached to this reply?

Paco

Attached File: ejs.pdf



Re: Re: Re: Using your WebCam with EJS - Feb 16 2013 9:49AM
Diego Racero
11 Posts

I´m affraid not, I´m going to print that one and let you know.

Thank you very much for your help.



Re: Re: Re: Using your WebCam with EJS - Feb 16 2013 10:34AM
Diego Racero
11 Posts

Paco, I printed the image you suggest and It worked !!!!

I wonder why?, but I know that you're preparing a paper  so I´ll be waiting for the explanation.

Thank you very much again for your help.



Re: Re: Re: Re: Using your WebCam with EJS - Feb 16 2013 3:31PM
Francisco Esquembre
121 Posts

Because the element is instructed to recognise that pattern. (The pattern file, matching the PDF I sent you, is inside the element code.)

You were probably using any other file and the element could "see" it, but "thought" it was not the pattern you were asking for.

Paco



The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics