Leap Motion 入门一:VS上环境配置



  1. 新建项目,创建新的win32控制程序
  2. 菜单->项目->项目属性
  3. 开始配置Debug
  1. 选择 (活动)Debug.
  2. 添加SDK至项目中:
  1. 在 配置属性 目录下, 选择 C/C++ > 常规.

  2. 在 属性 页面, 添加 SDK 的 include 根目录 到 附加包含目录 这一栏中:

    $(LEAP_SDK)\include    
    
$(LEAP_SDK)是LeapSDK的位置。如果设置环境变量没有成功,要么重配环境变量注销计算机让它生效,要么就使用绝对路径试一试。
  1. 添加Leap Motion库引用:
  1. 在 配置属性 下, 选择 链接器 > 常规.  

  2. 在 属性 面板下, 添加 SDK中 lib\x86 根目录 (如果是64位机则添加 lib\x64 ) 到 附加库目录:

    $(LEAP_SDK)\lib\x64  
    本人是win8 64位系统 配置x86后运行成功。

  3. 选择 链接器 > 输入

  4. 添加 Leapd.lib 到 附加依赖项。.

  1. 添加预先生成事件来引用Leap Motion库到运行的项目文件中
  1. 在配置属性下, 选择生成事件->预生成事件。

  2. 编辑 命令行 来拷贝lib文件
    xcopy /yr "$(LEAP_SDK)\lib\x86\Leapd.dll" "$(TargetDir)"
    xcopy /yr "$(LEAP_SDK)\lib\x86\msvcp120d.dll" "$(TargetDir)"
    xcopy /yr "$(LEAP_SDK)\lib\x86\msvcr120d.dll" "$(TargetDir)"
    
  1. 设置 Release下的属性:
  1. 选择 Release.
  2. 如配置Debug一样配置include.
  3. 在链接器中添加库引用Leap.lib (注意不是Leapd.lib).
  4. 在 预生成事件中复制dll, 同样release下全是Leap.dll.
  1. 添加代码就可以运行了

<span style="font-family:Comic Sans MS;font-size:12px;color:#333333;">#include <iostream>
#include <string.h>
#include "Leap.h"

using namespace Leap;

class SampleListener : public Listener {
    public:
    virtual void onConnect(const Controller&);
    virtual void onFrame(const Controller&);
};

void SampleListener::onConnect(const Controller& controller) {
    std::cout << "Connected" << std::endl;
}

void SampleListener::onFrame(const Controller& controller) {
    std::cout << "Frame available" << std::endl;
}

int main(int argc, char** argv) {
    SampleListener listener;
    Controller controller;

    controller.addListener(listener);

    // 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;
}</span>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值