FLARManager v0.61 (augmented reality in Flash)
ericsoco | 2009/11/07 | 3:03 pmv0.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.




Hi Eric, Thanks for sharing this great toolkit with us! I'm
Max | 2009/11/22 | 7:50 amHi 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
@max -- not a stupid question at all. FLARManagerProfiler
ericsoco | 2009/11/22 | 1:34 pm@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,
Killer stuff, this is working like a dream now...
axiom | 2009/11/25 | 5:18 amKiller 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.
Thank you very much for this. I had some initial
Asi Epshtain | 2009/12/16 | 6:14 amThank 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.
Hi, Sorry for my stupidity, but after I've upgraded to .61
Therion | 2009/12/18 | 8:27 amHi,
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!
@therion -- not sure what the problem could be.
ericsoco | 2009/12/18 | 2:59 pm@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.
@ericsoco - Hi, sorry for the late reply. No I
Therion | 2009/12/20 | 7:40 pm@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?
@therion -- i just tried that myself, and it works
ericsoco | 2009/12/20 | 9:03 pm@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?
@ericsoco - Yeah it is. This is really weird man...
Therion | 2009/12/20 | 9:08 pm@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!
Hey, Eric, great stuff! Finally got tired of trying
Michael | 2010/01/06 | 10:49 amHey, 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?
@michael -- what kind of camera are you using, and
ericsoco | 2010/01/06 | 12:31 pm@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.
Wow, that was easy. =P Went ahead and doubled it to
Michael | 2010/01/06 | 12:41 pmWow, 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!
Hi Eric, Great work! I have used the FlarToolkit before with
Joe | 2010/01/07 | 9:18 amHi 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
OK, downloaded the zip and ran examples fine using the
Joe | 2010/01/07 | 10:55 amOK, 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.
@Asi Epshtain - thanks for that pointer about the CS4
Adrian | 2010/01/14 | 7:47 pm@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?
Check that, I found the line in the config xml
Adrian | 2010/01/14 | 7:50 pmCheck that, I found the line in the config xml regarding FLARLoaderSource…
FLARCameraSource.CAMERA_VALIDATION_TIME where shld i update this value to 6??? for me
abby | 2010/01/17 | 10:48 amFLARCameraSource.CAMERA_VALIDATION_TIME
where shld i update this value to 6???
for me also dat error 2044 came….
Hi Eric! How do I for setup the place of
Daniel Delgado | 2010/01/22 | 9:05 pmHi 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
@daniel -- the webcam input is displayed inside of the
ericsoco | 2010/01/23 | 4:34 pm@daniel — the webcam input is displayed inside of the FLARCameraSource instance created by FLARManager. you can access it via flarManager.flarSource.
Hi Eric, It says "Secondary camera validation failed". I tried to
Noel | 2010/02/07 | 2:02 pmHi 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?
My problem with the "Secondary camera validation failed" has been
Noel | 2010/02/07 | 2:17 pmMy 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.
Hey Eric, running into another weird error: I have a gallery
Michael | 2010/03/23 | 3:09 pmHey 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?
@michael -- correctly disposing of a FLARManager/FLARToolkit application came up
ericsoco | 2010/03/28 | 10:23 am@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.
Hello, i am looking for a solution to check if the
Kristin | 2010/04/09 | 12:42 pmHello,
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?
@kristin, try: var flarManager:FLARManager = new FLARManager("flarConfig.xml"); flarManager.flarCameraSource.addEventListener(ErrorEvent.ERROR, this.onCameraError); private function onCameraError (evt:ErrorEvent)
ericsoco | 2010/04/09 | 12:58 pm@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
}
@ericsoco: thanks for your quick answer. but it does not
Kristin | 2010/04/09 | 1:17 pm@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?
@kristin -- whoops. forgot i rerouted that ErrorEvent to
ericsoco | 2010/04/09 | 1:32 pm@kristin — whoops. forgot i rerouted that ErrorEvent to go thru the FLARManager instance. so, just write:
flarManager.addEventListener(ErrorEvent.ERROR, onCameraError);
@ericsoco: hello again, this was my first idea too, but it does
Kristin | 2010/04/09 | 1:54 pm@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?
@kristin -- i just tested it, and it does work.
ericsoco | 2010/04/09 | 1:59 pm@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.
@ericsoco: i don't know, why it don't function on my pc.
Kristin | 2010/04/09 | 2:28 pm@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.
@daniel — the webcam input is displayed inside of the
Daniel Delgado | 2010/04/09 | 2:38 pm@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?
hello, i solved my problem about the error-message, when no camera
Kristin | 2010/04/20 | 1:30 amhello,
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
Display a DisplayObject3D without Marker! Hey ericsoco, have you an idea,
Ömer | 2010/05/20 | 2:38 pmDisplay 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!!
@omer -- hm...you could hold a marker up in front
ericsoco | 2010/05/20 | 7:27 pm@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?
Hey thank you so much, it wroks perfectly! Is there anywhere
Ömer | 2010/05/21 | 1:09 amHey 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
@omer -- you don't really need to know how an
ericsoco | 2010/05/21 | 11:57 am@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.