-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample.cpp
More file actions
53 lines (42 loc) · 1.7 KB
/
Sample.cpp
File metadata and controls
53 lines (42 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/******************************************************************************\
* Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved. *
* Leap Motion proprietary and confidential. Not for distribution. *
* Use subject to the terms of the Leap Motion SDK Agreement available at *
* https://developer.leapmotion.com/sdk_agreement, or another agreement *
* between Leap Motion and you, your company or other organization. *
\******************************************************************************/
#include <iostream>
#include <cstring>
#include "Leap.h"
using namespace Leap;
class SampleListener : public Listener {
public:
virtual void onFrame(const Controller&);
private:
};
void SampleListener::onFrame(const Controller& controller) {
// Get the most recent frame and report some basic information
const Frame frame = controller.frame();
const ImageList images = frame.images();
if (images.count() == 0)
return;
for (int i = 0; i < 2; ++ i) {
const Image image = images[i];
const unsigned char* image_buffer = image.data();
for (int j = 0; j < image.width() * image.height(); ++j)
std::cout << i << " " << j << " " << (int) image_buffer[j] << std::endl;
}
}
int main(int argc, char** argv) {
SampleListener listener;
Controller controller;
//controller.addListener(listener);
if (argc > 1 && strcmp(argv[1], "--bg") == 0)
controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES);
controller.setPolicy(Leap::Controller::POLICY_IMAGES);
std::cout << "Press Enter to quit..." << std::endl;
std::cin.get();
listener.onFrame(controller);
//controller.removeListener(listener);
return 0;
}