17COpenNiTool::COpenNiTool(
void)
31BOOL COpenNiTool::init(BOOL use_image)
33 device =
new COpenNi2Device();
34 BOOL ret = device->init(use_image);
37 setGlobalMirror(
TRUE);
50void COpenNiTool::free(
void)
58void COpenNiTool::delete_Device(
void)
68void COpenNiTool::clear_JointsData(
void)
70 clear_JointsPosData();
71 clear_JointsRotData();
75void COpenNiTool::clear_JointsPosData(
void)
77 memset(jointPosData, 0,
sizeof(XnVector3D) *OPENNI_JOINT_NUM);
78 memset(jointPosConfidence, 0,
sizeof(
double)*OPENNI_JOINT_NUM);
82void COpenNiTool::clear_JointsRotData(
void)
84 memset(jointRotData, 0,
sizeof(XnMatrix3X3)*OPENNI_JOINT_NUM);
85 memset(jointRotConfidence, 0,
sizeof(
double)*OPENNI_JOINT_NUM);
89nite::UserData* COpenNiTool::get_Avatar(
unsigned int id)
91 static nite::UserData avatar;
93 if (device!=NULL && device->user!=NULL) {
94 const nite::Array<nite::UserData>& avatars = device->userFrame.getUsers();
95 for (
int i=0; i<avatars.getSize(); i++) {
97 if (
id==(
unsigned int)avatar.getId()) {
112void COpenNiTool::get_JointsPositionData(
unsigned int nId)
114 nite::UserData* avatar = get_Avatar(nId);
116 clear_JointsPosData();
120 const nite::Skeleton& skeelton = avatar->getSkeleton();
122 if (skeelton.getState()==nite::SKELETON_TRACKED) {
123 for (
int j=1; j<OPENNI_JOINT_NUM; j++) {
124 const nite::SkeletonJoint& joint = skeelton.getJoint((nite::JointType)(j-1));
125 const nite::Point3f& position = joint.getPosition();
126 jointPosData[j].X = position.x;
127 jointPosData[j].Y = position.y;
128 jointPosData[j].Z = position.z;
129 jointPosConfidence[j] = joint.getPositionConfidence();
135void COpenNiTool::get_JointsRotationData(
unsigned int nId)
137 memset(jointRotData, 0,
sizeof(XnMatrix3X3)*OPENNI_JOINT_NUM);
138 memset(jointRotConfidence, 0,
sizeof(
double)*OPENNI_JOINT_NUM);
155XnVector3D COpenNiTool::joint_PositionData(
int j)
159 if (j>=0 && j<OPENNI_JOINT_NUM) {
160 vect = jointPosData[j];
163 memset(&vect, 0,
sizeof(XnVector3D));
169XnMatrix3X3 COpenNiTool::joint_RotationData(
int j)
173 if (j>=0 && j<OPENNI_JOINT_NUM) {
174 mtrx = jointRotData[j];
177 memset(&mtrx, 0,
sizeof(XnMatrix3X3));
183double COpenNiTool::joint_PositionConfidence(
int j)
187 if (j>=0 && j<OPENNI_JOINT_NUM) {
188 cnfd = (double)jointPosConfidence[j];
195double COpenNiTool::joint_RotationConfidence(
int j)
199 if (j>=0 && j<OPENNI_JOINT_NUM) {
200 cnfd = (double)jointRotConfidence[j];
211BOOL COpenNiTool::start_Detection(
int profile,
double smooth)
214 copy_s2Buffer(
"WARNING: COpenNiTool:start_Detection detection is already executed", &m_err_mesg);
223 BOOL ret = device->create_User();
224 if (ret) ret = device->setup_Tracking(profile, smooth);
228 device->delete_User();
230 copy_s2Buffer(
"ERROR: COpenNiTool:start_Detection: Myabe NITE is not installed!!", &m_err_mesg);
239BOOL COpenNiTool::stop_Detection(
void)
242 copy_s2Buffer(
"WARNING: COpenNiTool:stop_Detection: detection is already stopped", &m_err_mesg);
248 device->delete_User();
259unsigned int COpenNiTool::get_TrackingUser(
void)
263 if (device!=NULL && device->user!=NULL) {
264 const nite::Array<nite::UserData>& avatars = device->userFrame.getUsers();
267 if (tracking_deny!=0) {
268 for (
int i=0; i<avatars.getSize(); i++) {
269 const nite::UserData& avatar = avatars[i];
270 if (tracking_deny==(
unsigned int)avatar.getId()) {
277 for (
int i=0; i<avatars.getSize(); i++) {
278 int idx = (start + i) % avatars.getSize();
279 const nite::UserData& avatar = avatars[idx];
280 if (avatar.isNew()) {
281 nite::Status nc = device->user->startSkeletonTracking(avatar.getId());
282 if (nc==nite::STATUS_OK)
id = (
unsigned int)avatar.getId();
285 else if (!avatar.isLost()) {
286 id = (
unsigned int)avatar.getId();
295void COpenNiTool::set_DenyTrackingSearch(
unsigned int user)
297 if ((
int)user>0) tracking_deny = user;
298 else tracking_deny = 0;
307BOOL COpenNiTool::backupDevice(
void)
310 device =
new COpenNi2Device();
321BOOL COpenNiTool::restoreDevice(
void)
323 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()