MarcPelland.com
Welcome at » Motion Tracking and Papervision

Motion Tracking and Papervision

A couple of days ago I posted my first attempt at motion tracking in AS3 using a webcam and promised that I would play a little bit more with it. Well, I got a little bit anxious and before refining the tracking code I decided to put it to use.

You may have seen the video of head tracking using the Nintendo Wii. That video inspired me to try my hand at the same concept using Flash, Papervision 3d, and my newly discovered love for trying to get motion tracking / facial recognition into Flash.

Motion Tracking and Papervision

As such, I have created this example which is my first step in creating some sort of tracking interaction with a 3d scene. if you would care to see a little bit more detail about what is going on, hit X to see the video and W to see the framerate. Stay tuned for more updates as I update the tracking code. Once again, I will post the source when it is a little further along.

** please note that you require a webcam to take advantage of the motion tracking, if you do not have a camera the scene’s camera is simply controlled by the mouse.

96 Responses

  1. MikeM




    This is amazing. Can’t wait to study it. Thanks! Keep it up




  2. Sweet. Nice work.




  3. Good site I “Stumbledupon” it today and gave it a stumble for you.. looking forward to seeing what else you have..later




  4. I always read your blog in high spirits. Thanks :)




  5. That’s the writing style that tickles me.

  6. Steve




    Awesome. I’m getting a spot in line to get a look at the source code.




  7. nice picture :)




  8. yes, keen to see the source code as I had a similar idea… what res is the camera running at? perhaps it might be better to use coloured paper or LED’s mounted on saftey goggles like your wimote head tracking… you could then easily track the location of the two coloured LED’s as you would infra-red leds.

    heres an experiment I made a while ago with flash webcam… nothing to do with headtracking (yet)

    http://hydroplain.blogspot.com/2008/10/this-is-as3-time-slicing-demo-i-was.html




  9. Wowww realy great flash animation :) I want to Macromedia flash for my new Güvenlik ve kamera sistemleri web pages. but havent got time




  10. http://www.marcpelland.com/motion3dController.zip




  11. Wow. Super!

  12. velcro




    this could prolly be applied to an IR camera and IR leds. just a thought




  13. I was thinking about using IR LEDs but I wanted to try and make it work with just a user and a webcam. I am trying to find more time to play with the idea, have been thinking about connecting Processing and Flash and using the OpenCV Face Detection Library to track the motion. So far, I have been unsuccessful but I am getting there




  14. Thanks for these great tutorials!

  15. joe




    its would be nice to show a way without always using he document class in the flash IDE. I find just using the document class is limiting in real world projects. Most times there are other elements in a flash website and this approach limits you.

  16. rye




    thanks for this. I appreciate it! it’s a great orientation!

  17. Freddy




    “its would be nice to show a way without always using he document class in the flash IDE. I find just using the document class is limiting in real world projects. Most times there are other elements in a flash website and this approach limits you.”

    I agree, and even more difficult when you have to work with a team of flash timeline only designers :(

    still, great tutorial!




  18. it would be very easy to port most of the tutorial files over to pure AS3 (no document class). the only instance where it would become an issue is with the movieassetmaterial. however, i believe you could do something along the following:
    [Embed(source = "/materials.swf", symbol="sphereMaterial")]
    private var sphereMaterial:Class;

    from there you could just create an instance of that class as a clip and use it as a material.

  19. Freddy




    Hi again, on Flash CS4, I got the “1084: Syntax error: expecting rightparen before 55




  20. can’t help much without seeing the code that you are using or knowing which file you are working with.

    can you send me an email with a more detailed description of your issue?

  21. ChicoPacoPancho




    “Hi again, on Flash CS4, I got the “1084: Syntax error: expecting rightparen before 55″

    Got the same. This is the line causing the problem:

    var planeMaterial:ColorMaterial = new ColorMaterial(0×55FF11);

    If you copy and paste the code I get an error because of the little ‘x’. Just retype the x and that should fix it.




  22. Coot tutorial! Tenx!




  23. Thank you so much. This was the first tutorial on Papervision that actually compiled. Not even the offical website’s sample code worked properly. You did a great job covering the essentials.

    A few suggestions:
    -Copying your sample code on the webpages inserted extra lines and “#” symbols. Oops.
    -A couple screenshots and trace messages from your compiled samples would have helped reaffirm my progress.




  24. Anyone else get this error?

    ReferenceError: Error #1065: Variable sphereMaterial is not defined.

    I am using Flex Builder 3 and I am using the code in a new action script project.. am I missing an import?

    any help would be great

    thanks.

    Love the Tutorial :)

  25. FCX




    I’m also getting

    ReferenceError: Error #1065: Variable sphereMaterial is not defined.

    Dunno what to do with it.

  26. FCX




    using Flash CS4 with Papervision3D Public Alpha 3.0 – PapervisionX (18.09.08)




  27. FCX have you created the sphereMaterial clip in your library? or created a bindable instance of it in your source if you are not in flash IDE? that needs to be created in order to avoid that error…

  28. FCX




    No, I didn’t. Now works great!

    Amazing tutorial!




  29. I know this is an old post, but I just wanted to say THANK YOU! This tutorial was so easy to follow, and I’m really excited to have my first Papervision demo working :) Thanks again!

  30. jtalbea




    Awesome tutorial. I have a question though, I uploaded the source code and it loads great in firefox but not in IE6, do you know why? I can’t figure it out. Thanks!

  31. Dom




    I’m a 3D animator who’s just been briefed in a hurry to create with Papervision, it’s crash course of note! I’m using FlashMX ver6 and have no Actionscript 3.0 settings in Flash EDIT/PREFERENCES as mentioned in the tut above?:

    ‘Once you are synced up with the repository I would recommend loading Flash and going to Edit > Preferences. Go to the ActionScript category and select ActionScript 3.0 Settings’.

    any help most appreciated?!

  32. Jaibabu




    Can anyone please help me. How to draw the bar chart using Papervision with 3D effects(Multi dimension). Please give me some guidance and sample.

    Thanks




  33. thanks for guiding my first pv3d steps




  34. I very much appreciate the tutorial! I didn’t know I needed to make an .fla file of that class to compile it until I downloaded the source. Now I know. And so does everyone else ;^)




  35. Nice work, i’m waiting for a next Chapter. I like ur portfolio, some many interesting projects.

    Dom, to run actionscript u need flash cs3. Older version only works with actionscript 1.0 and 2.0.

    Bye




  36. As well as how to harness tools that have been created for you to build your own 3D experiences.For you, we are providing cheap age of conan power leveling for you, enjoy it.

  37. Max




    Hello, I’m having an issue with the step two. FlashDevelop & Flash says: The Type HelloPrimitives does not match the file name:…




  38. this could prolly be applied to an IR camera and IR leds. just a thought




  39. I always read your blog in high spirits. Thanks




  40. Dom, to run actionscript u need flash cs3. Older version only works with actionscript 1.0 and 2.0.

  41. Skant




    How Can I work just with Adobe Flash Cs4?
    All tutorials worlks with Flex and I’m not freanly with this aplicattion,

    Need I change to these aplicattion?

    thanks!

  42. Skant




    I always have the same error:

    “5008: El nombre de la definición ‘HelloPapervision’ no contiene la ubicación de este archivo. Cambie el nombre de la definición en este archivo, o cambie el nombre del archivo. K:\Documents and Settings\Cris\Escritorio\As3\Papervision3D_2.1.920\e01.as”

    ups, ! is in spanish! I hope the error number can show you whats going on?

  43. Skant




    ok! done!
    I have to undestand more acurate AS3!

    Congratulations fot this tutorial,

    ;)




  44. Thank you for sharing really worked to my jobs

  45. divertoso




    hello

    cud you make a tutorial teach how to usin flartoolkit (wich webcam) and show a maya collada object in swf…

    tks!!!!

  46. Gutza




    Awesome tutorial, this is something I was looking for to get me started with Papervision. One thing though: I get a “lookAt error” with the HelloClickability code…

  47. Krodil




    Hey.. nice work.. :)

    I get the cam feed and such, but when I run I get error
    1017: the definition of base class ObjectContainer3D was not found..
    Any help…




  48. Hi;
    I really like your papervision tutorial; it’s one of the few understandable beginners guides I could find!
    Anyway, I guess I have my FlashDevelop setup wrong. All I get when playing / publishing is a white background, instead of the primitives and stuff. FlashDevelop says “Build Succeeded”, but I’m not sure though.. Could you help me out?
    thanks in advance;
    Ruben

  49. Ray




    Nicely done!

    Finally a tutorial for us mere mortals…

    Papervision3D is no joke…you’d better eat your Wheaties… :)

    Thanks much!




  50. Hi,

    Thanks for uploading a great primer to Papervision3D! Really helped me get started on it =)

    Thanks!

  51. andy




    ReferenceError: Error #1065: Variable sphereMaterial is not defined.
    This was a headache for me. I was hunting down trying to add the MovieAssetMaterial class into the library, trying to figure out the PV3D component to see if i can drag something to the library, etc. Nothing worked, till i went to the MovieAssetMaterial documentations.

    So,

    To clarify to noobish users such as myself, you’d need to create a new MovieClip in the Flash IDE library, name it sphereMaterial, then click on “Export for Actionscript”….

    It should now work fine.

    I have never worked with flashdevelop or flex before, i have been working with the Flash IDE itself, so i wish more things had been spelled out for me, like the jump from setting up FlashDevelop to actually making a new document. I didnt know Flash IDE had to be up and running for FlashDevelop to run, and I didnt know I had to create a .fla file like usual, set the HelloPapervision document class in Flash IDE so that i can run the HelloPapervision.as code.

    I came into this completely new to FlashDevelop or Flex, so the unspelled things provided me with hours of consulting other guides.

    I appreciate the guide so far, it has carried me further than any other ones online. Just my input so its more newbie friendly :) . Especially since i am not stuck in the actual coding part…but the actual setup of paths/classes/libraries part.

    thanks for the efforts!




  52. Yeah – that “Error #1065: Variable sphereMaterial is not defined” threw me a bit too. I work in a combination of Flash IDE and Flex Builder 3, but unlike with FlashDevelop I can use Flex Builder to compile.

    MovieAssetMaterial needs to be passed the name of a MovieClip object in order to instantiate properly. So here’s how I did it…

    Drag a jpg into Flash (mine was of bricks) and create a MovieClip from it. Tick “Export for Actionscript” (if you don’t know where that is then learning Papervision is probably trying to run before you can walk), call the Class “Bricks” and subclass (“Base Class” they call it there) MovieClip – which should be the default.

    Now that you’ve created your MovieClip, publish the fla (ensuring you have “Generate SWC” ticked in your publish settings to create a SWC library along with the SWF.

    In Flex Builder > Project > Properties > Actionscript Build Path > Library Path, hit “Add SWC” and add your SWC in order to access your MovieClip with a jpg in it.

    You can then instantiate it using var bricks:Bricks = new Bricks() or whatever you called it. And then “sphereMaterial = new MovieAssetMaterial(“Bricks”)” will work.

    Anyway – that’s one way of doing it in Flex Builder 3, the important thing as far as I can see is that MovieAssetMaterial is passed a MovieClip object that it can use.

  53. CharlesG




    Great tutorial, no “have you seen me” coding and great explanations!

    Thanks




  54. Thanks for this!!!

  55. san




    awesome tutorial.. thanks for your hard work!! :)

  56. Marcos




    Thanks for the tutorial, mate. It is excellent: smooth to follow and right-to-the-point.

    We’ll be using papervision3D for nice projects at the university of Espírito Santo, Brazil, as part of the graphic design lab group.

    Thanks again!




  57. It’s Great, Good Job.

    It’s very ease this form.

  58. Mark Cabrera




    Thanks for the great tutorial! It was very easy to follow! :D




  59. anakra kuaförler




  60. All people deserve wealthy life time and credit loans or short term loan will make it much better. Just because freedom depends on money state.




  61. I got the “x” error (resolved above) and also another error for these two lines:

    var rotY: Number = (mouseY – (stage.stageHeight / 2)) / (stage.height / 2) * 400;
    var rotX: Number = (mouseX – (stage.stageWidth / 2)) / (stage.width / 2) * -400;

    Similar to the “x” issue where I needed to delete the “x” and type another “x” there, although in this instance I had to delete the “-” and put a “-” in it’s place. Maybe this will help someone.




  62. I can hardly wait to try it out. Great blog, thanks for it.




  63. Hey there:

    This is simple and easy to follow, but, the typical 3D problems that I get.

    My browser’s displaying a blank white screen. The flash object is present in the web page.

    I swfdump the swf file and I see the shapes defined in the swf but they are not being displayed.

    I did not move the camera or anything. I have the same code.

    anyone had this??

    Thanks

    Duncan

  64. akshay




    access to undefined property stage
    how to resolve this error?




  65. Very nice! Thanks a lot!

  66. Mark




    Hey there:

    This is simple and easy to follow, but, the typical 3D problems that I get.

    My browser’s displaying a blank white screen. The flash object is present in the web page.

    I swfdump the swf file and I see the shapes defined in the swf but they are not being displayed.

    I did not move the camera or anything. I have the same code.

    anyone had this??

    Thanks

    Duncan

    - I have the same problem, builds fine but just plain white screen with nothing inside. Ive tried everything to fix it the codes identical, no errors, the only thing I get is an output message saying the viewport autostage scale message like this:

    INFO: Papervision3D 2.0.0 (March 12th, 2009)

    INFO: Viewport autoScaleToStage : Papervision has changed the Stage scale mode.

    Please Help!!

    Mark




  67. Thanks for the article ..

  68. Virgilio




    Great tutorial to start, thank you very much Marc!

  69. Asaf




    I could not get it to work with
    super(0, 0, true, true) in the HelloClickability class
    So I change it to:
    viewport.interactive = true; – taken from anther tut.

  70. Sagar S. Ranpise




    Awesome tut!

    This is absolutely well written and very easy to understand!

    Thanks a lot for sharing!

    Looking forward to more PV stuffs!

    Thanks & Regards,
    Sagar S. Ranpise

  71. tu




    thank you very much. It’s very interesting.




  72. Really Cool … keep up!




  73. could not get it to work with




  74. thank you for sharing..




  75. This is good article 3d. Thanks for sharing well information




  76. Thanks for admin,very sharing..




  77. Was a beautiful page. Thanks to the designers and managers.




  78. This was a useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful




  79. Always good to see, this was a brilliant post. In theory I would like to write like this too.




  80. You need time to creat that interesting and additionally real effort to make such a good article




  81. Hello friend, I am very much happy to see your blog. But the problem is I can’t understand the language. Thanks for posting. All the best.




  82. Thanks a lot. Good kick-start for a newbie in flash-3d stuff.




  83. It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this. I want to say it would supply up to !




  84. I’m having an issue with the step two. FlashDevelop & Flash




  85. Howdy

    Great tutorials and flash improvement here ;) .
    I click on you portfolio and sounds good to me how the thing works and is interactivity. I would like to know if you could publish the code you used on that.

    Cheers.

    Best Regards,
    Daniel from Portugal




  86. thanks your sharing my dude




  87. nice sharing..




  88. I like this concept. I visited your blog for the first time and just been your fan. Keep posting as I am gonna come to read it everyday




  89. This a nice tutorial and very detailed with matching table of contents. I like the way you elaborated each step since it is easy to follow. Even if those people who don’t have enough knowledge about programing would have an ease to follow each step.




  90. would have an ease to follow each step.




  91. Many thanks to the person who made this post, this was very informative for me. Please continue this awesome work. Sincerely…

    The article is very well!




  92. MovieAssetMaterial needs to be passed the name of a MovieClip object in order to instantiate properly.




  93. Great post! Whole blog is very interesting when you are flash pasionate!




  94. thanks your sharing my dude




  95. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I will be subscribing to your feed and I hope you post again soon. Thanks!




  96. thank you

Leave a Reply

Captcha
Enter the letters you see above.