Leap Motion SDK学习--API(翻译)
来源:互联网 发布:淘宝 卖家 现状 编辑:程序博客网 时间:2024/05/01 11:13
Leap Motion SDK学习--API(翻译)
Tool类
函数:
l Tool()
l Tool(const Pointable&)
l Invalid()
l toString()const
l
classLeap:: Tool
Tool类表示一个被跟踪的工具。在LeapMotion中,可指向对象被定义为工具。工具比手指更长,更细,更直。我们可以从一帧图像或者手对象中得到工具对象。
工具也可指向手,但是它们不像手指一样与手臂永久关联,其可以在ID不变的情况下在双手间传递。
工具对象可能无效,这意味着它们不包含有效的跟踪数据或者不对应于一个物理工具。无效的工具类可能是由于要求一个工具类使用一个在之前帧存在过(但当前帧不存在)的工具类对象的ID号造成的。从工具的构造函数创建的工具对象也是无效的。可以使用Tool::isValid()函数验证工具对象的有效性。
Pointable类
函数:
l Pointable()
l invalid()
l toString() const
class Leap::Pointable()
Pointable类检测对象的物理特征。Pointable对象包括finger和Tool两类,可以通过函数Pointable::isFinger()和Pointable::isTool()来判断一个对象时finger还是Tool。
Leap::Pointablepointable = frame.pointables().frontmost();
Leap::Vectordirection = pointable.direction();
float length= pointable.length();
float width =pointable.width();
Leap::VectorstabilizedPosition = pointable.stabilizedTipPosition();
Leap::Vectorposition = pointable.tipPosition();
Leap::Vectorspeed = pointable.tipVelocity();
floattouchDistance = pointable.touchDistance();
Leap::Pointable::Zonezone = pointable.touchZone();
Public Functions
l Vectordirection()
功能: 返回手指或者工具指向的方向,方向用一个单元向量表示,指向的方向就是手指或者工具顶端指向的方向。
VectorpointingToward=pointable.direction();
//如果需要修改方向获取需要对pointable类进行集成或覆盖
l Frameframe()
FrameframeOfThisPointableObject=pointable.frame();
返回值: 如果有的话,返回相关Frame对象;否则,返回一个无效的Frame对象。
l Handhand()
表示与手指或工具相关联的手对象
HandattachedHand=pointalbe.hand();
返回值:如果有的话,返回相关Hand对象;否则,返回一个无效的Hand对象。
l Int32_tid()
给Pointable对象指定的特定的ID号,当被追踪的手指和工具在连续帧中始终可见时其ID号保持不变。当跟踪失败时(例如,当一个手指被另一个手指遮挡或者手指从LeapMotion的可视范围中离开),LeapMotion会在重新检测到这个实体时为其重新分配一个ID号。
Int32_ttheID=pointable.id();
返回值:Pointable对象的ID
可以根据ID号以及Frame::pointable()函数在后面的帧中找到该对象。ID号的范围是1~100,当跟踪对象超过100时,将使用-1作为ID号直到有可用的ID号。
l bool isExtended()
功能:检测Pointable对象是否是延伸的
当手指是从手的直线延长就被认为是扩展的;当手指向下弯曲或卷曲朝向手掌时就不是延伸的。工具永远是延伸的。
intextendedFingers = 0;
for(int f = 0; f < hand.fingers().count(); f++)
{
Finger finger = hand.fingers()[f];
if(finger.isExtended()) extendedFingers++;
}
返回值: 当对象是延伸的时,返回TRUE
l bool isFinger() / bool isTool()
手指比工具短,粗并且没有那么直。
if(pointable.isTool()) {
Leap::Tool tool = Leap::Tool(pointable);
}else {
Leap::Finger finger =Leap::Finger(pointable);
}
l boolisValid()
判断一个Pointable对象是否有效
if(pointable.isValid()) {
//Use it...
}
当对象包含跟踪数据时,就真的存在,返回TRUE。
l float length()
float apparentlength =pointable.length();
功能:计算在Leap Motion的可见范围下手指或者工具的长度(单位:mm),如果长度值不知道,就返回0.
l booloperator!=(const Pointable &)
bool operator==(const Pointable &)
功能: 比较两个对象是否对等
thisPointable!=thatPointable;
当且仅当两个对象都有效且代表同一帧中相同的物理实体时两个对象才是相同的。
l VectorstabilizedTipPosition()
Vector stabilizedPosition =pointable.stabilizedTipPosition();
功能:对Pointable对象的顶端进行平滑化和稳定化处理,以使该值更适合于与2D内容进行交互。稳定的位置滞后于顶端位置一个可变值,主要取决于对象的运动速度。
返回值: 修正的顶端位置。
l floattimeVisible()
float lifetime=pointable.timeVisible();
功能: Pointable对象被持续跟踪的时间(在控制器的可见范围内)。
l Vector tipPosition()
Vector currentPosition =pointable.tipPosition();
返回值: 返回顶端的坐标(单位:mm)。
l VectortipVelocity()
Vector currentSpeed =pointable.tipVelocity();
返回值: 返回顶端的运动速度,为一个矢量。
l Tool(const Pointable &)
如果一个特定的Pointable对象表示一个工具,那么创建它的一个副本作为工具对象;否则创建一个无效的工具对象。
If(pointable.isTool()){
Tool tool=Tool(pointable);
}
l std::stringtoString()
返回一个字符串,包含了工具的简单说明。
l floattouchDistance()
Pointable对象与自适应触摸屏面之间的距离。范围为[-1,1],值为1.0表示对象与平面无限远,0表示对象刚好进入可触摸区域;-1表示对象坚定滴在可触摸区域,0.5表示对象在正在进入悬停区。
floatdistance = pointable.touchDistance();
if(distance > 0) {
//Handle hovering ...
}else {
//Handle touching ...
}
l ZonetouchZone()
LeapMotion的软件依据能够适应用户手指移动和手指形状的浮动触摸区来计算触摸区。LeapMotion软甲将有目的的运动作为可能的触摸点。当Pointable对象靠近自适应触摸平面时,他进入了“徘徊”区域,当对象到达或者穿过了平面时,他进入了“触摸”区。
touchDistance为在悬停区和触摸区的对象提供了一个归一化的预测。
返回值:对象当前的触摸区域。
switch(pointable.touchZone()) {
case Pointable::Zone::ZONE_NONE:
//Handle distant pointable
break;
case Pointable::Zone::ZONE_HOVERING:
//Handle pointable near touch plane
break;
case Pointable::Zone::ZONE_TOUCHING:
//Handle pointable penetrating touchplane
break;
default:
//Handle error cases...
break;
}
l Floatwidth()
floataverageThickness=pointable.width();
返回值:手指或工具的宽度(单位: mm)。
Public Static Functions
l constTool&invalid()
功能: 返回一个无效的工具对象,可以用该函数验证一个给定的工具实例是否是有效的。
if(tool != Tool::invalid()) {
//Handle valid tool data
}
- Leap Motion SDK学习--API(翻译)
- Unity Leap Motion学习笔记
- Leap Motion 之 官方SDK代码分析
- (0)Leap Motion简介
- leap motion
- Leap Motion
- Leap Motion
- Leap Motion 之Unity 开发指南(二. 开发架构和SDK)L
- 【VR】Leap Motion 官网文档 LeapRecorder (Leap记录器)
- 【VR】Leap Motion 官网文档 LeapRecorder (Leap记录器)
- [Leap Motion开发文档翻译]屏幕定位 Screen Location
- [资料汇总]Leap Motion官方开发文档翻译
- Develop Leap Motion in Ubuntu 16.04.02 LTS: SDK install
- Leap Motion环境配置(C++)
- 在unity3D里建立leap motion API的过程
- 从Kinect和Leap Motion谈体感的开发(无处不在的机器学习)
- 【翻译】动态图像监测开源代码 motion 学习-----Motion Guide - Installation(motion的安装指南)
- LEAP MOTION与MYO
- c++ 日历
- 用red5和flex实现的一个小的聊天程序
- 遇到的蛋疼bug
- zoj 2176 Speed Limit
- 【线段树】 HDOJ 1540 Tunnel Warfare
- Leap Motion SDK学习--API(翻译)
- 黑马程序员——集合
- ADS错误(Fatal)L6002U解决方法
- function返回sys_refcursor
- Machine Learning in Python (Scikit-learn)-(No.1)
- Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds
- 网络流+删边判环hdu4975
- 实习一个月的小总结(前台跳后台、后台跳前台)
- hdu4778 状态压缩dp+博弈