Education Prize Logo
Science SPORE Prize
November 2011

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

Using hardware

Return to the EJS Modeling forum
Login to post to this thread

Using your WebCam with EJS - Feb 2, 2013 at 12:16PM
Francisco Esquembre
144 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


Current Replies - View all
Re: Using your WebCam wit...   (Diego Racero - Feb 2, 2013 at 6:44PM)
Re: Re: Using your WebCam...   (Francisco Esquembre - Feb 3, 2013 at 7:00AM)
Re: Re: Re: Using your We...   (Francisco Esquembre - Feb 3, 2013 at 11:28AM)
Re: Re: Re: Re: Using you...   (Diego Racero - Feb 8, 2013 at 7:32PM)
Re: Using your WebCam wit...   (Diego Racero - Feb 15, 2013 at 5:57PM)
Re: Re: Using your WebCam...   (Francisco Esquembre - Feb 15, 2013 at 6:39PM)
Re: Re: Re: Using your We...   (Diego Racero - Feb 16, 2013 at 9:49AM)
Re: Re: Re: Using your We...   (Diego Racero - Feb 16, 2013 at 10:34AM)
Re: Re: Re: Re: Using you...   (Francisco Esquembre - Feb 16, 2013 at 3:31PM)
Using Phidgets boards - Feb 2, 2013 at 11:58AM
Francisco Esquembre
144 Posts

EJS has now new a Model Element to control Phidget boards.

The best way to learn how to use it is to inspect an example. See attached zip with one example.

Before you inspect the example, you need to download the Phidget drivers from http://www.phidgets.com/docs/Operating_System_Support and install them in your computer. Then. load the attached example and inspect it.

You need additional hardware for making things work. The boards just act as I/O boards. Whatever software you attach to them makes the real work. But if you are playing with these boards, you know this already.

For instance, you need a Phidget 1048 board (4 probe temperature sensor) for the attached example.

Good luck!

Paco

Attached File: ejs_PhidgetTemperatureExample.zip


Using Arduino boards with EJS - Feb 2, 2013 at 11:55AM
Francisco Esquembre
144 Posts

EJS has now new a Model Elements to control Arduino boards.

The best way to learn how to use it is to inspect an examples. See attached zip with an example.

Before you start, you need to download and install Arduino standard software from http://arduino.cc/en/Main/Software. This allows you to install the drivers for your computers AND install in your Arduino board the script StandardFirmata. Both things are a must before using the example attached. You install the script by running the Arduino software and selecting "File->Examples->Firmata->StandardFirmata. Then, click the "Upload" icon (looks like a small right arrow) in the task bar of the Arduino software. This step needs to be done only once (per board).

Now, open the attached Arduino example in the latest EJS and inspect the example (in particular, the Model -> Elements tab).

You need additional hardware for making things work. The boards just act as I/O boards. Whatever software you attach to them makes the real work. But if you are playing with these boards, you know this already.

Good luck!

Paco

Attached File: ejs_Arduino_LedTempServo.zip


Current Replies - View all
Re: Using Arduino boards ...   (Diego Racero - Mar 25, 2013 at 8:03PM)
Re: Re: Using Arduino boa...   (Francisco Esquembre - Mar 26, 2013 at 3:45AM)
Re: Re: Re: Using Arduino...   (Diego Racero - Mar 27, 2013 at 8:48AM)
The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics