本文整理汇总了C++中UserGenerator::GetSkeletonCap方法的典型用法代码示例。如果您正苦于以下问题:C++ UserGenerator::GetSkeletonCap方法的具体用法?C++ UserGenerator::GetSkeletonCap怎么用?C++ UserGenerator::GetSkeletonCap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGenerator
的用法示例。
在下文中一共展示了UserGenerator::GetSkeletonCap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UserCalibration_CalibrationComplete
// Callback: Finished calibration
void XN_CALLBACK_TYPE UserCalibration_CalibrationComplete(xn::SkeletonCapability& capability, XnUserID nId, XnCalibrationStatus eStatus, void* pCookie)
{
XnUInt32 epochTime = 0;
xnOSGetEpochTime(&epochTime);
if (eStatus == XN_CALIBRATION_STATUS_OK)
{
// Calibration succeeded
printf("%d Calibration complete, start tracking user %d\n", epochTime, nId);
g_UserGenerator.GetSkeletonCap().StartTracking(nId);
}
else
{
// Calibration failed
printf("%d Calibration failed for user %d\n", epochTime, nId);
/*if(eStatus==XN_CALIBRATION_STATUS_MANUAL_ABORT)
{
printf("Manual abort occured, stop attempting to calibrate!");
return;
}*/
if (g_bNeedPose)
{
g_UserGenerator.GetPoseDetectionCap().StartPoseDetection(g_strPose, nId);
}
else
{
g_UserGenerator.GetSkeletonCap().RequestCalibration(nId, TRUE);
}
}
}
示例2: getJointPosition
void getJointPosition(XnUserID player, XnSkeletonJoint eJoint1, unsigned char * dest)
{
if (!_userGenerator.GetSkeletonCap().IsTracking(player))
{
printf("not tracked!\n");
return;
}
XnSkeletonJointPosition joint1;
_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, eJoint1, joint1);
if (joint1.fConfidence < 0.5)
{
return;
}
XnPoint3D pt[1];
pt[0] = joint1.position;
_depth.ConvertRealWorldToProjective(1, pt, pt);
float _x, _y, _z;
_x = pt[0].X;
_y = pt[0].Y;
_z = pt[0].Z;
memcpy(dest, &_x, 4);
memcpy(dest+4, &_y, 4);
memcpy(dest+8, &_z, 4);
}
示例3: GetForwardVector
XnVector3D OpenNIUser::GetForwardVector()
{
if( mId )
{
UserGenerator* userGen = _device->getUserGenerator();
// OpenNI's orientation does not work very well.
/*
XnSkeletonJointTransformation t;
m_userGen->GetSkeletonCap().GetSkeletonJoint(userID, XN_SKEL_TORSO, t);
float* e = t.orientation.orientation.elements;
return XV3(e[6], e[7], -e[8]);
*/
XnSkeletonJointPosition p0, p1, p2;
userGen->GetSkeletonCap().GetSkeletonJointPosition( mId, XN_SKEL_RIGHT_SHOULDER, p0 );
userGen->GetSkeletonCap().GetSkeletonJointPosition( mId, XN_SKEL_TORSO, p1 );
userGen->GetSkeletonCap().GetSkeletonJointPosition( mId, XN_SKEL_LEFT_SHOULDER, p2 );
XnVector3D v0(p0.position), v1(p1.position), v2(p2.position);
XnVector3D res1, res2;
res1 = sub( v1, v0 );
res2 = sub( v2, v0 );
XnVector3D res = cross( res1, res2 );
res = normalize( res );
}
return XnVector3D();
}
示例4: isReadyPose
// Detect if hands are forming "Ready Pose"
static bool isReadyPose(){
XnSkeletonJointPosition torso, leftHip, rightHip;
g_user.GetSkeletonCap().GetSkeletonJointPosition(g_userID, XN_SKEL_TORSO, torso);
g_user.GetSkeletonCap().GetSkeletonJointPosition(g_userID, XN_SKEL_LEFT_HIP, leftHip);
g_user.GetSkeletonCap().GetSkeletonJointPosition(g_userID, XN_SKEL_RIGHT_HIP, rightHip);
// Return if hands are within hips ad torso
return IS_BETWEEN(leftHandPosition, leftHip, torso, Y) && IS_BETWEEN(rightHandPosition, rightHip, torso, Y)
&& IS_BETWEEN(leftHandPosition, leftHip, rightHip, X) && IS_BETWEEN(rightHandPosition, leftHip, rightHip, X);
}
开发者ID:nwoedf,项目名称:Chinese-Sign-Language-Recognition-and-Translation-System,代码行数:12,代码来源:UserRecorderProductor.cpp
示例5: loadCalibration
/*
* Function: loadCalibration
*
* Loads a skeletal calibration from a standard file.
* This means that a new user does not need to hold a pose to be tracked.
* The CALIBRATION_FILE macro is defined in monitor.h.
*
* Parameters:
* XnUserID user - The reference to the new user to be calibrated.
*/
void loadCalibration(XnUserID user) {
if( userGenerator.GetSkeletonCap().IsCalibrated(user) ) return;
// Load file
XnStatus status = userGenerator.GetSkeletonCap().
LoadCalibrationDataFromFile(user, CALIBRATION_FILE);
// Start tracking
if( status == XN_STATUS_OK )
userGenerator.GetSkeletonCap().StartTracking(user);
}
示例6: UserPose_PoseDetected
// Callback: Detected a pose
void XN_CALLBACK_TYPE UserPose_PoseDetected(xn::PoseDetectionCapability& capability, const XnChar* strPose, XnUserID nId, void* pCookie)
{
XnUInt32 epochTime = 0;
xnOSGetEpochTime(&epochTime);
printf("%d Pose %s detected for user %d\n", epochTime, strPose, nId);
g_UserGenerator.GetPoseDetectionCap().StopPoseDetection(nId);
g_UserGenerator.GetSkeletonCap().RequestCalibration(nId, TRUE);
}
示例7: GetUpVector
XnVector3D OpenNIUser::GetUpVector()
{
if( mId )
{
UserGenerator* userGen = _device->getUserGenerator();
XnSkeletonJointPosition p0, p1;
userGen->GetSkeletonCap().GetSkeletonJointPosition( mId, XN_SKEL_TORSO, p0 );
userGen->GetSkeletonCap().GetSkeletonJointPosition( mId, XN_SKEL_NECK, p1 );
XnVector3D v0(p0.position), v1(p1.position);
XnVector3D res1 = sub( v1, v0 );
res1 = sub( v1, v0 );
res1 = normalize( res1 );
return res1;
}
return XnVector3D();
}
示例8: UserCalibration_CalibrationEnd
void XN_CALLBACK_TYPE UserCalibration_CalibrationEnd(SkeletonCapability& capability, XnUserID nId, XnBool bSuccess, void* pCookie)
{
if (bSuccess)
{
if(_printUserTracking) printf("AS3OpenNI :: Calibration complete, start tracking user: %d\n", nId);
_userGenerator.GetSkeletonCap().StartTracking(nId);
char cValue[50];
sprintf(cValue, "user_tracking_user_calibration_complete:%d", nId);
if(_useSockets)
{
#if (XN_PLATFORM == XN_PLATFORM_WIN32)
g_AS3Network.sendMessage(1,8,nId);
#else
sendToSocket(USER_TRACKING_SOCKET, cValue);
#endif
}
}
else
{
if(_printUserTracking) printf("AS3OpenNI :: Calibration failed for user: %d\n", nId);
if (_needPose)
{
_userGenerator.GetPoseDetectionCap().StartPoseDetection(_strPose, nId);
}
else
{
_userGenerator.GetSkeletonCap().RequestCalibration(nId, true);
}
char cValue[50];
sprintf(cValue, "user_tracking_user_calibration_failed:%d", nId);
if(_useSockets)
{
#if (XN_PLATFORM == XN_PLATFORM_WIN32)
g_AS3Network.sendMessage(1,9,nId);
#else
sendToSocket(USER_TRACKING_SOCKET, cValue);
#endif
}
}
}
示例9: takeFrame
// Record one frame from data
static void takeFrame(){
SkeletonRawData rawData;
XnSkeletonJointPosition pos_left_elbow, pos_right_elbow, pos_left_shoulder, pos_right_shoulder;
// Capture Data
xnOSMemCopy(&(rawData.leftHand), &(leftHandPosition.position), sizeof(XnPoint3D));
xnOSMemCopy(&(rawData.rightHand), &(rightHandPosition.position), sizeof(XnPoint3D));
g_user.GetSkeletonCap().GetSkeletonJointPosition(g_userID, XN_SKEL_LEFT_ELBOW, pos_left_elbow);
xnOSMemCopy(&(rawData.leftElbow), &(pos_left_elbow.position), sizeof(XnPoint3D));
g_user.GetSkeletonCap().GetSkeletonJointPosition(g_userID, XN_SKEL_RIGHT_ELBOW, pos_right_elbow);
xnOSMemCopy(&(rawData.rightElbow), &(pos_right_elbow.position), sizeof(XnPoint3D));
g_user.GetSkeletonCap().GetSkeletonJointPosition(g_userID, XN_SKEL_LEFT_SHOULDER, pos_left_shoulder);
xnOSMemCopy(&(rawData.leftShoulder), &(pos_left_shoulder.position), sizeof(XnPoint3D));
g_user.GetSkeletonCap().GetSkeletonJointPosition(g_userID, XN_SKEL_RIGHT_SHOULDER, pos_right_shoulder);
xnOSMemCopy(&(rawData.rightShoulder), &(pos_right_shoulder.position), sizeof(XnPoint3D));
rawDatas.push_back(rawData);
}
开发者ID:nwoedf,项目名称:Chinese-Sign-Language-Recognition-and-Translation-System,代码行数:21,代码来源:UserRecorderProductor.cpp
示例10: UserPose_PoseDetected
void XN_CALLBACK_TYPE UserTracker::UserPose_PoseDetected(xn::PoseDetectionCapability& capability, const XnChar* strPose, XnUserID nId, void* pCookie)
{
XnUInt32 epochTime = 0;
xnOSGetEpochTime(&epochTime);
//printf("%d Pose %s detected for user %d\n", epochTime, strPose, nId);
UserGenerator *userGenerator = static_cast<xn::UserGenerator*>(pCookie);
if(userGenerator)
{
userGenerator->GetPoseDetectionCap().StopPoseDetection(nId);
userGenerator->GetSkeletonCap().RequestCalibration(nId, TRUE);
}
}
示例11: getPosition
/*
* Function: getPosition
*
* Returns the Position (enum defined in monitor.h) of the specified user.
* Positions are assigned based on joint locations and defined tolerances.
* Sets the location of the hospital bed if it has not yet been set and the patient
* is lying down.
*
* Parameters:
* XnUserID user - The id for the user whose position to get
*
* Return:
* The Position of the user
*/
Position KinectMonitor::getPosition(XnUserID user) {
XnSkeletonJointPosition headPos, torsoPos, leftPos, rightPos;
double head, torso, center, left, right;
Position position = UNKNOWN;
SkeletonCapability skeleton = userGenerator.GetSkeletonCap();
// Get Joint positions for the specified joint locations
// Joints are XN_SKEL_<option> where <option> is:
// HEAD, NECK, TORSO, WAIST, LEFT_COLLAR, LEFT_SHOULDER, LEFT_ELBOW, LEFT_WRIST, LEFT_HAND
// LEFT_FINGERTIP, RIGHT_COLLAR, RIGHT_SHOULDER, RIGHT_ELBOW, RIGHT_WRIST, RIGHT_HAND,
// RIGHT_FINGERTIP, LEFT_HIP, LEFT_KNEE, LEFT_ANKLE, LEFT_FOOT, RIGHT_HIP, RIGHT_KNEE,
// RIGHT_ANKLE, RIGHT_FOOT
skeleton.GetSkeletonJointPosition(user, XN_SKEL_HEAD, headPos);
skeleton.GetSkeletonJointPosition(user, XN_SKEL_TORSO, torsoPos);
skeleton.GetSkeletonJointPosition(user, XN_SKEL_LEFT_SHOULDER, leftPos);
skeleton.GetSkeletonJointPosition(user, XN_SKEL_RIGHT_SHOULDER, rightPos);
// Get the relevant coordinate for each joint (X, Y, or Z)
head = headPos.position.Z;
torso = torsoPos.position.Z;
center = torsoPos.position.X;
left = leftPos.position.Z;
right = rightPos.position.Z;
// Determine defined positions based on tolerances defined in monitor.h
if(head - LAYING_TOLERANCE > torso) {
position = LAYING;
out = false;
} else if( left < right - TURNED_TOLERANCE ||
left > right + TURNED_TOLERANCE ) {
position = TURNED;
} else {
position = FORWARD;
}
// Set/Check the patient vs the bed location
if( (!bedSet) && position == LAYING ) {
// If the bed location is not yet set, then set the bed at the patients torso X coordinate
bed = center;
bedSet = true;
} else if( bedSet ) {
// The patient is out of bed if they are outside the BED_TOLERANCE defined in monitor.h
out = ( center < bed - BED_TOLERANCE || center > bed + BED_TOLERANCE );
}
return position;
}
示例12: UserPose_PoseDetected
void XN_CALLBACK_TYPE UserPose_PoseDetected(PoseDetectionCapability& capability, const XnChar* strPose, XnUserID nId, void* pCookie)
{
if(_printUserTracking) printf("AS3OpenNI :: Pose %s detected for user: %d\n", strPose, nId);
_userGenerator.GetPoseDetectionCap().StopPoseDetection(nId);
_userGenerator.GetSkeletonCap().RequestCalibration(nId, true);
char cValue[50];
sprintf(cValue, "user_tracking_pose_detected:%d", nId);
if(_useSockets)
{
#if (XN_PLATFORM == XN_PLATFORM_WIN32)
g_AS3Network.sendMessage(1,6,nId);
#else
sendToSocket(USER_TRACKING_SOCKET, cValue);
#endif
}
}
示例13: User_NewUser
void XN_CALLBACK_TYPE UserTracker::User_NewUser(xn::UserGenerator& generator, XnUserID nId, void* pCookie)
{
XnUInt32 epochTime = 0;
xnOSGetEpochTime(&epochTime);
printf("%d New User %d\n", epochTime, nId);
UserGenerator *userGenerator = static_cast<xn::UserGenerator*>(pCookie);
// New user found
if (g_bNeedPose)
{
userGenerator->GetPoseDetectionCap().StartPoseDetection(g_strPose, nId);
}
else
{
if(userGenerator)
userGenerator->GetSkeletonCap().RequestCalibration(nId, TRUE);
}
}
示例14: User_NewUser
void XN_CALLBACK_TYPE User_NewUser(UserGenerator& generator, XnUserID nId, void* pCookie)
{
if(_printUserTracking) printf("AS3OpenNI :: New User: %d\n", nId);
if(_needPose)
{
_userGenerator.GetPoseDetectionCap().StartPoseDetection(_strPose, nId);
}
else
{
_userGenerator.GetSkeletonCap().RequestCalibration(nId, true);
}
char cValue[50];
sprintf(cValue, "user_tracking_new_user:%d", nId);
if(_useSockets)
{
#if (XN_PLATFORM == XN_PLATFORM_WIN32)
g_AS3Network.sendMessage(1,2,nId);
#else
sendToSocket(USER_TRACKING_SOCKET, cValue);
#endif
}
}
示例15: nextFrame
/**
* Method that controls the fireballs that are
* going to be spawned per frames.
*/
void SuperFiremanBrothers :: nextFrame ()
{
if (gameStatus != STARTED) {
return;
}
static int counter = 0;
static int spawnRate = (SPAWN_RATE_FIRST_LEVEL) * players.size();
static float speedRate = (SPEED_RATE_FIRST_LEVEL) * players.size();
static int flamesInLevel = (FLAMES_IN_FIRST_LEVEL) * players.size();
const static int riseSpawnRate = (RISE_SPAWN_RATE) * players.size();
const static int riseSpeedRate = (RISE_SPEED_RATE) * players.size();
const static int riseFlamesInLevel = (RISE_FLAMES_IN_LEVEL) * players.size();
int i;
int j;
int hp;
float x;
float y;
Vector3D position;
vector <ZamusShoot> zShoot;
vector <LinqSpawnIce> lShoot;
zShoot = zamusDetector -> shoots;
lShoot = linqDetector -> iceSpawn;
UserGenerator ugen;
DepthGenerator dgen;
map <XnUserID, int> :: iterator iter;
XnUserID player;
XnSkeletonJointPosition joint;
XnPoint3D foots[2];
ugen = userDetector -> retUserGenerator();
dgen = userDetector -> retDepthGenerator();
for (i = 0; i < fireBalls.size(); i++) {
for (j = 0; j < zShoot.size(); j++) {
if (fireBalls[i].isInBoundingBox(zShoot[j].position)) {
fireBalls[i].extinguish();
players[zShoot[j].player] += POINTS_PER_HIT;
zShoot.erase(zShoot.begin() + j);
j--;
}
}
for (j = 0; j < lShoot.size(); j++) {
if (fireBalls[i].isInBoundingBox(lShoot[j].position)) {
fireBalls[i].extinguish();
players[lShoot[j].player] += POINTS_PER_HIT;
lShoot.erase(lShoot.begin() + j);
j--;
}
}
for (iter = players.begin(); iter != players.end(); iter++) {
player = iter -> first;
ugen.GetSkeletonCap().GetSkeletonJointPosition(player,
XN_SKEL_RIGHT_FOOT,
joint);
foots[0] = joint.position;
ugen.GetSkeletonCap().GetSkeletonJointPosition(player,
XN_SKEL_RIGHT_FOOT,
joint);
foots[1] = joint.position;
dgen.ConvertRealWorldToProjective(2, foots, foots);
if (fireBalls[i].isInBoundingBox(foots[0])) {
fireBalls[i].extinguish();
players[player] += POINTS_PER_HIT;
j--;
}
if (fireBalls[i].isInBoundingBox(foots[1])) {
fireBalls[i].extinguish();
players[player] += POINTS_PER_HIT;
j--;
}
}
zamusDetector -> shoots = zShoot;
linqDetector -> iceSpawn = lShoot;
if (fireBalls[i].getZPos() > FIRE_LIMIT) {
lostGame = true;
return;
}
else {
fireBalls[i].advance(speedRate);
}
}
if ((counter == spawnRate) &&
(numFlames < flamesInLevel)){
x = (float)rand() / (float)RAND_MAX;
//.........这里部分代码省略.........