How to set Video Frame Capture Using Bitmap Data

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


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.

链接地址: http://www.djcxy.com/p/27902.html

上一篇: Android对象上的Away3DLite不会显示在屏幕上

下一篇: 如何使用位图数据设置视频帧捕获