How to modify motion tracking in AS3
Asked Answered
P

3

9

I have this amazing tutorial at http://www.computerarts.co.uk/tutorials/build-your-own-motion-tracking-system In the developer version, the tracker moves along the X-axis. I want it to stay stationary rather than moving and when the object from the webcam comes in front of it. The stationary cross mark should be able to trigger an event preferably a sound when anybody is in front of it. Would be grateful for the help I get. I am a complete noob in AS. If you have any other tutorial and link me to it I would appreciate it.

Perfidious answered 27/1, 2012 at 15:38 Comment(3)
That is an awesome tutorial, thanks for sharing that site :)Making
+1, Cool tutorial, I'll see at it and return to your question!Conidium
Thank you Eugeny89, and no problem mouseasPerfidious
D
1

The easiest way to do this would probably be to create either a second Point to keep track of the position. Then you can test collision with the TrackerMC that doesn't move. To do this: At the top, add

private var _movingPos:Point = new Point();

Then, in the resize() function, add:

_tracker.x = sW * 0.5;
_movingPos.y = sH * 0.5;

Then, in loop() change _tracker.x += (_pos.x - _tracker.x) * .1; to:

_movingPos.x += (_pos.x - _movingPos.x) * 0.1;

And, to test if the point is in front of the crosshair, add at the end of the loop() function:

if (_tracker.hitTestPoint(_movingPos.x, _movingPos.y, true))
    doSomething(); // Add whatever custom function here.

In your doSomething(); function, you can play a sound, or anything else. For debugging, you can add a second TrackerMC and update its position to equal _movingPos to see where you are.

Driskell answered 10/4, 2012 at 0:2 Comment(0)
M
1

I wrote a similar motion tracker in AS3. Its on github. You can check it out here: https://github.com/chinchang/AS3-Motion-Tracker

Let me know if you have any queries on it.

Also a sample game made with it here.

Cheers!

Melleta answered 20/7, 2012 at 18:43 Comment(0)
A
0

I don't know how much you are a noob in AS3, but this is kind of a complicated thing.

I happen to have had a few AS3 classes in school with motion tracking, that makes use of your webcam. I have no clue of how to use it but I still have the packages of source code of the AS3 code we used. Here you can find the two packages:

They're coded by a guy named Grant Skinner and I do not know what the copyright and restricions on them are, so be warned :)

Here you can find more, and perhaps updated versions: http://www.insurgent.com.ar/en/tag/grant-skinner-en/

I hope this will help!

Andyane answered 25/6, 2012 at 13:42 Comment(1)
Thank you so much for the share, I am a n00b but then I do know how to move about with source codes. Thank you againPerfidious

© 2022 - 2024 — McMap. All rights reserved.