Leap提供了SDK。但是整合有很多的问题,写博客记录一下;

写一个类:SampleListener.cpp以及头文件SampleListener.h。

这里主要碰到的问题是找不到以及冲突问题;

这里最关键的是用的不能写using namespace Lead。必须写Lead::这种形式。

代码如下:

#include <iostream>
#include <cstring>
#include "Leap.h"
//using namespace Leap;
class SampleListener : public Leap::Listener {
public:
int civiv;//手机识别的标志
void onInit(const Leap:: Controller&);
void onConnect(const Leap::Controller&);
void onDisconnect(const Leap:: Controller&);
void onExit(const Leap:: Controller&);
void onFrame(const Leap:: Controller&);
void onFocusGained(const Leap:: Controller&);
void onFocusLost(const Leap::Controller&);
void onDeviceChange(const Leap:: Controller&);
void onServiceConnect(const Leap:: Controller&);
void onServiceDisconnect(const Leap:: Controller&);
void onStart(); private:
};

SampleListener.cpp:

#include "stdafx.h"
#include "SampleListener.h"
using namespace Leap; const std::string fingerNames[] = {"Thumb", "Index", "Middle", "Ring", "Pinky"};
const std::string boneNames[] = {"Metacarpal", "Proximal", "Middle", "Distal"};
const std::string stateNames[] = {"STATE_INVALID", "STATE_START", "STATE_UPDATE", "STATE_END"}; void SampleListener::onInit(const Leap::Controller& controller) {
std::cout << "Initialized" << std::endl;
} void SampleListener::onConnect(const Leap:: Controller& controller) {
std::cout << "Connected" << std::endl;
controller.enableGesture(Gesture::TYPE_CIRCLE);
controller.enableGesture(Gesture::TYPE_KEY_TAP);
controller.enableGesture(Gesture::TYPE_SCREEN_TAP);
controller.enableGesture(Gesture::TYPE_SWIPE);
} void SampleListener::onDisconnect(const Leap:: Controller& controller) {
// Note: not dispatched when running in a debugger.
std::cout << "Disconnected" << std::endl;
} void SampleListener::onExit(const Leap::Controller& controller) {
std::cout << "Exited" << std::endl;
} void SampleListener::onFrame(const Leap:: Controller& controller) {
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
std::cout << "Frame id: " << frame.id()
<< ", timestamp: " << frame.timestamp()
<< ", hands: " << frame.hands().count()
<< ", extended fingers: " << frame.fingers().extended().count()
<< ", tools: " << frame.tools().count()
<< ", gestures: " << frame.gestures().count() << std::endl; Leap::HandList hands = frame.hands();
for ( Leap::HandList::const_iterator hl = hands.begin(); hl != hands.end(); ++hl) {
// Get the first hand
const Leap:: Hand hand = *hl;
std::string handType = hand.isLeft() ? "Left hand" : "Right hand";
std::cout << std::string(, ' ') << handType << ", id: " << hand.id()
<< ", palm position: " << hand.palmPosition() << std::endl;
// Get the hand's normal vector and direction
const Leap::Vector normal = hand.palmNormal();
const Leap:: Vector direction = hand.direction(); // Calculate the hand's pitch, roll, and yaw angles
std::cout << std::string(, ' ') << "pitch: " << direction.pitch() * Leap::RAD_TO_DEG << " degrees, "
<< "roll: " << normal.roll() * Leap::RAD_TO_DEG << " degrees, "
<< "yaw: " << direction.yaw() * Leap:: RAD_TO_DEG << " degrees" << std::endl; // Get the Arm bone
Leap::Arm arm = hand.arm();
std::cout << std::string(, ' ') << "Arm direction: " << arm.direction()
<< " wrist position: " << arm.wristPosition()
<< " elbow position: " << arm.elbowPosition() << std::endl; // Get fingers
const Leap::FingerList fingers = hand.fingers();
for ( Leap::FingerList::const_iterator fl = fingers.begin(); fl != fingers.end(); ++fl) { civiv=;
const Leap::Finger finger = *fl;
std::cout << std::string(, ' ') << fingerNames[finger.type()]
<< " finger, id: " << finger.id()
<< ", length: " << finger.length()
<< "mm, width: " << finger.width() << std::endl; // Get finger bones
for (int b = ; b < ; ++b) {
Leap::Bone::Type boneType = static_cast< Leap::Bone::Type>(b);
Leap::Bone bone = finger.bone(boneType);
std::cout << std::string(, ' ') << boneNames[boneType]
<< " bone, start: " << bone.prevJoint()
<< ", end: " << bone.nextJoint()
<< ", direction: " << bone.direction() << std::endl;
}
}
} // Get tools
const ToolList tools = frame.tools();
for (ToolList::const_iterator tl = tools.begin(); tl != tools.end(); ++tl) { const Tool tool = *tl;
std::cout << std::string(, ' ') << "Tool, id: " << tool.id()
<< ", position: " << tool.tipPosition()
<< ", direction: " << tool.direction() << std::endl;
} // Get gestures
const GestureList gestures = frame.gestures();
for (int g = ; g < gestures.count(); ++g) {
Gesture gesture = gestures[g]; switch (gesture.type()) {
case Gesture::TYPE_CIRCLE:
{
CircleGesture circle = gesture;
std::string clockwiseness; if (circle.pointable().direction().angleTo(circle.normal()) <= PI/) {
clockwiseness = "clockwise";
} else {
clockwiseness = "counterclockwise";
} // Calculate angle swept since last frame
float sweptAngle = ;
if (circle.state() != Gesture::STATE_START) {
CircleGesture previousUpdate = CircleGesture(controller.frame().gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * * 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(, ' ')
<< "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(, ' ')
<< "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(, ' ')
<< "Screen Tap id: " << gesture.id()
<< ", state: " << stateNames[gesture.state()]
<< ", position: " << screentap.position()
<< ", direction: " << screentap.direction()<< std::endl;
break;
}
default:
std::cout << std::string(, ' ') << "Unknown gesture type." << std::endl;
break;
}
} if (!frame.hands().isEmpty() || !gestures.isEmpty()) {
std::cout << std::endl;
} } void SampleListener::onFocusGained(const Controller& controller) {
std::cout << "Focus Gained" << std::endl;
} void SampleListener::onFocusLost(const Controller& controller) {
std::cout << "Focus Lost" << std::endl;
} void SampleListener::onDeviceChange(const Controller& controller) {
std::cout << "Device Changed" << std::endl;
const Leap::DeviceList devices = controller.devices(); for (int i = ; i < devices.count(); ++i) {
std::cout << "id: " << devices[i].toString() << std::endl;
std::cout << " isStreaming: " << (devices[i].isStreaming() ? "true" : "false") << std::endl;
}
} void SampleListener::onServiceConnect(const Controller& controller) {
std::cout << "Service Connected" << std::endl;
} void SampleListener::onServiceDisconnect(const Controller& controller) {
std::cout << "Service Disconnected" << std::endl;
}
void SampleListener::onStart()
{
// civiv=1;
// Create a sample listener and controller
SampleListener listener;
listener.civiv=;
Controller controller;
//controller.Config.SetFloat ("Gesture.Circle.MinRadius", 10.0f); .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
//................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................// controller.Config.SetFloat ("Gesture.Circle.MinArc", .5f);
// controller.config().setFloat("Gesture.Circle.MinRadius", 10.0f);
// controller.config().setFloat("Gesture.Circle.MinRadius", .5f); // Have the sample listener receive events from the controller
controller.addListener(listener); //if (argc > 1 && strcmp(argv[1], "--bg") == 0)
//controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES); // Keep this process running until Enter is pressed // Remove the sample listener when done
controller.removeListener(listener); } /*int main(int argc, char** argv) {
// Create a sample listener and controller
SampleListener listener;
Controller controller;
//controller.Config.SetFloat ("Gesture.Circle.MinRadius", 10.0f);
// controller.Config.SetFloat ("Gesture.Circle.MinArc", .5f);
controller.config().setFloat("Gesture.Circle.MinRadius", 10.0f);
controller.config().setFloat("Gesture.Circle.MinRadius", .5f); // Have the sample listener receive events from the controller
controller.addListener(listener); if (argc > 1 && strcmp(argv[1], "--bg") == 0)
controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES); // Keep this process running until Enter is pressed
std::cout << "Press Enter to quit..." << std::endl;
std::cin.get(); // Remove the sample listener when done
controller.removeListener(listener); return 0;
}
*/

嵌入师兄的MFC写的程序中:

注意因为与师兄写的变量冲突,所以这里不能写using namespace Lead。必须写Lead::这种形式。

EyeTrackView.h:

#include "TshirtCode.h"
#include "TshirtDraw.h"
#include "GeneticAlgorithm.cpp"
#include "CvvImage.h"
#include <deque>
#include "shockwaveflash1.h"
#include "pupilDetector.h"
#include "Device.h"
#include "communication.h"
#include "DeviceEyeDataAnalyze.h"
#include "HardWord.h"
#include "SampleListener.h"

EyeTrackView.cpp照常引入EyeTrackView.h。

研:手势与眼动相结合-手势SDK的整合的更多相关文章

  1. C#开发EyeLink眼动仪的实验程序

    [题外话] Eyelink眼动仪是SR Research推出的一款眼动仪,很多高校都在使用其做实验.其官方提供了COM的接口,所以支持COM接口的开发平台都可以开发使用.官方甚至提供了一个C#的样例供 ...

  2. 与众不同 windows phone (25) - Input(输入)之捕获 UIElement 之外的触控操作, Silverlight 方式捕获手势操作, XNA 方式捕获手势操作, 多点触控

    原文:与众不同 windows phone (25) - Input(输入)之捕获 UIElement 之外的触控操作, Silverlight 方式捕获手势操作, XNA 方式捕获手势操作, 多点触 ...

  3. 手势-webview与scrollView重复手势处理

    // called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocke ...

  4. 解决右滑返回手势和UIScrollView中的手势冲突

    当在一个viewController中添加了scrollView或者tableView的时候,贴边侧滑返回的时候会首先触发滚动而失效,要解决这个问题,需要通过requireGestureRecogni ...

  5. iOS手势UIGestureRecognizer的使用及手势冲突的解决办法【转】

    转自:iOS开发中的手势体系——UIGestureRecognizer分析及其子类的使用 关于手势的一篇很好的帖子,转载过来免得丢失.你可能最感兴趣的是手势间的互斥处理,那么就搜索 4.手势间的互斥处 ...

  6. 乐动ld06激光雷达sdk改bug记录分享

    前言: 工作中,有使用过乐动ld06款激光雷达,此款雷达将常规雷达的转动的电机部分内置于自己的保护罩内,减少了雷达本身转动积灰等其他外界影响,探测半径是12m,是一款不错的雷达. 不过今天的主要内容不 ...

  7. Kinect for Windows SDK v2.0 开发笔记 (十五) 手势帧

     (转载请注明出处) 使用SDK: Kinect for Windows SDK v2.0 public preview1409 同前面,由于SDK未完毕,不附上函数/方法/接口的超链接. 这次最 ...

  8. 手势识别(一)--手势基本概念和ChaLearn Gesture Challenge

    以下转自: http://blog.csdn.net/qq1175421841/article/details/50312565 像点击(clicks)是GUI平台的核心,轻点(taps)是触摸平台的 ...

  9. RDVECore来自锐动的无UI,高度抽象化API的视频编辑SDK

    1 编写目的 预期读者: 有视频编辑开发经验或者无经验的,打算或者正在使用"锐动IOS版RDVECore"的相关工程师. iOS软件工程师. 产品经理. QA 2 名词解释 分辨率 ...

随机推荐

  1. CRM Look Up 解决方案

    CRM 前瑞开发中关于lookup的开发工作肯定会遇到,例如选中一个客户或者联系人后自动把相关的信息映射到相关记录上,这样可以减少用户的输入工作.我们在CRM 的映射关系中可以配置相关字段的映射可以解 ...

  2. Microsoft FIM: Working with Domino Connector v8

    Microsoft FIM: Working with Domino Connector v8 Posted on July 22, 2013 by Michael Pearn - 4 Comment ...

  3. Caused by: java.lang.UnsupportedOperationException

    对Arrays.asList()返回的List进行操作之后报错Caused by: java.lang.UnsupportedOperationException 让我们来看一下Arrays.asLi ...

  4. iOS内存管理(二)之深拷贝和浅拷贝

    对象拷贝(复制对象) 1.复制对象顾名思义,复制一个对象作为副本,它会开辟一块新的一块内存(堆内存)来存储副本对象,就像复制文件一样.即源对象和副本对象是两块不同的内存区域.   2.NSObject ...

  5. UnityShader之固定管线命令Combine纹理混合【Shader资料4】

    Combine,纹理混合. 我们先看圣典上给的解释. 纹理在基本的顶点光照被计算后被应用.在着色器中通过SetTexture 命令来完成. SetTexture 命令在片面程序被使用时不会生效:这种模 ...

  6. WPF+Caliburn.Micro 杂记

    开发过程中的小问题总结 1DataGrid的Header里面给Checkbox绑定IsEnabled,绑不上去.  2由A页面跳转到B页面,再由B页面返回一个值 3DataGrid里面的行通过一个方法 ...

  7. android network develop(1)----doing network background

    Develop network with HttpURLConnection & HttpClient. HttpURLConnection  is lightweight with Http ...

  8. chrome浏览器font-size<12px无效解决办法

    当样式设定font-size<12px时,chrome浏览器里字体显示仍为12px:如font-size:11px; 但是chrome还是12px的大小,很不听话. 今天我就遇到了这样的问题?网 ...

  9. ubuntu14.04下nodejs + npm + bower的安装、调试和部署

      1. 简介 本文介绍ubuntu14.04下nodejs+npm+bower的安装.调试和部署 参考文档 https://docs.npmjs.com/getting-started https: ...

  10. Node.js之Promise维护(同步)多个回调(异步)状态

    金天:学习一个新东西,就要持有拥抱的心态,如果固守在自己先前的概念体系,就会有举步维艰的感觉..NET程序员初用node.js最需要适应的就是异步开发, 全是异步,常规逻辑下遍历列表都是异步,如何保证 ...