How to set Video Frame Capture Using Bitmap Data
Asked Answered
A

1

2

I'm implementing an Augmented Reality application for android using Flash. In order to get the application working on my Android Phone (nexus One) the Phone Camera must be activated as well. So I need 2 layers one for the background which is the feed of my phone camera and an other one on top of it which is the view from away3d in this case.

So setting up a BitmapData object to hold the information of the most recent webcam still-frame I can make this work.

If I use papervision3D library and FLARToolkit we setting up the BitmapData using the following part of the code found from this video tutorial:

//import libraries
 import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData;   
 import org.libspark.flartoolkit.detector.FLARSingleMarkerDetector;


 private function setupCamera():void
            {
                vid = new Video(640, 480);
                cam = Camera.getCamera();
                cam.setMode(320, 240, 10);
                vid.attachCamera(cam);
                addChild(vid);
            }   

            private function setupBitmap():void
            {
                bmd = new BitmapData(640, 480);
                bmd.draw(vid);
                raster = new FLARRgbRaster_BitmapData(bmd);
                detector = new FLARSingleMarkerDetector(fparams, mpattern, 80);
            }



private function loop(e:Event):void
            {
                if(detector.detectMarkerLite(raster, 80) && detector.getConfidence() > 0.5)
                {
                    vp.visible = true;
                    detector.getTransformMatrix(trans);
                    container.setTransformMatrix(trans);
                    bre.renderScene(scene, camera, vp);
                    }
                    else{
                    vp.visible = false}
                    }
            catch(e:Error){}}}}

However, to implement my application Im using Away3D engine and FLARManager and the way of doing that is very different as I can understand. I have implement the following code but the only think it does is just show the Flash Camera in the front of the 3D view and I can't check if my application is work or not since it doesn't show me any 3D Object when I place the marker in front of the screen.

My code is:

//Setting Up Away3DLite Camera3D
import com.transmote.flar.camera.FLARCamera_Away3DLite;

private var camera3D:FLARCamera_Away3DLite;

this.camera3D = new FLARCamera_Away3DLite(this.flarManager, new Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight));

  //Setting Up the bitmapData 
  private function bitmap():void
{
    c = Camera.getCamera();
    c.setMode(320,240,10)
    this.v.attachCamera(c);
    addChild(this.v);         
    bmd = new BitmapData(640,480); 
    bmd.draw(this.v);
   }

Can you please help me to find out how can I combine those two?

I will really appreciate any advice i can get from you.

Thank you

Ambulator answered 12/3, 2011 at 23:56 Comment(0)
M
1

To isolate your problem, I'd try to break these two things up and make sure each part works first. It's sounds like you've got the camera part working, try doing just some 3D (no AR) draw a cube or something. Then try implementing the AR but have it do something simple like trace something out or making an object visible or invisible. Then start combining them.

Mimicry answered 13/3, 2011 at 13:25 Comment(4)
Thank you for you reply. The problem is T can't get the bitmapdata working correctly even if i use only some 3D cube. Is it any online resources available that you think it will help me to fix this problem? This seems very complicated to me since I'm new on away3D engine.Ambulator
Lee Brimelow has some excellent tutorials on that site. He actually did one using FLARManager too.Mimicry
FLARManager doesn't need you to explicitly call the camera class, that's just in FLARToolkit. link That may help.Mimicry
Thank again for your interest. The problem is that Lee's project using FLARManager has lots of errors and it's not working. Furthermore, as I realised in order to get the camera of the Android phone activated and work I need to use bitmapData and I did not manage to get it working using FLARManager. On the other hand, I manage to get it working with FLARToolkit and Papervision3D but the application it very slow and crashes. So the best combination for my application it will be Away3DLite FLARManager with the use of BitmapData but still trying to find out how can I mix all these.Ambulator

© 2022 - 2024 — McMap. All rights reserved.