16COpenNiTool::COpenNiTool(
void)
30BOOL COpenNiTool::init(BOOL use_image)
32 device =
new COpenNiDevice();
33 BOOL ret = device->init(use_image);
36 if (device->context!=NULL) device->context->SetGlobalMirror(
TRUE);
49void COpenNiTool::free(
void)
57void COpenNiTool::delete_Device(
void)
67void COpenNiTool::clear_JointsData(
void)
69 clear_JointsPosData();
70 clear_JointsRotData();
74void COpenNiTool::clear_JointsPosData(
void)
76 memset(jointPosData, 0,
sizeof(XnVector3D) *OPENNI_JOINT_NUM);
77 memset(jointPosConfidence, 0,
sizeof(
double)*OPENNI_JOINT_NUM);
81void COpenNiTool::clear_JointsRotData(
void)
83 memset(jointRotData, 0,
sizeof(XnMatrix3X3)*OPENNI_JOINT_NUM);
84 memset(jointRotConfidence, 0,
sizeof(
double)*OPENNI_JOINT_NUM);
92void COpenNiTool::get_JointsPositionData(
unsigned int nId)
94 XnSkeletonJointPosition joint;
97 if (device->skeleton!=NULL) {
98 for (
int j=1; j<OPENNI_JOINT_NUM; j++) {
99 device->skeleton->GetSkeletonJointPosition(nId, (XnSkeletonJoint)j, joint);
100 jointPosData[j] = joint.position;
101 jointPosConfidence[j] = joint.fConfidence;
107void COpenNiTool::get_JointsRotationData(
unsigned int nId)
109 XnSkeletonJointOrientation joint;
112 if (device->skeleton!=NULL) {
113 for (
int j=1; j<OPENNI_JOINT_NUM; j++) {
114 device->skeleton->GetSkeletonJointOrientation(nId, (XnSkeletonJoint)j, joint);
115 jointRotData[j] = joint.orientation;
116 jointRotConfidence[j] = joint.fConfidence;
122XnVector3D COpenNiTool::joint_PositionData(
int j)
126 if (j>=0 && j<OPENNI_JOINT_NUM) {
127 vect = jointPosData[j];
130 memset(&vect, 0,
sizeof(XnVector3D));
136XnMatrix3X3 COpenNiTool::joint_RotationData(
int j)
140 if (j>=0 && j<OPENNI_JOINT_NUM) {
141 mtrx = jointRotData[j];
144 memset(&mtrx, 0,
sizeof(XnMatrix3X3));
150double COpenNiTool::joint_PositionConfidence(
int j)
154 if (j>=0 && j<OPENNI_JOINT_NUM) {
155 cnfd = (double)jointPosConfidence[j];
161double COpenNiTool::joint_RotationConfidence(
int j)
165 if (j>=0 && j<OPENNI_JOINT_NUM) {
166 cnfd = (double)jointRotConfidence[j];
176BOOL COpenNiTool::start_Detection(
int profile,
double smooth)
179 copy_s2Buffer(
"WARNING: COpenNiTool:start_Detection: detection is already executed", &m_err_mesg);
188 BOOL ret = device->create_User();
189 if (ret) ret = device->setup_Tracking(profile, smooth);
190 if (ret) ret = device->setup_CallBacks();
194 device->clear_Skeleton();
195 device->delete_User();
197 copy_s2Buffer(
"ERROR: COpenNiTool:start_Detection: Myabe NITE is not installed!!", &m_err_mesg);
207BOOL COpenNiTool::stop_Detection(
void)
210 copy_s2Buffer(
"WARNING: COpenNiTool:stop_Detection: detection is already stopped", &m_err_mesg);
217 device->clear_Tracking();
218 device->clear_CallBacks();
219 device->clear_Skeleton();
220 device->delete_User();
222 tracking_user = (
unsigned int)0;
223 tracking_deny = (
unsigned int)0;
231unsigned int COpenNiTool::get_TrackingUser(
void)
233 XnUserID
id = (
unsigned int)0;
235 if (device->user!=NULL && device->skeleton!=NULL) {
237 device->user->GetUsers(device->dUsers, device->nUsers);
240 if (tracking_deny!=0) {
241 for (
int i=0; i<device->nUsers; i++) {
242 if (tracking_deny==device->dUsers[i]) {
249 for (
int i=0; i<device->nUsers; i++) {
250 int idx = (start + i) % device->nUsers;
251 if (device->skeleton->IsTracking(device->dUsers[idx])) {
252 id = device->dUsers[idx];
261void COpenNiTool::set_DenyTrackingSearch(
unsigned int user)
263 if ((
int)user>0) tracking_deny = user;
264 else tracking_deny = 0;
273BOOL COpenNiTool::backupDevice(
void)
276 device =
new COpenNiDevice();
287BOOL COpenNiTool::restoreDevice(
void)
289 if (dev_backup==NULL)
return FALSE;
#define NI_STOP_WAIT_TIME
#define NI_STATE_DETECT_EXEC
#define NI_STATE_DETECT_STARTING
#define NI_STATE_DETECT_STOPPED
#define NI_STATE_DETECT_STOPPING
Buffer make_Buffer(int sz)
Buffer型変数のバッファ部をつくり出す.
void free_Buffer(Buffer *buf)
Buffer型変数のバッファ部を解放する
int copy_Buffer(Buffer *src, Buffer *dst)
Buffer型変数 srcから dstへバッファをコピーする.
#define copy_s2Buffer(src, dst)
copy_b2Buffer()