im using the Threshold method of the Bitmapdata object to make some motion buttons from a camera video source.
It's working with 1 button (1 threshold on 1 rectangle, that is my button onscreen), like this:
//...
actualFrame.draw(oldFrame, new Matrix(), null, "difference");
changedPixels = actualFrame.threshold(actualFrame,rect,pt1,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false);
if (changedPixels > 200) {
//my actions
}
//...
This is working, threshold returns the number of changed pixel between 2 istants, if that is > of 200 (i have to tune this), an action is commited.
The problem is that i need more than 1 button, and
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
}
i use the same dimension for the button (the rectangle rect is the same), and a different (X,Y) position: pt2 vs pt1
But this is not working, changedPixels2 is always 0, (the threshold isnt applied to the image)
how can i correct this?
Thanks
Alessio
My understanding is that threshold changes the BitmapData when it meets the correct conditions. Have you tried creating another instance of actualFrame instead of running threshold on the same one twice?