天天看點

Qt 加載Leap motion 手勢識别軟體 二次開發 hello world

開始使用的Qt mingw的版本開發,總是函數沒有定義,最後發現是leap sdk中需要代育vs的庫檔案,是以猜測需要使用vs版本的Qt 編譯,順利通過

Qt 加載Leap motion 手勢識别軟體 二次開發 hello world

以下是源代碼,有需要的,借鑒一下下

Pro檔案

QT += core
QT -= gui
 
CONFIG += c++11
 
TARGET = Leap_test
CONFIG += console
CONFIG -= app_bundle
 
#INCLUDEPATH += C:\Dev\LeapSDK\include
 
#LIBS += -L E:\WorkSpace\Leap_test -l Leap
 
LIBS += $$PWD\Leap.lib
 
TEMPLATE = app
 
SOURCES += main.cpp      

cpp檔案

#include <QCoreApplication>
#include <QDebug>
#include "Leap.h"
 
 
using namespace Leap;
 
 
 
class SampleListener:public Listener
{
public:
    virtual void onConnect(const Controller& controller);
 
    virtual void onFrame(const Controller& controller);
};
 
 
 
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
 
    qDebug()<<"Leap Motion Testing ...";
 
 
    SampleListener listenertest;
 
   Controller controllertest;
 
 
   controllertest.addListener(listenertest);
 
 
 
    std::cin.get();
 
    controllertest.removeListener(listenertest);
 
 
 
 
 
    return a.exec();
}
 
 
void SampleListener::onConnect(const Controller& controller)
{
    qDebug()<<"Connected";
 
    controller.enableGesture(Gesture::TYPE_SWIPE);
 
 
}
 
void SampleListener::onFrame(const Controller& controller)
{
    qDebug()<<"Fram available";
 
    const Frame frame = controller.frame();
 
    qDebug()<< "Frame id: " << frame.id()
            << ", timestamp: " << frame.timestamp()
            << ", hands: " << frame.hands().count()
            << ", fingers: " << frame.fingers().count()
            << ", tools: " << frame.tools().count()
            << ", gestures: " << frame.gestures().count();
 
}      

歡迎交流

繼續閱讀