我想要检测手指(或任何对象)是否指向(屏幕上的)某个框,如下图所示。
下面的代码可以用来获取手指的xy坐标,但是定义交互框的最简单方法是什么,然后映射坐标,看看它是否与屏幕外部的任何框匹配。
我在Windows上使用的是最新版本的leap motion SDK (3.2.0)。
def on_frame(self, controller):
app_width = 800
app_height = 600
# Get the most recent frame and report some basic information
frame = controller.frame()
pointable = frame.pointables.frontmost
if pointable.is_valid:
iBox = frame.interaction_box
leapPoint = pointable.stabilized_tip_position
normalizedPoint = iBox.normalize_point(leapPoint, False)
app_x = normalizedPoint.x * app_width
app_y = (1 - normalizedPoint.y) * app_height
#The z-coordinate is not used
print ("X: " + str(app_x) + " Y: " + str(app_y))然后输出如下所示:
X: 467.883825302 Y: 120.019626617
X: 487.480115891 Y: 141.106081009
X: 505.537891388 Y: 164.418339729
X: 522.712898254 Y: 189.527964592
X: 539.482307434 Y: 213.160014153
X: 556.220436096 Y: 233.744287491
X: 573.109865189 Y: 253.145456314

https://stackoverflow.com/questions/41222130
复制相似问题