genekogan / ofxLeapMotion2

A wrapper for the Leap Motion SDK compatible with Leap 2.0 Beta with skeletal tracking
MIT License
61 stars 33 forks source link

Using camera images #4

Open micuat opened 9 years ago

micuat commented 9 years ago

I don't have time to make a nice API, but I could implement a getImage() function so I'll post it here with some tips:

    void getImage(ofImage& retImage, int index) {
        Frame frame = ourController->frame();

        ImageList images = frame.images();
        if(index >= 0 && index < images.count()) {
            Image image = images[index];

            const unsigned char* image_buffer = image.data();

            //Draw the raw image data as a greyscale bitmap
            ofLogError() << image.width();
            retImage.setFromPixels(image_buffer, image.width(), image.height(), OF_IMAGE_GRAYSCALE);
        }
    }

This should be implemented in onImages() listener instead. Also,

        ourController->setPolicy(Leap::Controller::POLICY_IMAGES);

has to be set to get images, and most importantly, Allow Images has to be enabled in the Leap Motion Control Panel.

nosarious commented 8 years ago

This looks interesting, but could I get a clue as to where to place it within my application? I'm trying to integrate this within open frameworks 0.9.3 and Xcode 7.3

ImanolGo commented 5 years ago

thanks @micuat.

I modified the addon with the code and I'm nicely reading each frame now.