Domanda

Ho scritto abbastanza codice per visualizzare l'anteprima del video webcam in flash.

Ora, voglio catturare le immagini a intervalli di 10 secondi.

Ecco il mio codice:

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);
}
.

Qualsiasi aiuto per favore?

Sono un flash totale newbie.

Grazie, Rishi.

È stato utile?

Soluzione

Se si desidera salvarlo sul disco dell'utente, tenere presente che non è possibile farlo automaticamente come, per motivi di sicurezza, il metodo Salva () della classe FileReFerence può essere utilizzato solo dopo specifiche azioni utente (clicca,Mousedown e immagino le tasti-presse).Dopo aver avuto il tuo bitmapdata avrete bisogno del codificatore JPEG da http://code.google.com/P / AS3Corelibib / per codificare il tuo IMG e salvarlo sul disco.Qualcosa del genere:

    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);
.

Dai un'occhiata al documento FileReference Doc qui http://help.adobe.com/en_us/as3lcr/flash_10.0/flash/net/filereference.html Quindi vedi cos'altro puoi fare con esso.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top