JunkBox_Lib++ (for Windows) 1.10.1
Loading...
Searching...
No Matches
OpenNiDevice.h
Go to the documentation of this file.
1#ifndef __JBXL_OPENNI_DEV_H_
2#define __JBXL_OPENNI_DEV_H_
3
4#ifdef ENABLE_OPENNI2
5#ifdef ENABLE_OPENNI
6#undef ENABLE_OPENNI
7#endif
8#endif
9
10#ifdef ENABLE_OPENNI
11
12#ifdef WIN32
13#pragma warning(disable:4996)
14#endif
15
16#include <XnCppWrapper.h>
17#include <XnUSB.h>
18
19#include "NiDevice.h"
20#include "common++.h"
21#include "tools++.h"
22#include "buffer.h"
23
24//
25namespace jbxl {
26
27
28class COpenNiDevice
29{
30public:
31 COpenNiDevice(void);
32 virtual ~COpenNiDevice(void) { free();}
33
34 ONI_EnuDev m_enu_dev;
35
36 int m_state;
37 BOOL m_has_camera;
38 Buffer m_err_mesg;
39
40 int m_xsize;
41 int m_ysize;
42 int m_nfps;
43
44 XnStatus rc;
45
46public:
47 BOOL init(BOOL use_image);
48 BOOL init(char* fname, BOOL use_image);
49 void free(void);
50
51 // Generators
52 BOOL create_Context(char* fname=NULL);
53 BOOL create_Image (BOOL easy=FALSE);
54 BOOL create_Depth (BOOL easy=FALSE);
55 BOOL create_User (BOOL easy=FALSE);
56 BOOL create_Player(BOOL easy=FALSE);
57
58 void delete_Context(void);
59 void delete_Image(void);
60 void delete_Depth(void);
61 void delete_User(void);
62 void delete_Player(void);
63
64public:
65 XnMapOutputMode outputMode;
66
67 xn::Context* context;
68 xn::ImageGenerator* image;
69 xn::DepthGenerator* depth;
70 xn::UserGenerator* user;
71 xn::Player* player;
72
73 xn::ImageMetaData* imageMD;
74 xn::DepthMetaData* depthMD;
75 xn::SceneMetaData* sceneMD; // for User
76
77 xn::Recorder* recorder;
78 xn::SkeletonCapability* skeleton;
79
80public:
81 XnUserID dUsers[OPENNI_USERS_NUM];
82 XnUInt16 nUsers;
83
84public:
85 // Capabilities
86 BOOL setup_Tracking(int profile, double smooth);
87 void clear_Skeleton(void);
88 void clear_Tracking(void);
89
90 // File
91 BOOL create_Recorder(char* file_name, BOOL use_image);
92 void delete_Recorder(void);
93
94 BOOL start_Recorde(char* file_name, BOOL use_image);
95 void stop_Recorde(void);
96
97public:
98 // USB
99 XN_USB_DEV_HANDLE usb_dev;
100 XnUSBConnectionString* devPath;
101
102public:
103 // USB
104 BOOL open_USB_Device (void);
105 void close_USB_Device(void);
106 void set_LED_Color (int col);
107 void set_Tilt_Motor(int ang);
108
109public:
110 XnCallbackHandle userCallbacks;
111 XnCallbackHandle poseCallbacks;
112 XnCallbackHandle calibCallbacks;
113
114public:
115 // Call Back
116 BOOL setup_CallBacks(void);
117 void clear_CallBacks(void);
118
119 BOOL set_UserCallbacks(xn::UserGenerator::UserHandler newUser, xn::UserGenerator::UserHandler lostUser, void* cookie);
120 BOOL set_CalibCallbacks(xn::SkeletonCapability::CalibrationStart calibStart, xn::SkeletonCapability::CalibrationEnd calibEnd, void* cookie);
121
122 void unset_UserCallbacks(void);
123 void unset_CalibCallbacks(void);
124};
125
126
127
129// Callback Functions
130
131void XN_CALLBACK_TYPE userDetect(xn::UserGenerator& user, XnUserID nId, void* cookie);
132void XN_CALLBACK_TYPE userLost (xn::UserGenerator& user, XnUserID nId, void* cookie);
133void XN_CALLBACK_TYPE calibStart(xn::SkeletonCapability& skeleton, XnUserID nId, void* cookie);
134void XN_CALLBACK_TYPE calibEnd (xn::SkeletonCapability& skeleton, XnUserID nId, XnBool success, void* cookie);
135
136
137} // namespace
138
139
140#endif
141#endif
142
#define OPENNI_USERS_NUM
Definition NiDevice.h:11
ONI_EnuDev
Definition NiDevice.h:17
Buffer型サポートヘッダ
Common Header for C++.
#define FALSE
Definition common.h:223
Definition Brep.h:29
ツールライブラリ ヘッダ for C++