HandList类(Leap:: HandList)

HandList类(Leap:: HandList)

这个类代表了Hand对象的列表。通过调用Frame:: hands()可以得到一个HandList对象。
Leap:: HandList allHands = frame.hands();
HandList & append(const HandList & other): 表示把指定的一个HandList的成员添加到这个HandList对象中。参数other表示一个HandList对象,其中包含Hand对象,将要添加到这个HandList对象末端。
const_iterator begin(): 表示C++的迭代器,设置在这个HandList对象的开始。
用法:Leap:: HandList hands = frame.hands();
for (Leap:: HandList::const_iterator hl = hands.begin(); hl != hands.end(); hl++)
std::cout << *hl << std::endl;
int count(): 表示这个列表中手的数目。
const_iterator end(): 表示C++的迭代器,设置在这个HandList对象的结束。
用法:Leap:: HandList hands = frame.hands();
for (Leap:: HandList::const_iterator hl = hands.begin(); hl != hands.end(); hl++)
std::cout << *hl << std::endl;
Hand frontmost(): 表示在Leap Motion参照系下这个列表中最靠前的成员(也就是z值最小)。
用法:Leap::Hand FrontHand=frame. hands().frontmost();
HandList(): 表示构造一个没有实体的空列表。
bool isEmpty(): 判断这个列表是否为空。如果没有成员,返回True。
Hand leftmost(): 表示在Leap Motion参照系下这个列表中最靠左的成员(也就是x值最小)。
用法:Leap::Hand furthestleft=frame. hands().leftmost();
Hand operator[](int index): 表示对列表中一个成员位置的访问。返回的是指定索引下的Hand对象。
用法:Leap::Hand firstInList=frame.hands()[0];
Hand rightmost(): 表示在Leap Motion参照系下这个列表中最靠右的成员(也就是x值最大)。
用法:Leap::Hand furthestright=frame. hands().rightmost();

引自:https://developer.leapmotion.com/documentation/cpp/api/Leap.HandList.html

### LeapMotion2 的安装与使用教程 #### 软件环境准备 在开始之前,确保计算机满足以下条件: - Windows 或 macOS 操作系统。 - 已安装最新版本的驱动程序以及 SDK。可以从官网下载并按照说明完成安装[^1]。 #### 安装过程详解 1. **硬件连接**Leap Motion 控制器通过 USB 接口连接到电脑上。设备会自动被识别,并提示安装相应的驱动程序[^2]。 2. **软件配置** 下载并解压 Leap Motion 提供的 SDK 文件包至本地目录。随后,在项目环境中设置好对应的路径以便调用其功能库[^3]。 3. **集成开发环境 (IDE) 配置** 对于 Unity 用户来说,需导入特定插件来支持手势追踪等功能模块。具体操作可参照官方文档中的指导步骤执行[^4]。 #### 基础API介绍 以下是几个常用及其作用描述: - `Hand` :表示单只手的整体数据结构,包括位置、方向等属性信息[^5]。 ```csharp var handList = frame.Hands; foreach(var hand in handList){ Debug.Log("Palm Position:" +hand.PalmPosition); } ``` - `Finger` :用于获取每根手指的具体参数比如长度、弯曲角度等等。 - `Tool` :当检测到笔状物时会被实例化出来,可用于虚拟绘画场景下模拟真实工具行为。 - `Gesture` :封装了一系列预定义的手势动作模式匹配机制,开发者能够轻松捕获复杂的人体动态表现形式。 #### 示例代码片段展示如何初始化控制器对象并与之交互 ```csharp using UnityEngine; using System.Collections; public class ExampleScript : MonoBehaviour { private Controller controller; void Start(){ this.controller=new Controller(); } void Update() { Frame frame=controller.Frame(); foreach(Finger finger in frame.Fingers){ Vector3 tipPos=finger.TipPosition.ToVector3(); Debug.DrawRay(tipPos,-finger.Direction.ToVector3(),Color.red); } } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值