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.
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.
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!
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!
© 2022 - 2024 — McMap. All rights reserved.