• LeapMotion HelloWorld


    Leap::Controller:

      该类提供了主要的接口,当你创建一个controller对象时,它会和电脑上的服务连接使得你能从Leap::Frame对象获得帧数据

    如何获得帧对象:

      调用Controller对象的frame函数,空参返回最新的Frame对象,参数为1时获取的是上一次的Frame对象

    更新程序数据的两种方式:

      类似  轮询(循环里不断去获得帧对象)和中断(添加Listener,有数据更新时执行回调函数

    回调函数的写法:

      继承自Leap::Listener,重写一系列回调函数:

      • onInit — dispatched once, when the controller to which the listener is registered is initialized.
      • onConnect — dispatched when the controller connects to the Leap and is ready to begin sending frames of motion tracking data.
      • onDisconnect — dispatched if the controller disconnects from the Leap (for example, if you unplug the Leap device or shut down the Leap software).
      • onExit — dispatched to a listener when it is removed from a controller.
      • onFrame — dispatched when a new frame of motion tracking data is available.

     

    Frame里的数据:

      Hand对象或Finger对象都包含一个id和一些属性

     

    手势:

      获取手势之前需使能手势识别,  在connect后任意时刻调用

        controller.enableGesture(Gesture::TYPE_CIRCLE);

          controller.enableGesture(Gesture::TYPE_KEY_TAP);等等即可使能

    获取手势对象

    const GestureList gestures = frame.gestures();
    
    //gestures.count()
    
    //Gestures[0]
    //controller.frame(1).gesture(circle.id())//返回上一帧的某一手势,用id号查找

    Gesture 类是手势对象的基类,获得的gesture可能需要强制转换成子类,转换类型不匹配时,返回 invalid Gesture objects

    switch (gesture.type()){}分类对手势进行操作

     

  • 相关阅读:
    IOS数据持久化之归档NSKeyedArchiver
    Java中导入、导出Excel
    IOS开发中多线程的使用
    深入分析动态管理Fragment
    IOS开发之数据sqlite使用
    如何在Eclipse和Tomcat的Debug过程中启用热部署
    在PHP中无法连接Memcached的解决办法
    Apache mod_rewrite规则重写的标志一览
    Java多线程中run(), start(), join(), wait(), yield(), sleep()的使用
    Centos5.8下编译安装PHP5.4和memcached, phalcon, yaf, apc
  • 原文地址:https://www.cnblogs.com/2cats/p/3687728.html
Copyright © 2020-2023  润新知