How to set Video Frame Capture Using Bitmap Data

六眼飞鱼酱① 提交于 2019-12-24 03:11:09

问题


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


回答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.



来源:https://stackoverflow.com/questions/5286449/how-to-set-video-frame-capture-using-bitmap-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!