After capturing a frame from a webcam, I’m saving this frame as an actual image-file.
Unfortunately, this doesn’t always work well.
See link:[COLOR=#0000ff]results[/COLOR]
I’m using the functions below.
Does anyone know what’s causing this? Can a different OS or browser cause a different outcome?
function setImgData(){
trace("making");
_root.w = 360, tmp
_root.h = 270;
_root.a = 0;
_root.tNum = 0;
_root.bNum = 0;
_root.pixels="";
_root.createEmptyMovieClip("imgMaker", this.getNextHighestDepth());
imgMaker.onEnterFrame = function(){
for(var b=0; b<_root.h; b++){
_root.tNum++ ;
tmp = _root.snap.getPixel32(_root.a, b).toString(16)
tmp =tmp.substr(1);
while(tmp.le ngth<6)
{
tmp = "0" + tmp;
}
_root.pixels +=tmp;
_root.bNum=b ;
}
perc = int((_root.a*10)/w);
_root.ssMc.s napShotLoader.text = _root.snapShotLoadText+" ["+perc+"0%]";
_root.ssMc.s napShotLoader.setTextFormat(style_fmtS SLoader);
_root. ssMc.snapShotLoader._x=_root.vidMc._x-_root.areaLeftIn dent+180-(_root.ssMc.snapShotLoader._width/2);
_root.a++
if(_root.a&g t;w-1){ //Finish capturing
//trace(pixe ls.toString());
sendData(h, w)
//free memory
_root.snap.d ispose();
trace(_root. tNum);
imgMaker.rem oveMovieClip();
}
}
}
function sendData(h:Number, w:Number){
trace("sending");
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
_root.gotoAn dStop("endSol");
_root.ssMc.r emoveMovieClip();
}
};
//Create the LoadVars object and pass data to PHP script
var output:LoadVars = new LoadVars()
output.img = _root.pixels;
output.height = h
output.width = w
//The page (and this movie itself) should be in a server to work
//output.send("sendImg.aspx", "output", "POST")
output.sendAndLoad("sendImg.aspx", result_lv, "POST");
with(_root.ssMc.snapShotLoader){
text = "één moment geduld, a.u.b...";
setTextForma t(style_fmtSSLoader);
}
}