-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfreenectdevice.h
More file actions
75 lines (59 loc) · 1.32 KB
/
freenectdevice.h
File metadata and controls
75 lines (59 loc) · 1.32 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifdef KINECT1
#ifndef FRENECT_DEVICE_H
#define FRENECT_DEVICE_H
#include <pthread.h>
#include "libfreenect.hpp"
#include <vector>
class Mutex
{
public:
Mutex()
{
pthread_mutex_init(&m_mutex, NULL);
}
void lock()
{
pthread_mutex_lock(&m_mutex);
}
void unlock()
{
pthread_mutex_unlock(&m_mutex);
}
class ScopedLock
{
public:
ScopedLock(Mutex &mutex) : _mutex(mutex)
{
_mutex.lock();
}
~ScopedLock()
{
_mutex.unlock();
}
private:
Mutex &_mutex;
};
private:
pthread_mutex_t m_mutex;
};
class FreenectDevice : public Freenect::FreenectDevice
{
public:
FreenectDevice(freenect_context *_ctx, int _index);
// Do not call directly, even in child
void VideoCallback(void *_rgb, uint32_t timestamp);
// Do not call directly, even in child
void DepthCallback(void *_depth, uint32_t timestamp);
bool getRGB(std::vector<uint8_t> &buffer);
bool getDepth(std::vector<uint16_t> &buffer);
static FreenectDevice* createDevice();
private:
Mutex m_rgb_mutex;
Mutex m_depth_mutex;
std::vector<uint8_t> m_buffer_video;
std::vector<uint16_t> m_buffer_depth;
bool m_new_rgb_frame;
bool m_new_depth_frame;
};
#endif // FRENECT_DEVICE_H
#endif