default camera

44 views
Skip to first unread message

CR L

unread,
Oct 17, 2009, 12:19:17 PM10/17/09
to flartool...@googlegroups.com
I'm working on the "gotoAndLearn" project "Augmented Reality with FLARManager " using Flash Builder 4 Beta
I'm at the first step where you check if the camera is working.

When I run HelloFLAR I get a clear panel but the "Console" says:
[FLARManager] Initing camera 'DeskShare IP Camera Source'.

I need to use the "QuickCam Orbit/Sphere AF" camera instead of the "DeskShare IP Camera".

How do I make FLARManager to pick the right camera?

I right clicked on the flash panel and pick the right camera and see myself in the tiny video but it doesn't change anything.

Plase advice.
Thanks.
-cl
PS: I successfully worked on
"Introduction to Augmented Reality" and "Papervision3D Collada Basics" projects
and made my own 3D project using Flash Builder 3, Papervison3d and Blender.

eric socolofsky

unread,
Oct 17, 2009, 1:58:11 PM10/17/09
to flartool...@googlegroups.com
this has been a sticky issue since the first version of FLARManager.
flash is apparently not very good at selecting the correct camera, so
FLARCameraSource has code that picks the first camera, waits 2
seconds, checks it for activity, and if no activity is found, it moves
on to the next camera. it repeats this until it has found a camera
that reports activity.

the problem is that Camera.names reports a list of all camera
*drivers* on the system. none of these drivers necessarily have a
camera attached. generally the code described above will work
correctly, but apparently some drivers report activity even when they
have none. this is very difficult to debug, as i only have so many
environments (platforms + cameras) to test on.

in the meantime, you can manually select a camera by its index, via
FLARCameraSource.cameraIndex.
the code to do so is:

var flarManager:FLARManager = new FLARManager("flarConfig.txt");
FLARCameraSource(flarManager.flarSource).cameraIndex = n;

where n is the index of the camera you want to use. you can find the
index of the camera you want to use by tracing out Camera.names to the
console, or you can just guess until you get it right; most likely you
only have a few cameras in the system.

hth,
-eric

CLRL

unread,
Oct 18, 2009, 11:20:28 AM10/18/09
to FLARToolKit userz
Thank you.
I also added: "import com.transmote.flar.source.FLARCameraSource;"

I tried 1, 2, 3, 4 although I think that 2 should work.
Still the camera is not started.

I get this error after "run":
Error: Error #2032: Stream Error. URL:
file:///C|/Documents%20and%20Settings/Carlos/Adobe%20Flash%20Builder%20Beta%202/HelloFLAR/bin%2Ddebug/flarConfig.txt
at com.transmote.flar::FLARManager/onFlarConfigLoadError()[C:
\Documents and Settings\Carlos\My Documents\FlashActionScriptSVN
\FLARManagerZip\FLARManager_v06\src\com\transmote\flar\FLARManager.as:
824]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

Even if this works it will make it hard to publish since we don't know
which camera others will use in their system.
-cl
> > I need to use the "QuickCamOrbit/Sphere AF" camera instead of the  

eric socolofsky

unread,
Oct 18, 2009, 1:29:00 PM10/18/09
to flartool...@googlegroups.com
this error is telling you that you specified an incorrect path to flarConfig.txt.  the code i wrote in the previous message was only an example, you should modify it to fit your environment.

if you like, you can disable FLARManager's camera handling and just use flash's built-in camera selection by replacing this code, in FLARCameraSource.initCamera:

// set up Camera to capture source video
if (this.manualCameraIndex >= 0) {
// use camera index specified via cameraIndex accessor (setter)
this.camera = Camera.getCamera(this.manualCameraIndex.toString());
} else {
// attempt to init cameras one-by-one until an active camera is selected,
// or all options are exhausted.
if (!this.attemptedCameras || this.attemptedCameras.length != Camera.names.length) {
this.attemptedCameras = new Vector.<Boolean>(Camera.names.length, true);
}


for (var i:int=0; i<this.attemptedCameras.length; i++) {
if (!this.attemptedCameras[i]) {
this.attemptedCameras[i] = true;
this.camera = Camera.getCamera(i.toString());
}
}
}

with:

this.camera = Camera.getCamera();

i can't guarantee even that will work, however.  the reason i implemented the more advanced camera handling in the first place was an effort to get around the fact that flash player does not always automatically select the correct camera.

-eric

eric socolofsky

unread,
Oct 18, 2009, 1:44:25 PM10/18/09
to FLARToolKit userz
ok, i just commited to SVN a way to make this change simply.

if you check out the latest, you can now set FLARManager to use flash
player's default method of choosing a camera. i also added a hook to
get at the camera source more directly, to avoid the weird casting you
had to do previously.

so now, try this:
var flarManager:FLARManager = new FLARManager("your/flarConfig/path/
here");
flarManager.flarCameraSource.useDefaultCamera = true;

please let me know if that works.
-eric

CLRL

unread,
Oct 20, 2009, 2:07:39 PM10/20/09
to FLARToolKit userz
I downloaded Rev. 127 with SVN.
I tried your suggestion but I can't get around the error I get.
I'm sure I'm missing something obvious... sorry-
--------------------------------------------------------------------------------
03 - import com.transmote.flar.FLARManager;
04 - import com.transmote.flar.source.FLARCameraSource;

43 - private function initFLAR():void
44 - {
45 - fm = new FLARManager("/HelloFLAR/src/flarConfig.xml");
46 - var flarManager:FLARManager = new FLARManager("/HelloFLAR/src/
flarConfig.xml");
(X) 47 - flarManager.flarCameraSource.useDefaultCamera = true;
48 - addChild(Sprite(fm.flarSource));
49 - }

Problems:
(X) Error(1 item)
(X) 1119: Access of possibly undefined property Manager through a
reference with static type com.transmote.flar:FLARManager.
Resource: HelloFLAR.as
Path: HelloFLAR/src
Location: line 47
Type: Flex Problem
--------------------------------------------------------------------------------
-cl

eric socolofsky

unread,
Oct 20, 2009, 2:19:30 PM10/20/09
to flartool...@googlegroups.com
that looks like a syntax error in your code, no? what's 'Manager'?
also, why are you instantiating FLARManager twice?

CLRL

unread,
Oct 20, 2009, 7:59:16 PM10/20/09
to FLARToolKit userz
EUREKA! - It works now after i adjusted the paths and with this code:
-----------------------------------------------------------------------------------------------
package {
import com.transmote.flar.FLARManager;

import flash.display.Sprite;
import flash.events.Event;

[SWF(width='640', height='480', backgroundColor='#000000',
frameRate='40')]

public class HelloFLAR extends Sprite {
private var fm:FLARManager;

public function HelloFLAR() {
initFLAR();
}

private function initFLAR():void
{
fm = new FLARManager("flarConfig.xml");
fm.flarCameraSource.useDefaultCamera = true;

addChild(Sprite(fm.flarSource));
}
}
-----------------------------------------------------------------------------------------------
Now I can continue with the gotoAndLearn "Augmented Reality with
FLARManager"
My first success with FLEX 4...
Thanks a lot!
-cl
Reply all
Reply to author
Forward
0 new messages