FLARManager v0.61 (augmented reality in Flash)

v0.5 introduced some issues with automatic camera selection (in FLARCameraSource) that went fairly unnoticed until v0.6. this primarily affected users with USB cameras on Windows, as well as a couple of other edge cases.

v0.61 corrects those issues, thanks to some help from jim alliban. download it here:
http://words.transmote.com/wp/flarmanager/


 

what is this?

FLARManager is a lightweight framework that makes it easier to build FLARToolkit augmented reality applications for Flash. it is compatible with a variety of 3D engines, and provides a more robust event-based system for managing marker addition, update, and removal. it supports detection and management of multiple patterns, and multiple markers of a given pattern.

42 Comments

  1. Max says:

    Hi Eric,

    Thanks for sharing this great toolkit with us! I’m diving into (Flash based) AR right now and I’m trying to get things up and running. Your toolkit is definitely one of the tools that I’ll keep in my toolbox!

    Anyway, I was just wondering what the file FLARManagerProfiler.as is all about. Apparently FLARManager can be used without it (I just tried removing it and recompiled my app). Can you give me some hints?

    BTW If this is a really stupid question, then please excuse me, although I have some coding skills, I’m quite new to the flash/flex/as3 environment.

    Thanks again, cheers,
    Max

  2. ericsoco says:

    @max — not a stupid question at all. FLARManagerProfiler is an application class that i use to run the flex builder profiler on FLARManager, to ensure there are no memory leaks. i considered svn:ignoring it so it wouldn’t end up in the repo, as it’s really just for my use, but figured i’d leave it anyway in case other devs want to profile their apps. sorry for the confusion,

  3. axiom says:

    Killer stuff, this is working like a dream now… I’ve had my share of stumbles along the way but your FLARManager has made this possible for me in a relatively short period of time. It took me longer to figure out how to beat Flex into submission. :)

    Someday when my coding is better I hope I can help contribute to this project.

  4. Asi Epshtain says:

    Thank you very much for this. I had some initial problems with compiling this in flash CS4 and found the problem is due to CS4 bug with singleton class that also have interfaces. ( caused by FLARLabeling_BitmapData )

    The solution can be found here:
    http://blog.webdeely.com/2009/02/cs4-doesnt-like-the-combo-of-internal-classes-and-interfaces-in-as3/

    Works great now, and I’m off to my experiments.

  5. Therion says:

    Hi,

    Sorry for my stupidity, but after I’ve upgraded to .61 any of my markers are not being detected anymore, even the ones in the sample. I wonder what could be wrong?

    Thanks for all the great work!

  6. ericsoco says:

    @therion — not sure what the problem could be. have you tried creating a completely new project, and importing FM0.61 into it, and testing that? it should work without trouble.

  7. Therion says:

    @ericsoco – Hi, sorry for the late reply. No I haven’t yet. But I did try compiling the sample I got from the svn and it didn’t work as well. Could there have been any changes to FlarToolkit’s marker detection?

  8. ericsoco says:

    @therion — i just tried that myself, and it works fine. re: FLARToolkit changes, that’s irrelevant, because i bundle FLARToolkit with FLARManager, so if there were any changes you would have those.

    is your flarConfig.xml pointing at the correct pattern files?

  9. Therion says:

    @ericsoco – Yeah it is. This is really weird man… Anyways I’ll try it again and tell you if anything comes up.

    Thanks for the help! :)

  10. Michael says:

    Hey, Eric, great stuff! Finally got tired of trying to figure out why my project (seemingly randomly) is unable to detect my camera, and came across the posts here and on the v06 page. I updated to the current version in SVN, also updated the toolkit, but I still seem to be having the same problem. =/

    I did 5 compiles while writing this post. Not changing any code, just re-publishing over and over. ;)
    2 out of the 5 publishes, I get: Error #2044: Unhandled error:. text=Camera not found. Please check your connections and ensure that your camera is not in use by another application.

    But even on a successful compile, if I run the .swf outside of flash, I will get a debug error pop-up dialogue that says the same thing… so I guess it doesn’t really matter if it compiles correctly or not…

    Any ideas? :)

  11. ericsoco says:

    @michael — what kind of camera are you using, and what’s your hardware/OS setup? i set the timeout for camera activation to 3 seconds (FLARCameraSource.CAMERA_VALIDATION_TIME) — try increasing that value. it’s a bit of a crapshoot trying to get camera detection to work for all cameras on all platforms without making the user wait forever for the app to init, so i tried to keep that value as low as reasonably possible. apparently it’s too low for your setup.

  12. Michael says:

    Wow, that was easy. =P
    Went ahead and doubled it to 6 and so far, no problems at all.

    I’m on Windows XP SP3, with a Microsoft LifeCam VX-6000 (USB).
    It was also doing it for the built-in webcam on a Macbook Pro. I’ll have him test it out a few times, too, to see if he gets the error anymore.

    Thanks for the quick reply, greatly appreciate it! And great work on the Manager!

  13. Joe says:

    Hi Eric,

    Great work! I have used the FlarToolkit before with success and I am trying to use FLARManager but I am running into a problem. I am using .61 from the repository as well as FLARToolkit from their repository. ( I have also tried .6)

    I am editing with FlashDevelop and compiling with CS4. I am running Windows XP on a MacBook Pro.

    My issue is with marker detection. The confidence level being returned in never greater than .000*. Everything else works fine, no errors. If I set the confidence level to 0.0 in the flarConfig.xml or if I comment out the code in FLARManager.as where it checks the confidence, I get flickering markers popping up all over the place.

    Any ideas?

    Thanks,

    -Joe

  14. Joe says:

    OK, downloaded the zip and ran examples fine using the FLARToolkit and FLARManager in the zip, still not working with my updated files from the FLARToolkit and FLARManger repositories. I guess I am good for now to test.

  15. Adrian says:

    @Asi Epshtain – thanks for that pointer about the CS4 compiler Bug. I was about to throw the whole damn thing out the window. I fixed mine (also in FLARLabeling_BitmapData) with a new class called BugFix:
    package org.libspark.flartoolkit.core.labeling {
    //fix for CS4 compile bug...

    public interface BugFix{ }
    }

    then change the line in FLARLabeling_BitmapData to:
    public class FLARLabeling_BitmapData implements IFLARLabeling, BugFix {

    However, now I have a new issue where I think its complaining that I don’t have a camera hooked up? The error is:
    TypeError: Error #1009:Cannot access a property or method of a null object reference.
    at com.transmote.flar.source::FLARCameraSource/initCamera()
    ...
    ...

    If this is what’s causing the error, is there a way to use an image instead or a live video?

  16. Adrian says:

    Check that, I found the line in the config xml regarding FLARLoaderSource

  17. abby says:

    FLARCameraSource.CAMERA_VALIDATION_TIME

    where shld i update this value to 6???

    for me also dat error 2044 came….

  18. Daniel Delgado says:

    Hi Eric!

    How do I for setup the place of webcam video input? I mean, I want to do some kind of flash interface, with buttons and other stuff. But I need to move the webcam video input to other place than the right top corner. How do I that?

    Waiting for some help here,

    thanks in advanced

    Daniel

  19. ericsoco says:

    @daniel — the webcam input is displayed inside of the FLARCameraSource instance created by FLARManager. you can access it via flarManager.flarSource.

  20. Noel says:

    Hi Eric,

    It says “Secondary camera validation failed”. I tried to increase CAMERA_VALIDATION_TIME to 6 seconds or even to 30 seconds but it keeps failing. The LED on the cam turns on after the first validation and stays on until I’ll close the flash player. My cam is a Logitech QuickCam Fusion, Windows XP SP3, Logitech drivers. The cam works, as I was able to create a marker using this cam and the app on tarotaro.org.

    Any other suggestions how to fix this? Is this perhaps an OS/driver problem?

  21. Noel says:

    My problem with the “Secondary camera validation failed” has been fixed. It had nothing to do with timeouts, driver, or as Flash reported the cam is busy by another application.

    The reason was a mistake in the flarConfig.xml file, my mistake. cameraParamsFile was set to the wrong path. Doh! As it seems, if it cannot find FLARCameraParams.dat file then the second camera validation fails. Don’t ask me why.

  22. Michael says:

    Hey Eric, running into another weird error:

    I have a gallery of various AR experiments that are loaded externally as .swfs. Separately, they all run fine. If loaded via the gallery, however, only the first one will run. Then, when I kill it (removed from display list, reference is nulled, camera is disposed, all successfully), any subsequent calls to load either the same AR or a different one results in:

    TypeError: Error #1034: Type Coercion failed: cannot convert com.transmote.flar.pattern::FLARPattern@3537b389 to com.transmote.flar.pattern.FLARPattern.
    at Vector$object/http://adobe.com/AS3/2006/builtin::push()
    at com.transmote.flar::FLARManager/parseFlarConfigFile()
    at com.transmote.flar::FLARManager/onFlarConfigLoaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    Which seems weird, because its coercion from FLARPattern to FLARPattern. Any ideas?

  23. ericsoco says:

    @michael — correctly disposing of a FLARManager/FLARToolkit application came up on the FLARToolkit forums a little while back. can’t remember if we ever figured that one out; i’m pretty positive that all FLARManager-related classes are disposed of properly when calling FLARManager.dispose, so if there are FLARPattern instances still hanging around in memory there is probably a FLARMarker instance somewhere still in memory, possibly in your application code…just a thought.

  24. Kristin says:

    Hello,
    i am looking for a solution to check if the webcam is attached. and if the webcam is not attached to display an error message at the screen an not so a cryptical message from the system.

    any ideas?

  25. ericsoco says:

    @kristin, try:
    var flarManager:FLARManager = new FLARManager(“flarConfig.xml”);
    flarManager.flarCameraSource.addEventListener(ErrorEvent.ERROR, this.onCameraError);

    private function onCameraError (evt:ErrorEvent) :void {
    // handle camera error here
    }

  26. Kristin says:

    @ericsoco: thanks for your quick answer. but it does not work. when the webcam is not attach i get the TypeError: Error #1009: cannot access a property or method of a null object reference at src\com\transmote\flar\source\FLARCameraSource.as:345

    my code:

    flarManager = new FLARManager("assets/config/flarConfig.xml");
    flarManager.flarCameraSource.addEventListener(ErrorEvent.ERROR, onCameraError);
    addChild(FLARCameraSource(flarManager.flarSource));

    private function onCameraError (event:ErrorEvent):void
    {
    trace("___________ Webcam is not attach!");
    }

    any other idea?

  27. ericsoco says:

    @kristin — whoops. forgot i rerouted that ErrorEvent to go thru the FLARManager instance. so, just write:

    flarManager.addEventListener(ErrorEvent.ERROR, onCameraError);

  28. Kristin says:

    @ericsoco:

    hello again,
    this was my first idea too, but it does not function. i’ve got also the typeError #1009 when the camera is not attached. The methode initCamera() in the class FLARCameraSource fire this error.

    Do you have an another idea?

  29. ericsoco says:

    @kristin — i just tested it, and it does work. the ErrorEvent dispatched from within FLARCameraSource.initCamera gets handled by FLARManager.onCameraSourceError(), which re-dispatches the event from the FLARManager instance.

    make sure you have a persistent reference (e.g. as a member variable) to your FLARManager instance, and that you are not using true for the weakReference param to addEventListener.

  30. Kristin says:

    @ericsoco:
    i don’t know, why it don’t function on my pc. now i tried one of your examples you launched with your sourcecode. and there is the line of code too. but when i run this example without attached webcam, i’ve got the #1009 error. i updated your sourcecode, but i have the actual version and i restart my computer.

    it is very strange…

    if you or another has any idea, i will be very thankful.

  31. Daniel Delgado says:

    @daniel — the webcam input is displayed inside of the FLARCameraSource instance created by FLARManager. you can access it via flarManager.flarSource.

    Hello Eric, I don’t see your answer before… thanks :)

    Now I’m not sure what variables can I use for this?
    I think this variables in FLARManager.as can work but no…

    var sourceSize:Rectangle = this.flarSource.sourceSize;
    this._cameraParams.changeScreenSize(sourceSize.width, sourceSize.height);

    I guess i need to move in my stage the camera video input (640×480) and the camera video source for analysis (320×240)

    How can I move all, video input and video analysis (hide to user, show with thresholdSourceDisplay=true;) at the same ratio?

  32. Kristin says:

    hello,
    i solved my problem about the error-message, when no camera is attached.

    i find a bug in your code:
    in your FLARCameraSource.as initCamera-methode:


    if (!this.attemptedCameras || this.attemptedCameras.length != Camera.names.length) {
    // if no cameras attempted yet, start with default camera
    this.attemptedCameras = new Vector.(Camera.names.length, true);
    this.camera = Camera.getCamera();
    // the if is added, because, when there is no camera attached, this.camera == null
    if (this.camera) {
    this.attemptedCameras[this.camera.index] = true;
    }
    }

    with this one added “if” my error-message will displayed.

    kristin

  33. Ömer says:

    Display a DisplayObject3D without Marker!

    Hey ericsoco, have you an idea, how i can achieve that.

    I hope you understand wat i’m trying to do. When the camera starts up, there should be immediately the Image or anything i want to be displayed.

    I hope anyone here can help me, i’m working on that for so long now!

    I think my problem is that i dont realy understand the FlarCamer3D, how can DisplayObjetc3D translated in such a Camera?

    Is there anywhere an example of something like that? A link, source code? Anything would help, thank you!!

  34. ericsoco says:

    @omer — hm…you could hold a marker up in front of the camera while recording the values of the transform Matrix (FLARMarker.transformMatrix), then manually create a Matrix with those values and apply it to your 3d object on app init. that should work, no?

  35. Ömer says:

    Hey thank you so much, it wroks perfectly!

    Is there anywhere an explanation for, how the Parameters of a NyARDoubleMatrix34 work?

    It is realy difficult for me, to understand which parameter causes which translation / transformation!

    What i’m going to do is, to display a 3D Object immediately after app init (works now, with your help, thank you) but then when the Marker is visible, i want only the 2D Rotation to take effect an moy 3D Object?

    For somthing like that, i’m sure, some of the NyARDoubleMatrix34 must be null, the others must be the ones from the marker?

    Have you ever done anything like this? It must be a 3D Object, no change with 2D!
    Thank you so much for your realy fast and helpfull answer.
    Ömer

  36. ericsoco says:

    @omer — you don’t really need to know how an NYARDoubleMatrix34 works, just copy the values in the correct order. however, if you want to know, take a look at the conversion methods in FLARGeomUtils.

  37. J says:

    Am getting the following error when trying to compile using Flash CS5:
    U:\Work\Flash\Class'\com\transmote\flar\utils\geom\FLARToolkitGeomUtils.as, Line 103 1046: Type was not found or was not a compile-time constant: NyARDoubleMatrix34.

  38. Tom Peeters says:

    Trying to implement flarmanager v.06 in flash CS4. Everything works:the webcam detects the marker, but my webcam doesn’t show on the movie.. Any idea?

  39. ericsoco says:

    @tom — first question, why are you using such an old version?

  40. Tom Peeters says:

    @ericsoco: 1.compiling my project with the latest version returning me all kind of errors. (with v.06 it works immediately..). Do I have to do something in the .fla file..?

  41. ericsoco says:

    @tom — “all kind of errors” is not helpful in determining your problem.
    if you still need help, please post more detail on the FLARManager forums.

  42. dbahsee says:

    Id like to know if there are any instructoins for this for windows users, and adobe. because I cannot follow your instructions and im deperatley trying to lern about ar tags, you are my first attempt at this any assistance or information to helo me better grasp this it would be greatly appreciated

Leave a Reply

Additional comments powered by BackType