-
Notifications
You must be signed in to change notification settings - Fork 24
/
matleap.h
executable file
·78 lines (70 loc) · 1.67 KB
/
matleap.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/// @file matleap.h
/// @brief leap motion controller interface
/// @author Jeff Perry <jeffsp@gmail.com>
/// @version 1.0
/// @date 2013-09-12
#ifndef MATLEAP_H
#define MATLEAP_H
#define MAJOR_REVISION 0
#define MINOR_REVISION 7
#include "Leap.h"
#include "mex.h"
namespace matleap
{
/// @brief a leap frame
struct frame
{
int64_t id;
int64_t timestamp;
Leap::PointableList pointables;
Leap::HandList hands;
};
/// @brief leap frame grabber interface
class frame_grabber
{
private:
bool debug;
Leap::Controller controller;
frame current_frame;
public:
/// @brief constructor
frame_grabber ()
: debug (false)
{
// receive frames even when you don't have focus
controller.setPolicyFlags (Leap::Controller::POLICY_BACKGROUND_FRAMES);
}
/// @brief destructor
~frame_grabber ()
{
if (debug)
mexPrintf ("Closing matleap frame grabber\n");
}
/// @brief debug member access
///
/// @param flag turn it on/off
void set_debug (bool flag)
{
if (flag == debug)
return;
if (flag)
mexPrintf ("Setting debug on\n");
debug = flag;
}
/// @brief get a frame from the controller
///
/// @return the frame
const frame &get_frame ()
{
const Leap::Frame &f = controller.frame ();
current_frame.id = f.id ();
if (debug)
mexPrintf ("Got frame with id %d\n", current_frame.id);
current_frame.timestamp = f.timestamp ();
current_frame.pointables = f.pointables ();
current_frame.hands = f.hands ();
return current_frame;
}
};
} // namespace matleap
#endif