本文整理汇总了C++中UserGenerator类的典型用法代码示例。如果您正苦于以下问题:C++ UserGenerator类的具体用法?C++ UserGenerator怎么用?C++ UserGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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);
}
}
}
示例3: 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);
}
示例4: xnOSGetEpochTime
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);
}
}
示例5: drawGameInfo
/**
* Draw the scores over the users in the game (openGL).
*/
void SuperFiremanBrothers :: drawGameInfo ()
{
float y;
int score;
char strLabel[20] = "";
char strLevel[20] = "";
char strStart[20] = "Calibrate to begin";
char strEnd[20] = "Game Over";
UserGenerator uGen;
DepthGenerator dGen;
XnUserID player;
XnPoint3D com;
map <XnUserID, int> :: iterator iter;
float amb[3] = {1.0, 1.0, 1.0};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, amb);
glDisable(GL_LIGHTING);
y = -768;
uGen = userDetector -> retUserGenerator();
dGen = userDetector -> retDepthGenerator();
for (iter = players.begin(); iter != players.end(); iter++) {
player = iter -> first;
score = iter -> second;
sprintf(strLabel, "Score: %d", score);
uGen.GetCoM(player, com);
dGen.ConvertRealWorldToProjective(1, &com, &com);
glRasterPos3f( com.X + 100, com.Y - 300, com.Z);
glPrintString(GLUT_BITMAP_HELVETICA_18, strLabel);
y += 150;
}
sprintf(strLevel, "Level %d", level);
glRasterPos2f( 500, -768);
glPrintString(GLUT_BITMAP_HELVETICA_18, strLevel);
if (gameStatus == NOT_STARTED) {
glRasterPos2f( 500, 0);
glPrintString(GLUT_BITMAP_HELVETICA_18, strStart);
}
else if (gameStatus > STARTED) {
glRasterPos2f( 500, 0);
glPrintString(GLUT_BITMAP_HELVETICA_18, strEnd);
}
glEnable(GL_LIGHTING);
}
示例6: 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();
}
示例7: lostUser
/*
* Function: lostUser
*
* Gets the number of users remaining (including the lost user).
* If this was the last user, an alert is fired for "Patient not tracked."
*
* Parameters:
* UserGenerator& generator - A reference to the UserGenerator module. Not Used.
* XNUserID nID - The id referring to the lost user.
* void* pCookie
*/
void XN_CALLBACK_TYPE lostUser(UserGenerator &generator,
XnUserID nID, void *pCookie) {
// Get the available users (allowing enough space for up to 15 different users)
XnUInt16 numUsers = 15;
XnUserID users[numUsers];
userGenerator.GetUsers(users, numUsers);
// Raise an alert if there are no users being tracked (meaning we lost the patient).
if( numUsers <= 1) {
printf("Patient not tracked.\n");
}
}
示例8: 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
}
}
示例9: glutDisplay
void glutDisplay (void){
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Setup the OpenGL viewpoint
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
SceneMetaData sceneMD;
DepthMetaData depthMD;
ImageMetaData imageMD;
g_DepthGenerator.GetMetaData(depthMD);
glOrtho(0, depthMD.XRes(), depthMD.YRes(), 0, -1.0, 1.0);
glDisable(GL_TEXTURE_2D);
//XnStatus rc = g_Context.WaitOneUpdateAll(g_DepthGenerator);
XnStatus rc = g_Context.WaitAnyUpdateAll();
CHECK_RC("Wait Data",rc);
g_DepthGenerator.GetMetaData(depthMD);
if(g_UserGenerator.IsValid())
g_UserGenerator.GetUserPixels(0, sceneMD);
g_ImageGenerator.GetMetaData(imageMD);
DrawDepthMap(depthMD, sceneMD);
DrawImage(imageMD);
glutSwapBuffers();
}//glutdisplay
示例10: 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);
}
示例11: 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
示例12: 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);
}
示例13: prepare
XnStatus prepare(char useScene, char useDepth, char useHistogram)
{
//TODO handle possible failures!
if (useDepth)
{
mDepthGen.GetMetaData(depthMD);
nXRes = depthMD.XRes();
nYRes = depthMD.YRes();
pDepth = depthMD.Data();
if (useHistogram)
{
calcHist();
// rewind the pointer
pDepth = depthMD.Data();
}
}
if (useScene)
{
mUserGen.GetUserPixels(0, sceneMD);
nXRes = sceneMD.XRes();
nYRes = sceneMD.YRes();
pLabels = sceneMD.Data();
}
}
示例14: 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
}
}
示例15: run
/*
* Function: run
*
* Starts and continues generating data from the Kinect.
* A loop runs and updates data whenever new data is available from one of the Kinect
* devices, and then the data is processed to check for patient movement.
* The loop is controlled by the "quit" global boolean, which is set to false by the
* signal handler "stop()"
*/
void KinectMonitor::run() {
XnStatus status;
SceneMetaData scene;
DepthMetaData depth;
// Start the device
status = context.StartGeneratingAll();
// Running loop
while( !quit ) {
// Wait for any new incoming data
context.WaitOneUpdateAll(depthGenerator);
// Mark the new frame
xnFPSMarkFrame(&xnFPS);
// Get the depth data from the device
depthGenerator.GetMetaData(depth);
// Get the recognized users
XnUInt16 numUsers = 15;
XnUserID users[numUsers];
userGenerator.GetUsers(users, numUsers);
// Only track the patient if they are alone
if( numUsers != 1) continue;
// Get the user data
userGenerator.GetUserPixels(users[0], scene);
// Update patient position
previous = current;
current = getPosition(users[0]);
// Raise alerts based on the patient's state and position
if( previous != current ) {
if( current == TURNED && out == false ) {
// Patient is turned
printf("Patient getting out of bed.\n");
} else if( out && bedSet ) {
printf("Patient is out of bed.\n");
}
}
}
}