Pregunta

He escrito suficiente código para obtener una vista previa del video webcam en Flash.

Ahora, quiero capturar imágenes a intervalos de 10 segundos.

Aquí está mi código:

import flash.display.BitmapData
import flash.geom.Matrix
import com.adobe.images.JPGEncoder;
import flash.net.FileReference;

//get the default camera
//change your Default camera using the Flash Player Settings.
cam=Camera.get()
//this event is called whenever permission to access the local camera, is accepted or denied by the user
cam.onStatus=function(e)
{
    //if we are given permission
    if(e.code == "Camera.Unmuted")
    {
        //start the application
        initialize()
    }
    else
    {
        System.showSettings(3)
    }
}

var snapshot:BitmapData=new BitmapData(cam._width,cam._height);

function takeSnapshot()
{
    snapshot.draw(cam,new Matrix());
}


//if there are no Cameras
if(cam == null)
{
    System.showSettings(3)
}
else
{
    cam.setMode(1024, 768, 30);
    cam.setQuality(10000,0);
    output.attachVideo(cam);
    setInterval(this,"takeSnapshot",1000);
}

¿Alguna ayuda por favor?

Soy un Newbie flash total.

gracias, Rishi.

¿Fue útil?

Solución

Si desea guardarlo en el disco del usuario Tenga en cuenta que no puede hacerlo automáticamente como, por razones de seguridad, el método GUARDE () de la clase de filtreferencia solo se puede usar después de las acciones específicas del usuario (haga clic en,mousedown y supongo que las pulsaciones clave).Después de tener su bitmapdata, necesitará el codificador JPEG de http://code.google.com/P / AS3CORELIB / Para codificar su IMG y guárdelo en el disco.Algo así:

    var fileBrowser:FileReference = new FileReference();

    var bd:BitmapData = new BitmapData(imageContainer.width, imageContainer.height, false, 0xFFFFFF);

    bd.draw(imageContainer);

    var encoder:JPGEncoder = new JPGEncoder(35);

    var bytes:ByteArray = encoder.encode(bd);

    fileBrowser.save(bytes);

Eche un vistazo a la filería DOC aquí http://help.adobe.com/en_us/as3lcr/flash_10.0/flash/net/filereference.html Para que vea qué más puede hacer con él.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top