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
104 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
104 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
104 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
104 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
104 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



Using Phidgets boards - Feb 2, 2013 at 11:58AM
Francisco Esquembre
104 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
104 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


Replies to Using Arduino boards with EJS

Re: Using Arduino boards with EJS - Mar 25 2013 8:03PM
Diego Racero
11 Posts

Hi Franciso, I`m now experimenting wiht Arduino Leonardo and I have a question.
In your example you're using linux and the following sentence

arduino.connectSerial("/dev/tty.usbmodem1421")

Should ¡ld I replace It for

arduino.connectSerial("COM6")?

Because I'm using windows and my Arduino board was installed in COM6 and connected through USB port.

Thank in advance for your help.



Re: Re: Using Arduino boards with EJS - Mar 26 2013 3:45AM
Francisco Esquembre
104 Posts

Yes, that should be it. Remember to install the Arduino drivers.
I don't think we have tested the Leonardo board, though...

Paco



Re: Re: Re: Using Arduino boards with EJS - Mar 27 2013 8:48AM
Diego Racero
11 Posts

Paco, thank you for your help. I replaced the line you suggested and It works perfectly well.
I used the temperture example but with some modifications because I´m tryin to perform a remote laboratory turning on and turning off a laser diode and illuminate a difraction slit.
Now I´m moving to work in the Moodle integration.

Surely I´ll be requesting for your help again.

Thank you very much in advance for that.



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