Flash의 웹캠에서 캡처 한 스틸 이미지를 저장하십시오
문제
Flash에서 웹캠 비디오를 미리 볼 수있는 충분한 코드를 작성했습니다.
이제 10 초 간격으로 이미지를 캡처하고 싶습니다.
여기 코드가 있습니다 :
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);
}
.
도움을 받으십시오.
전체 플래시 초보자입니다.
고마워, rishi.
해결책
사용자의 디스크에 저장하려면 보안상의 이유로 자동으로 수행 할 수 없음을 유의하십시오. FileReference 클래스의 save () 메소드는 특정 사용자 작업 후에 만 사용할 수 있습니다 (클릭,MouseDown과 나는 핵심 압박을 추측한다).bitmapdata가있는 후에는 http://code.google.com/ko.nofollow noreferrer"> jpeg 인코더가 필요합니다.P / AS3Corelib / img를 인코딩하고 디스크에 저장하십시오.이와 같은 것 :
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);
.
여기를 참조하십시오 http://help.adobe.com/en_us/as3lcr/flash_10.0/fash/net/filereference.html 그래서 당신이 할 수있는 다른 것을 볼 수 있습니다.
제휴하지 않습니다 StackOverflow