zoukankan      html  css  js  c++  java
  • 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()){}分类对手势进行操作

     

  • 相关阅读:
    php数组之选择排序算法参考
    php数组之插入排序算法参考
    php数组之冒泡排序算法参考
    MySQL查询中的条件控制(where,group by,having,order by,limit,from,exists)
    第四次作业
    第三次作业
    第二次作业
    作业
    DevExpress TreeList使用心得
    项目开发总结:解决多线程窗体与主风格不一致问题
  • 原文地址:https://www.cnblogs.com/2cats/p/3687728.html
Copyright © 2011-2022 走看看