1#ifndef __JBXL_OPENNI_TOOL_H_
2#define __JBXL_OPENNI_TOOL_H_
36 virtual ~COpenNiTool(
void) { free();}
39 COpenNiDevice* device;
40 COpenNiDevice* dev_backup;
45 unsigned int tracking_user;
46 unsigned int tracking_deny;
49 BOOL init(BOOL use_camera);
51 void delete_Device(
void);
53 void clear_JointsData(
void);
54 void clear_JointsPosData(
void);
55 void clear_JointsRotData(
void);
59 void get_JointsPositionData(
unsigned int nId);
60 void get_JointsRotationData(
unsigned int nId);
62 XnVector3D joint_PositionData(
int joint);
63 XnMatrix3X3 joint_RotationData(
int joint);
64 double joint_PositionConfidence(
int joint);
65 double joint_RotationConfidence(
int joint);
69 BOOL start_Detection(
int profile,
double smooth);
70 BOOL stop_Detection(
void);
72 unsigned int get_TrackingUser(
void);
73 void set_DenyTrackingSearch(
unsigned int user);
76 BOOL backupDevice(
void);
77 BOOL restoreDevice(
void);
81 XnVector3D jointPosData[OPENNI_JOINT_NUM];
82 XnMatrix3X3 jointRotData[OPENNI_JOINT_NUM];
83 double jointPosConfidence[OPENNI_JOINT_NUM];
84 double jointRotConfidence[OPENNI_JOINT_NUM];
90 BOOL initDevice(BOOL image) {
if (device!=NULL)
return device->init(image);
else return FALSE;}
91 BOOL initDevice(
char* fname, BOOL image) {
if (device!=NULL)
return device->init(fname, image);
else return FALSE;}
93 BOOL resetDevice(BOOL image) { deleteDepth(); deleteImage(); deletePlayer();
return initDevice(image);}
94 BOOL resetDevice(
char* fname, BOOL image) { deleteDepth(); deleteImage(); deletePlayer();
return initDevice(fname, image);}
96 BOOL hasBackupDev(
void) {
if (dev_backup!=NULL)
return TRUE;
else return FALSE;}
97 void deleteBackupDev(
void) {
if (dev_backup!=NULL) {
delete(dev_backup); dev_backup=NULL;}}
99 int getDevState(
void) {
if (device!=NULL)
return device->m_state;
else return NI_STATE_UNKNOWN;}
100 void setDevState(
int state) {
if (device!=NULL) device->m_state = state;}
102 BOOL hasContext(
void) {
if (device!=NULL && device->context!=NULL)
return TRUE;
else return FALSE;}
103 BOOL hasImageGen(
void) {
if (device!=NULL && device->image!=NULL)
return TRUE;
else return FALSE;}
104 BOOL hasDepthGen(
void) {
if (device!=NULL && device->depth!=NULL)
return TRUE;
else return FALSE;}
105 BOOL hasPlayer(
void) {
if (device!=NULL && device->player!=NULL)
return TRUE;
else return FALSE;}
107 BOOL createContext(
void){
if (device!=NULL)
return device->create_Context();
else return FALSE;}
108 BOOL createImage(
void) {
if (device!=NULL)
return device->create_Image();
else return FALSE;}
109 BOOL createDepth(
void) {
if (device!=NULL)
return device->create_Depth();
else return FALSE;}
110 BOOL createPlayer(
void) {
if (device!=NULL)
return device->create_Player();
else return FALSE;}
112 void deleteContext(
void){
if (device!=NULL) device->delete_Context();}
113 void deleteImage(
void) {
if (device!=NULL) device->delete_Image();}
114 void deleteDepth(
void) {
if (device!=NULL) device->delete_Depth();}
115 void deletePlayer(
void) {
if (device!=NULL) device->delete_Player();}
117 void waitStreamData(
void) {
if (device!=NULL && device->context!=NULL) device->context->WaitAndUpdateAll();}
120 BOOL setImageData(
void)
122 if (device!=NULL && device->image!=NULL && device->imageMD!=NULL) {
123 device->image->GetMetaData(*(device->imageMD));
130 BOOL setDepthData(
void)
132 if (device!=NULL && device->depth!=NULL && device->depthMD!=NULL) {
133 device->depth->GetMetaData(*(device->depthMD));
140 BOOL setSceneData(
void)
142 if (device!=NULL && device->user!=NULL && device->sceneMD!=NULL) {
143 device->user->GetUserPixels(0, *(device->sceneMD));
150 uByte* getImageData(
void)
152 if (device!=NULL && device->imageMD!=NULL)
return (
uByte*)device->imageMD->RGB24Data();
157 uByte* getDepthData(
void)
159 if (device!=NULL && device->depthMD!=NULL)
return (
uByte*)device->depthMD->Data();
164 uByte* getSceneData(
void)
166 if (device!=NULL && device->sceneMD!=NULL)
return (
uByte*)device->sceneMD->Data();
171 BOOL isTracking(
unsigned int user)
173 if (device!=NULL && device->skeleton!=NULL && device->skeleton->IsTracking((XnUserID)user))
return TRUE;
176 void stopTracking(
unsigned int user)
178 if (device!=NULL && device->skeleton!=NULL) device->skeleton->StopTracking((XnUserID)user);
182 void setGlobalMirror(BOOL mirror)
184 if (device!=NULL && device->context!=NULL) device->context->SetGlobalMirror(mirror);
188 int getXSize(
void) {
if (device!=NULL)
return device->m_xsize;
else return 0;}
189 int getYSize(
void) {
if (device!=NULL)
return device->m_ysize;
else return 0;}
190 int getFPS(
void) {
if (device!=NULL)
return device->m_nfps;
else return 0;}
193 void setViewPoint(
void)
195 if (device!=NULL && device->depth!=NULL && device->image!=NULL) {
196 device->depth->GetAlternativeViewPointCap().SetViewPoint(*(device->image));
201 void convertDepth2Image(
int dx,
int dy,
unsigned short dz,
int* ix,
int* iy)
208 void convert2Projective(
unsigned int c, XnPoint3D* a, XnPoint3D* b)
210 if (device!=NULL && device->depth!=NULL) device->depth->ConvertRealWorldToProjective(c, a, b);
214 BOOL startRecorde(
char* file_name, BOOL use_image)
216 if (device!=NULL)
return device->start_Recorde(file_name, use_image);
221 void stopRecorde(
void) { device->stop_Recorde();}
223 void playerSetRepeat(BOOL rep) {
if (device!=NULL && device->player!=NULL) device->player->SetRepeat(rep); }
224 void playerSetSeek(XnInt64 tm) {
if (device!=NULL && device->player!=NULL) device->player->SeekToTimeStamp(tm, XN_PLAYER_SEEK_SET);}
227 BOOL open_USBDevice(
void) {
if (device!=NULL)
return device->open_USB_Device();
else return FALSE;}
228 void close_USBDevice(
void) {
if (device!=NULL) device->close_USB_Device();}
229 void set_LEDColor(
int col) {
if (device!=NULL) device->set_LED_Color(col);}
230 void set_TiltMotor(
int ang) {
if (device!=NULL) device->set_Tilt_Motor(ang);}