LeapMotion SDK开发,常用功能总结
来源:互联网 发布:什么软件可以学数学 编辑:程序博客网 时间:2024/05/20 15:39
设置设备后台获取数据:
controller.setPolicyFlags(Leap::Controller::POLICY_BACKGROUND_FRAMES);
onDeviceChange:
获取设备列表: controller.devices();
获取设备名称:devices[i].toString();
判断设备是否传输: devices[i].isStreaming();
onConnect:
启用手势功能:
controller.enableGesture(Gesture::TYPE_CIRCLE);
controller.enableGesture(Gesture::TYPE_KEY_TAP);
controller.enableGesture(Gesture::TYPE_SCREEN_TAP);
controller.enableGesture(Gesture::TYPE_SWIPE);
------------------------
hand:
判断左右手: hand.isLeft();
手掌位置 hand.palmPosition();
法向量 Vector normal = hand.palmNormal();
方向向量 Vector direction = hand.direction();
与垂直轴Y的角度: normal.roll() * RAD_TO_DEG
与水平面-Z的夹角: direction.yaw() * RAD_TO_DEG
arm:
手臂的方向:arm.direction();
腕关节的位置: arm.wristPosition();
手肘的位置: arm.elbowPosition();
Finger:
指头的类型(名称): finger.type();
指头的ID: finger.id();
指头的长度: finger.length();
指头的宽度: finger.width();
Bone:
骨头的类型:Bone::Type
骨头的开始位置点:bone.prevJoint();
骨头的结束位置点:bone.nextJoint();
骨头的方向: bone.direction();
------------------
Tool:
工具ID: frame.id();
工具的位置:tool.tipPosition();
工具的方向: tool.direction();
Gesture:
手势类型:gesture.type();
switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
std::string clockwiseness;
if (circle.pointable().direction().angleTo(circle.normal()) <= PI/2) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
}
// Calculate angle swept since last frame
float sweptAngle = 0;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * PI;
}
std::cout << std::string(2, ' ')
<< "Circle id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", progress: " << circle.progress()
<< ", radius: " << circle.radius()
<< ", angle " << sweptAngle * RAD_TO_DEG
<< ", " << clockwiseness << std::endl;
break;
}
case Gesture::TYPE_SWIPE:
{
SwipeGesture swipe = gesture;
std::cout << std::string(2, ' ')
<< "Swipe id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", direction: " << swipe.direction()
<< ", speed: " << swipe.speed() << std::endl;
break;
}
case Gesture::TYPE_KEY_TAP:
{
KeyTapGesture tap = gesture;
std::cout << std::string(2, ' ')
<< "Key Tap id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", position: " << tap.position()
<< ", direction: " << tap.direction()<< std::endl;
break;
}
case Gesture::TYPE_SCREEN_TAP:
{
ScreenTapGesture screentap = gesture;
std::cout << std::string(2, ' ')
<< "Screen Tap id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", position: " << screentap.position()
<< ", direction: " << screentap.direction()<< std::endl;
break;
}
default:
std::cout << std::string(2, ' ') << "Unknown gesture type." << std::endl;
break;
}
- LeapMotion SDK开发,常用功能总结
- LeapMotion SDK 开发之一 编写第一个LeapMotion VC++ 程序
- Unity& leapmotion开发实录
- LeapMotion VR开发
- Unity之LeapMotion开发
- LeapMotion
- 2.leapmotion之开发指南
- LEAPMotion猎户座(VR)开发~001~
- LEAPMotion猎户座(VR)开发~002~
- LeapMotion开发(四)-- Hand模块下的所有Methods用法和说明(上篇)(C++SDK)
- LeapMotion开发(五)-- Hand模块下的所有Methods用法和说明(下篇)(C++SDK)
- Unity3d 常用功能总结
- iptables 常用功能总结
- JavaScript 常用功能总结
- JavaScript 常用功能总结
- Jquery常用功能总结
- git常用功能总结
- Charles常用功能总结
- HTML5学习之fileReader
- problem中Project'XX'is missing required library:'[路径]\XXX.jar'解决方法
- 第13周项目1删除数组中所有能被3整除的元素
- 数组排序(1)
- 深入理解java异常处理机制
- LeapMotion SDK开发,常用功能总结
- Jenkins FQA
- JS基础——JS找到合适的值
- 软件工程第一次作业
- 第十三周项目1-数组大折腾(1从前往后)
- jdk7 新特性-Java语言的动态性-脚本语言支持api-方法调用05
- uboot默认参数的修改
- Android中的Handler消息处理机制
- LeetCode Find Minimum in Rotated Sorted Array