Flash 使用双阈值

Flash 使用双阈值,flash,actionscript,webcam,motion-detection,Flash,Actionscript,Webcam,Motion Detection,im使用Bitmapdata对象的阈值方法从摄影机视频源制作一些运动按钮 它使用1个按钮(1个矩形上的1个阈值,即屏幕上的我的按钮),如下所示: //... actualFrame.draw(oldFrame, new Matrix(), null, "difference"); changedPixels = actualFrame.threshold(actualFrame,rect,pt1,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false);

im使用Bitmapdata对象的阈值方法从摄影机视频源制作一些运动按钮

它使用1个按钮(1个矩形上的1个阈值,即屏幕上的我的按钮),如下所示:

//...
actualFrame.draw(oldFrame, new Matrix(), null, "difference"); 
 changedPixels = actualFrame.threshold(actualFrame,rect,pt1,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false); 
    if (changedPixels > 200)  {
     //my actions
    }
//...
这是工作,阈值返回2个IStant之间更改的像素数,如果大于200(我必须对此进行调整),则执行操作

问题是我需要不止一个按钮,而且

actualFrame.draw(oldFrame, new Matrix(), null, "difference"); 
changedPixels = actualFrame.threshold(actualFrame,rect,pt1,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false); 
if (changedPixels > 200)  {
       //my actions
}

changedPixels2 = actualFrame.threshold(actualFrame,rect,pt2,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false); 
if (changedPixels2 > 200)  {
    //my actions
}
我对按钮使用相同的尺寸(矩形rect是相同的),并且使用不同的(X,Y)位置:pt2与pt1

但这不起作用,changedPixels2始终为0(阈值未应用于图像)

我怎样才能纠正这个问题

谢谢


Alessio

我的理解是,当BitmapData满足正确的条件时,threshold会改变它。您是否尝试过创建另一个actualFrame实例,而不是在同一个实例上运行两次threshold

actualFrame.draw(oldFrame, new Matrix(), null, "difference"); 
changedPixels = actualFrame.threshold(actualFrame,rect,pt1,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false); 
if (changedPixels > 200)  {
       //my actions
}

actualFrame2.draw(oldFrame, new Matrix(), null, "difference");
changedPixels2 = actualFrame2.threshold(actualFrame2,rect,pt2,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false); 
if (changedPixels2 > 200)  {
    //my actions
}

有4-5个按钮会很慢,我想我试过了(有2个按钮),但它太慢了,不能100%工作,我以后会再试一次