Code

The readme.txt file in the download ZIP (linked to at the left) provides full instructions on installing and using the code.  Example document classes are provided.  Below is the operative code from the samples so that you get the idea.

Assuming that you import the ostrich package as detailed in the ZIP file.

private var myCamera:OstrichCamera;
private var myCursor:OstrichCursor;

public function SampleCursor() {            

 // make an OstrichCamera object and call init function when ready          
 myCamera = new OstrichCamera();    
 addChild(myCamera);
 myCamera.addEventListener(OstrichCamera.READY, init);       

}

private function init(e:Event) {
 
 // make an OstrichCursor object (more parameters available)
 myCursor = new OstrichCursor(myCamera); 
 addChild(myCursor);     // a cursor will now follow cam motion!       

}

28 Responses

  1. [...] available in the video link above that show Ostrich in use and discus the ActionScript code.  The code section provides a quick look at the code which is something like [...]

  2. 1046: Type was not found or was not a compile-time constant: OstrichCamera.

    this error comes…

    I guess the OstrichCamera Class is not Defined.. in the .as files.

    • This usually happens if the classes are not in the class path. I usually make a classes folder somewhere – say c:/classes/ and then add that to the class path. This is the only folder I put in the class path.

      Then add com/danzen/interfaces/ostrich/ and its files to the classes folder. So in other words – you have a com folder now in classes. Then you have a danzen folder in com, etc.

      If you need help adding a folder to the class path then see the readme file that comes with the zip.

  3. [...] given the Ostrich code in the beginning, I carefully analyzed and decided to edit the Ostrich Button document. I liked the [...]

  4. [...] given the Ostrich code in the beginning, I carefully analyzed and decided to edit the Ostrich Button document. I liked the [...]

  5. hellou, i’ve peeked through your examples, and was wondering is there any way to use your constructor OstrichButton without having on stage the square of the cursor or the sprite covering it.

    Thanks

    • Sorry for the delay Cafrea – for some reason, I thought I was getting e-mail notification of new comments but I was not.

      You can make it so there is no cursor square by just commenting out the addChild(myCursor). Same with the button do not addChild it.

      You may want to look into making a cursor for each area that you want a button and use the MotionStart event to capture movement on that area. I do that quite a lot as it responds faster.

  6. Hola amigos estoy explorando esto de ostrich y es muy chido pero tengo un problema como hago para poner un objeto de papervicion en la camara esque me lo pone detras y solo se ve en la escena peno no en la camara pleaseeeee help

    • I am not sure how things will act with PaperVision. The OstrichCamera class extends a Sprite so it should work like any sprite. I think I had some issues when I moved or animated the OstrichCamera object so I suspect the classes are not set up for motion. It probably has to do with drawing to bitmaps and translations and stuff.

  7. Hi! first, thank you very much for Ostrich! (and I’m sorry by my poor english)

    I’m testing some uses for camera tracking, and I have a question: How can I change the camera’s resolution? If I set the camera:

    myCamera = new OstrichCamera(0,0,800,600);

    then it only scale the video, but the quality is so poor, very pixelated, something like a video of 160×120 px scaled to 800×600 px

    I searched in “OstrichCamera.as” something like “cam.setMode(…)” but i can’t find it. I think you set the resolution with this lines:

    cam.width=theR-theL;
    cam.height=theB-theT;

    I’m lost :)

    I used my webcam in another aplications at 960×720 px or 640×480 px without problems..

    Can you help me?
    Thank you very much..

    ________________
    mad inventor
    meets internet
    finds peace :)

  8. I am having a horrible time trying to get these samples to even work on my computer. I can access a webcam in flash, but i cannot open up any of the ostrich camera or mouse….. What am I doing wrong… PLEASE HELP

    I just want to learn more about how these works

    • Well… some things to check:

      1. You are using CS3, CS4 or CS5 – the class is AS3 based
      2. You have put the com.danzen.interfaces.ostrich folder in your class path (there are instructions in the zip)
      3. Where did you get to? Are you getting an error, does the accept camera message come up, etc.
      4. What platform (Mac, Win, Unix) and what browser and version?

      Let me know…

      • I have cs4 and cs5 both as3

        i have made a folder named classes… went to the reame.file in the zip.. i upload the classes file through the edit button. I put the com folder then in the classes folder.

        When i try to open the sample cursor it says access denied…

        I open the fairy file and past in the code in as from the code in fairy but when i open it up… I just get the picture and a glowing fairy.

        i figured if I can open up the samples i will be able to open the files in other files I make.i am a beginner, but a very faster learner…. I how this might help.. Please help I have a project I wanted to use this on…

  9. Make sure you unzip the files.

    Also, you need to add that classes folder to your class path in Flash. So open the FLA and follow the instructions in the readme about setting your class path. This tells Flash where to automatically look for extra code – like Ostrich.

    Oh… there is no reason to paste in any code. There is a connection in the FLA file in the properties panel when you click on the stage. The connection tells flash where to look for the code something like: samples.Fairy. Then the code in the Fairy.as file will run. And if you set up your class path correctly, the import command at the top of Fairy.as will call the code from the Ostrich classes.

    So it should just work without you doing anything but making sure the com folder is placed in a folder that is in your class path (classes for example once you set it).

    • I’m sorry I hate to keep taking up your time…. this is what i have so far fresh start… download the the zip file… unzip the file… i created a folder called classes on the desktop… add the folder by going to in flash(cs4_as3.0) edit_preferences_ actionscript_3.0settings_sourcepath_+c:\users\myname\desktop\classes….. from there i put the com folder…. when i open the fairy folder nothing happens…

      if there is some simple code is there anyway you can email me or talk with me.. I’m more than willing to donate…. I know your helping I’m just not getting it…

      Thanks

      • The first part sounds good. When you added the com folder I assume that the danzen / interfaces / ostrich folders were also in there as well as the Ostrich files.

        There is no fairy folder though… there is a fairy.fla and that is what you need to run – to see that example and then go – but I assume you know that…

        The simplest code to try possible in AS3 is the sampleCursor.fla – just open it in Flash and ctrl enter and you should see the request to access the camera and then the camera with a little square that follows the motion.

        Also – just so I know, are you on Mac or PC?

        Don’t worry at all about asking questions ;-)

      • I am on a PC…. Well after I wrote that last post I was able to get all the samples to work, but the samplecursor…. when I try to open the file it say… unexpeccted file format and closes when i push “ok” because i have too…. Now my next step is trying to get them in some type I code I make…. I have tried but nothing happens… just wonering if you might have some helpful tips… Sorry I’m a noob

      • Hmm… I checked the download zip and sampleCursor works for me – perhaps try downloading and unzipping again.

        With respect to further coding… it would be difficult to help you, not knowing your background, etc. and there are time issues. Perhaps have a read of a document that I made a while back that tries to help new coders get an idea of what it is about.

        http://interactivemultimedia.wordpress.com/2008/07/07/if-all-the-world-did-flash-rather-than-sudoku-programming-the-environmentally-friendly-puzzle/

  10. Hi Dan , is there any way to make te cursor faster.
    thank you . ostrich rulez!!

    • Hi Arturo,

      You can make the cursor go faster by adjusting the responsiveness to 1 when you create your OstrichCursor. This will mean it tries to place the cursor every frame as opposed to 4 (the default) where it waits and averages over 4 frames. One drawback is that it might appear jumpy. If you are just needing quicker response in motioning over places then consider using a cursor for each of your places and using the MOTION_START event to capture when there is motion on the cursor. This is the most responsive way to handle a button like feature for instance.

      new OstrichCursor(theCam:OstrichCamera, theL:Number=0, theT:Number=0, theR:Number=0, theB:Number=0, theResponse:Number=4)

      for example: (the 0s will make it default to whatever your camera size is and the 1 is very responsive:

      new OstrichCursor(myCam, 0, 0, 0, 0, 1)

  11. Oh i see thanks .
    I’m using 6 sprites i think, i’ve to use 6 ostrich cursor each one with it’s own limmits (x and y).

  12. hi dan,
    i have a little problem , I have 6 sprites and 6 cursors (each one with it`s own area ), and when i use the aplication they move a lot so… i tried putting an initial position(x,y) before the addChild(cursor) and another position(x,y) in the over event(to make them move after the event), but it doesn’t work. is there any suggestions?.
    thank you very much.

    • Hi Arturo,

      Not quite sure what you mean by they move a lot. Are you saying they move when there is no motion? If there is motion in their area, then they should move.

      Also, you may find that it is easier to control your own clips rather than trying to control the OstrichCursors. Just do not addChild the OstrichCursors and then set your own cursors to the OstrichCursor x and y when you want to. If you try and set the x and y of the OstrichCursors, they will just be set by Ostrich.

      Not sure if this helps – but you are welcome to describe the issues again.

      • Sorry about my bad explanation, I know that my English is bad, the problem I have is that cursors activate the sprites like I want but they are a little jumpy and sometimes they activate the same sprites more than once. That’s why I’ve tried to reset the x and y after the over() event , and when I start the application all the cursors jump everywhere for a couple of seconds and some sprites are activated even if there’s no movement of the person who start the application.

        Here’s the Url of my finale college project. Well it’s the beginning, my sister lend me her server for my application so I can show you. With this I think you’ll see what my problem is.

        http://www.e-motivos.com/ostrich

        Thank you very much and sorry for so many questions Dan.

  13. Hmmm… the project looks pretty cool.

    I can’t make it work for some reason – yet my ostrich examples are working so I am not sure – are you sure it is working as posted? I do see the orange balls go to the various places but that’s it.

    Here are some suggestions:

    People usually need to see where they are on screen to make gestures work – so perhaps just keep a faded (alpha = .2) camera visible to them.

    If you set regions for your cursors that are right on the buttons, you will not need balls following your movement. Just use the MOTION_START and MOTION_STOP events to activate the buttons when there is motion on the button area.

    Hope this helps.

    Dan

  14. Thank you very much Dan , that was the solution , It Works !!!!.
    the solution was the MOTION_START and MOTION_STOP events instead of the over event.
    I don’t know why you couldn’t see yourself in the webcam , your right people need to see their bodies when they use the application.
    everything works fine but I found another problem, It works when I use my computer but it doesn’t work in my friends computers. hmmm the only different between them is that I have windows vista, they have Windows 7 and the last version of Chrome and Firefox. When they use the application all the buttons activate without movement.
    Well i hope it solve, i’m working on, if you have any suggestion i’ll appreciate it .
    Thank you very much Dan , I learn a lot working in this project an using ostrich !! you rock!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.