当前位置: 首页>>代码示例>>C++>>正文


C++ UserGenerator::GetUsers方法代码示例

本文整理汇总了C++中UserGenerator::GetUsers方法的典型用法代码示例。如果您正苦于以下问题:C++ UserGenerator::GetUsers方法的具体用法?C++ UserGenerator::GetUsers怎么用?C++ UserGenerator::GetUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserGenerator的用法示例。


在下文中一共展示了UserGenerator::GetUsers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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");
	}
}
开发者ID:tlrobrn,项目名称:mdpnp-kinect,代码行数:23,代码来源:monitor.cpp

示例2: 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");
				}
		}
  }
}
开发者ID:tlrobrn,项目名称:mdpnp-kinect,代码行数:51,代码来源:monitor.cpp

示例3: getPlayers

	void getPlayers()
	{	
		XnUserID aUsers[MAX_USERS];
		XnUInt16 nUsers = MAX_USERS;
		_userGenerator.GetUsers(aUsers, nUsers);
		
		for (int i = 0; i < nUsers; ++i)
		{
			XnUserID player;
			player = aUsers[i];
	
			// Track each player.
			XnPoint3D com;
			_userGenerator.GetCoM(player, com);
			memcpy(g_ucPlayersBuffer[i].player_id, &player, 4);
			copyNIData(g_ucPlayersBuffer[i].player_data, com.X, com.Y, com.Z);
	
			//if(_printUserTracking) printf("AS3OpenNI :: User Tracking: %f, %f, %f\n", com.X, com.Y, com.Z);
			
			// If a user is being tracked then do this.
			if(_userGenerator.GetSkeletonCap().IsTracking(player))
			{
				memcpy(g_ucSkeletonsBuffer[i].player_id, &player, 4);
				if(_convertRealWorldToProjective)
				{
					getJointPosition(player, XN_SKEL_HEAD, g_ucSkeletonsBuffer[i].head);
					getJointPosition(player, XN_SKEL_NECK, g_ucSkeletonsBuffer[i].neck);
					getJointPosition(player, XN_SKEL_TORSO, g_ucSkeletonsBuffer[i].torso);
					
					getJointPosition(player, XN_SKEL_LEFT_SHOULDER, g_ucSkeletonsBuffer[i].lshoulder);
					getJointPosition(player, XN_SKEL_LEFT_ELBOW, g_ucSkeletonsBuffer[i].lelbow);
					getJointPosition(player, XN_SKEL_LEFT_HAND, g_ucSkeletonsBuffer[i].lhand);

					getJointPosition(player, XN_SKEL_RIGHT_SHOULDER, g_ucSkeletonsBuffer[i].rshoulder);
					getJointPosition(player, XN_SKEL_RIGHT_ELBOW, g_ucSkeletonsBuffer[i].relbow);
					getJointPosition(player, XN_SKEL_RIGHT_HAND, g_ucSkeletonsBuffer[i].rhand);
					
					getJointPosition(player, XN_SKEL_LEFT_HIP, g_ucSkeletonsBuffer[i].lhip);
					getJointPosition(player, XN_SKEL_LEFT_KNEE, g_ucSkeletonsBuffer[i].lknee);
					getJointPosition(player, XN_SKEL_LEFT_FOOT, g_ucSkeletonsBuffer[i].lfoot);

					getJointPosition(player, XN_SKEL_RIGHT_HIP, g_ucSkeletonsBuffer[i].rhip);
					getJointPosition(player, XN_SKEL_RIGHT_KNEE, g_ucSkeletonsBuffer[i].rknee);
					getJointPosition(player, XN_SKEL_RIGHT_FOOT, g_ucSkeletonsBuffer[i].rfoot);
				}
				else
				{
					XnSkeletonJointPosition head, neck, left_shoulder, left_elbow, left_hand, right_shoulder, right_elbow, right_hand;
					XnSkeletonJointPosition torso, left_hip, left_knee, left_foot, right_hip, right_knee, right_foot;
					
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_HEAD, head);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_NECK, neck);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_TORSO, torso);
		
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_LEFT_SHOULDER, left_shoulder);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_LEFT_ELBOW, left_elbow);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_LEFT_HAND, left_hand);
		
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_RIGHT_SHOULDER, right_shoulder);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_RIGHT_ELBOW, right_elbow);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_RIGHT_HAND, right_hand);
		
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_LEFT_HIP, left_hip);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_LEFT_KNEE, left_knee);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_LEFT_FOOT, left_foot);
		
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_RIGHT_HIP, right_hip);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_RIGHT_KNEE, right_knee);
					_userGenerator.GetSkeletonCap().GetSkeletonJointPosition(player, XN_SKEL_RIGHT_FOOT, right_foot);
		
					copyNIData(g_ucSkeletonsBuffer[i].head, head.position.X, head.position.Y, head.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].neck, neck.position.X, neck.position.Y, neck.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].torso, torso.position.X, torso.position.Y, torso.position.Z);
		
					copyNIData(g_ucSkeletonsBuffer[i].lshoulder, left_shoulder.position.X, left_shoulder.position.Y, left_shoulder.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].lelbow, left_elbow.position.X, left_elbow.position.Y, left_elbow.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].lhand, left_hand.position.X, left_hand.position.Y, left_hand.position.Z);
		
					copyNIData(g_ucSkeletonsBuffer[i].rshoulder, right_shoulder.position.X, right_shoulder.position.Y, right_shoulder.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].relbow, right_elbow.position.X, right_elbow.position.Y, right_elbow.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].rhand, right_hand.position.X, right_hand.position.Y, right_hand.position.Z);
		
					copyNIData(g_ucSkeletonsBuffer[i].lhip, left_hip.position.X, left_hip.position.Y, left_hip.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].lknee, left_knee.position.X, left_knee.position.Y, left_knee.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].lfoot, left_foot.position.X, left_foot.position.Y, left_foot.position.Z);
		
					copyNIData(g_ucSkeletonsBuffer[i].rhip, right_hip.position.X, right_hip.position.Y, right_hip.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].rknee, right_knee.position.X, right_knee.position.Y, right_knee.position.Z);
					copyNIData(g_ucSkeletonsBuffer[i].rfoot, right_foot.position.X, right_foot.position.Y, right_foot.position.Z);
				}
			}
		}
	}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:93,代码来源:main.cpp

