Computer Graphics and Multimedia Software - Knowledge Sharing

Monday, November 20, 2017

openframeworks basic tutorial LeapMotion gesture recognition

The following repository version could be built without problems or you could also receive directly from openframeworks addon.
First of all, as a Hello World-like sample, try to recognize and display the hand. Only the fingertip could be detected independently! Easy!
There are two ways available for ofxLeapMotion. The first method is to use a simple hand model called ofxLeapMotionSimpleHand defined in ofxLeapMotion. The second method is to access and display functions provided by LeapMotion's SDK.
First of all, I try to draw by using a simple ofxLeapMotionSimpleHand. The way of doing it is very simple, once you have recognized ofxLeapMotionSimpleHand, calling a method called debugDraw () on that instance will display a simple 3D model of the hand.

testApp.cpp

#include "testApp.h"

void testApp::setup(){
ofSetFrameRate(60);
ofSetVerticalSync(true);
ofBackground(31);

ofEnableLighting();
light.setPosition(200, 300, 50);
light.enable();
cam.setOrientation(ofPoint(-20, 0, 0));

glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
leap.open();
}

void testApp::update(){

simpleHands = leap.getSimpleHands();

if( leap.isFrameNew() && simpleHands.size() ){
fingerPos.clear();

leap.setMappingX(-230, 230, -ofGetWidth()/2, ofGetWidth()/2);
leap.setMappingY(90, 490, -ofGetHeight()/2, ofGetHeight()/2);
leap.setMappingZ(-150, 150, -200, 200);

for(int i = 0; i < simpleHands.size(); i++){
for(int j = 0; j < simpleHands[i].fingers.size(); j++){
ofVec3f pos = simpleHands[i].fingers[j].pos;
fingerPos.push_back(pos);
}
}
}
leap.markFrameAsOld();
}

void testApp::draw(){
cam.begin();
for(int i = 0; i < fingerPos.size(); i++){
ofBoxPrimitive box;
box.setPosition(fingerPos[i].x, fingerPos[i].y, fingerPos[i].z);
box.set(20);
box.draw();
}
cam.end();
}

testApp.h

#include "ofMain.h"
#include "ofxLeapMotion.h"

class testApp : public ofBaseApp{

public:
void setup();
void update();
void draw();

void keyPressed (int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void exit();

ofxLeapMotion leap;
vector simpleHands;
ofEasyCam cam;
ofLight light;
vector fingerPos;
};

The output : 


Share:

6 comments:

  1. LifeVoxel.AI platform offers a better alternative for the medical imaging community. Its unique approach is based on 12 international patents that encompass visualization, AI, image management, workflow and billing. It works 100X faster and 50%+ cheaper than all our competitors. Enterprise Imaging (VNA and Image Sharing) are unsuitable for AI and 3D/VR/AR. Powered by GPU (Graphical Processors) and AI it provides you with high-quality images that can be accessed at different locations with ease.

    Interactive Streaming AI Platform RIS PACS

    ReplyDelete
  2. Grab best holiday deals and discount up to $50 on flight tickets to India:


    Tripbeam.com
    Airfarebooking.ca
    Flyopedia.com
    Tripbeam.ca

    Babycouture is one-stop destination for baby and kids wear online.

    Buy kids wear online


    ReplyDelete
  3. The following are the reasons why it is in high demand for our Uber Clone APP:
    Branding and modular solution that is superior
    Highly tailored framework for taxi
    Application ready to run
    Taxi app for platforms for Android & IOS
    Seamless admin panel to monitor company operations
    Aid for top-notch maintenance
    Extremely cost-efficient
    Creation of websites

    ReplyDelete
  4. Omninos is a Top-notch mobile app development company, backed by strong workforce experts providing highly proficient mobile app development services of any complexity with incredible competence. It is also the Best IPad Application Development Company in Chandigarh.. Omninos is a unique iPad application Development organization driven by Mac capable iPad app designers that are known for building the finest app.

    ReplyDelete
  5. Are you willing to get TikTok Clone APP developed for your own business? You must be pleased to know that Omninos Solutions is Providing you a great opportunity to get developed a clone APP. Omninos Solutions is one of the best APP development Companies that give the services at the cheapest prices.

    ReplyDelete
  6. Casinos near Harrah's Casino & Racetrack in Las Vegas, NV
    동해 출장샵 Casinos 용인 출장마사지 › Casinos Find 상주 출장마사지 Casinos near Harrah's Casino & Racetrack in Las Vegas, NV in real-time and see 진주 출장샵 activity. 포천 출장샵

    ReplyDelete

Malaysia Augmented Reality

Its incredibly difficult to discover the undiscovered. Here will see how I can help you. Cheers - Ajune (comp.utm.my/ajune)
ajune@utm.my. Powered by Blogger.