使用双阈值
我使用 Bitmapdata 对象的 Threshold 方法从相机视频源制作一些运动按钮。
它使用 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 个距离之间更改的像素数,如果 > 200(我必须调整这个),一个动作被提交。
问题是我需要超过 1 个按钮,并且
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,(阈值未应用于图像)
我该如何纠正这个问题?
谢谢阿莱西奥
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的理解是,阈值在满足正确条件时会更改 BitmapData。您是否尝试过创建另一个actualFrame实例,而不是在同一个实例上运行阈值两次?
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?