示例4: reload

bool CVKinectWrapper::reload(){

	if (!started) return false;

	XnStatus rc = XN_STATUS_OK;

	const XnDepthPixel* pDepth;

	// Read a new frame
	rc = g_context.WaitAnyUpdateAll();
	if (rc != XN_STATUS_OK)
	{
		printf("Read failed: %s\n", xnGetStatusString(rc));
		return  false;
	}

	g_depth.GetMetaData(g_depthMD);
	g_image.GetMetaData(g_imageMD);

	pDepth = g_depthMD.Data();

	const XnRGB24Pixel* pImageRow = g_imageMD.RGB24Data();
	const XnDepthPixel* pDepthRow = g_depthMD.Data();


	for (XnUInt y = 0; y < g_imageMD.YRes(); ++y){

		const XnRGB24Pixel* pImage = pImageRow;
		const XnDepthPixel* pDepth = pDepthRow;

		for (XnUInt x = 0; x < g_imageMD.XRes(); ++x, ++pImage,++pDepth){

			_rgbImage->at<Vec3b>(y,x) = Vec3b(pImage->nBlue, pImage->nGreen , pImage->nRed);

			if (*pDepth != 0)

				_rawDepth->at<short>(y,x) = *pDepth;
			else

				_rawDepth->at<short>(y,x) = 0 ;
		}

		pDepthRow += g_depthMD.XRes();
		pImageRow += g_imageMD.XRes();
	}

	double min, max;

    /*
	Mat aux(480,640,CV_8UC3);
	minMaxLoc(*_rawDepth, &min, &max,NULL,NULL);
	_rawDepth->convertTo(*_depthImage, CV_8UC1, 255.0/max);
	cvtColor(*_depthImage,aux,CV_GRAY2BGR);
	_rgbImage->copyTo(*_comboImage);
	aux.copyTo(*_comboImage, *_depthImage);
    */

    // temporary convert to 16bit to 8 bit
	_rawDepth->convertTo(*_depthImage, CV_8UC1, 255.0/1048);
	for(int y=0; y < comboImage->height; y++){
	    for(int x=0; x < comboImage->width; x++){
            // copy 16bit to 2x8 bit RGB
/*            ((u_char * )(comboImage->imageData + y))[x] = 255; // _rawDepth->at<short>(y,x) && 256 ;
            ((u_char * )(comboImage->imageData + y))[x+1] = 255; //_rawDepth->at<short>(y,x) >> 8 ;*/
			_comboImage->at<Vec3b>(y,x) = Vec3b( _rawDepth->at<short>(y,x) & 255, 10*_rawDepth->at<short>(y,x) >> 8, 0);
        }
    }
	//cvtColor(*_depthImage,*_comboImage,CV_GRAY2BGR);

    //skeleton
	char strLabel[50] = "";
	XnUserID aUsers[15];
	XnUInt16 nUsers = 2;
	g_UserGenerator.GetUsers(aUsers, nUsers);
    //printf("number of users %d\n", nUsers);
	XnPoint3D pt[1], p_pt[1];
    user_tracker = false;

	for (int i = 0; i < nUsers; ++i){
        //get active users
        if ( i != nUsers-1){
            continue;
        }

        if (!g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i]))
        {
            printf("not tracked!\n");
            return true;
        }

        user_tracker = true;
        // printf ("active user: %d\n", i);

        XnSkeletonJointPosition Pos;
        // copy skeleton point to float array
        for ( unsigned short j=0; j < ENUM_SKELETON_POINT_SIZE; ++j ) {

            g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(
               aUsers[i], ENUM_SKELETON_POINT[j], Pos);

//.........这里部分代码省略.........
开发者ID:Pajinek,项目名称:kinect-annotation,代码行数:101,代码来源:openni.cpp


注:本文中的UserGenerator::GetUsers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。