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()){}分类对手势进行操作

     

  • 相关阅读:
    每日学习
    每日学习——iframe标签伪造ajax
    每日总结
    LA 3667 Ruler
    hdu 2066 一个人的旅行 (dij+heap)
    LA 3507 Keep the Customer Satisfied (Greedy)
    hdu 2527 Safe Or Unsafe
    LA 4636 Cubist Artwork
    hdu 4514 湫湫系列故事——设计风景线(树DP)
    LA 4328 Priest John's Busiest Day (Greedy)
  • 原文地址:https://www.cnblogs.com/2cats/p/3687728.html
Copyright © 2011-2022 走看看