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


C++ Context::WaitAnyUpdateAll方法代码示例

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


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

示例1: glutDisplay

// this function is called each frame
void glutDisplay (void)
{
  // Read next available data
  g_Context.WaitAnyUpdateAll();
  // Process the data
  g_pSessionManager->Update(&g_Context);
  
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
  // Setup the OpenGL viewpoint
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  
#ifdef USE_GLUT
  glOrtho(0, GL_WIN_SIZE_X, 0, GL_WIN_SIZE_Y, -1.0, 1.0);
#else
  glOrthof(0, GL_WIN_SIZE_X, 0, GL_WIN_SIZE_Y, -1.0, 1.0);
#endif
  
  glDisable(GL_TEXTURE_2D);
  
  // Draw the TrackPad
  DrowTrackPad();
  
#ifdef USE_GLUT
  glutSwapBuffers();
#endif
}
开发者ID:89grad,项目名称:Fish-Game,代码行数:30,代码来源:main.cpp

示例2: glutDisplay

// this function is called each frame
void glutDisplay (void)
{
    // Read next available data
    g_Context.WaitAnyUpdateAll();

    // Process the data
    g_pSessionManager->Update(&g_Context);

    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Setup the OpenGL viewpoint
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

#ifdef USE_GLUT
    //glOrtho(0, GL_WIN_SIZE_X, 0, GL_WIN_SIZE_Y, -1.0, 1.0);
    glOrtho(0, 1.0, 1.0, 0, -1.0, 1.0);
#else
    //glOrthof(0, GL_WIN_SIZE_X, 0, GL_WIN_SIZE_Y, -1.0, 1.0);
    glOrthof(0, 1.0, 1.0, 0, -1.0, 1.0);
#endif

    // draw
    if (g_bDrawFrame)
    {
        DrawFrame(xnCreatePoint3D(0.0, 0.0, 0), xnCreatePoint3D(1.0, 1.0, 0), 8, g_fFrameR, g_fFrameG, g_fFrameB);
    }

    if (g_bDrawCircle)
    {
        XnV3DVector vec(0.5, 0.5, 0);
        vec += XnV3DVector(sin(g_fCircleAngle), -cos(g_fCircleAngle), 0) * 0.3;
        DrawCircle(xnCreatePoint3D(0.5, 0.5, 0), 0.3, 3, g_fCircleR, g_fCircleG, g_fCircleB);
        DrawLine(xnCreatePoint3D(0.5, 0.5, 0), vec, 4, g_fCircleLineR, g_fCircleLineG, g_fCircleLineB);
    }

    // flip surfaces
#ifdef USE_GLUT
    glutSwapBuffers();
#else
    eglSwapBuffers(display, surface);
#endif
}
开发者ID:ranxian,项目名称:KiNaomatics,代码行数:44,代码来源:main.cpp

示例3: OpenNIThread

void CPNUIPlugin::OpenNIThread(boost::weak_ptr<CPNUIPluginAPI> JSAPI,
	xn::Context& Context)
{
	printf("Started OpenNI thread\n");

	extern boost::weak_ptr<CPNUIPluginAPI> GJSAPI;
	GJSAPI = JSAPI;

	while (!JSAPI.expired())
	{
		XnStatus rc = Context.WaitAnyUpdateAll();
		if (rc != XN_STATUS_OK)
		{
			printf("Read failed: %s\n", xnGetStatusString(rc));
			//m_NUIAvailable = false;
			return;
		}
	}
	printf("JSAPI pointer expired!\n");
}
开发者ID:inequation,项目名称:chromepadder,代码行数:20,代码来源:CPNUIPlugin.cpp

示例4: main


//.........这里部分代码省略.........

	// g_DepthGen.GetAlternativeViewPointCap().SetViewPoint( g_ImageGen );

	g_DepthGen.GetMetaData ( g_DepthMD );
	g_ImageGen.GetMetaData ( g_ImageMD );

	assert ( g_ImageMD.PixelFormat() == XN_PIXEL_FORMAT_RGB24 );
	assert ( g_DepthMD.PixelFormat() == XN_PIXEL_FORMAT_GRAYSCALE_16_BIT );

	// 
	// Create OpenCV Showing Window and Related Data Structures
	// 

	cv::namedWindow ( IMAGE_WIN_NAME, CV_WINDOW_AUTOSIZE );
	cv::namedWindow ( DEPTH_WIN_NAME, CV_WINDOW_AUTOSIZE );

	cv::Mat depthImgMat  ( g_DepthMD.YRes(), g_DepthMD.XRes(), CV_16UC1 );
	cv::Mat depthImgShow ( g_DepthMD.YRes(), g_DepthMD.XRes(), CV_8UC3  );
	cv::Mat colorImgMat  ( g_ImageMD.YRes(), g_ImageMD.XRes(), CV_8UC3 );

#define ARTAG_DEBUG

#ifdef ARTAG_DEBUG
	
	cv::setMouseCallback ( IMAGE_WIN_NAME, ClickOnMouse, 0 );

#endif

	bool flipColor = true;

	// 
	// Start to Loop
	// 

	while ( ctlWndKey != ESC_KEY_VALUE ) 
	{
		// 
		// Try to Get New Frame From Kinect
		// 
	
		nRetVal = g_Context.WaitAnyUpdateAll ();

		g_DepthGen.GetMetaData ( g_DepthMD );
		g_ImageGen.GetMetaData ( g_ImageMD );

		assert ( g_DepthMD.FullXRes() == g_DepthMD.XRes() && g_DepthMD.FullYRes() == g_DepthMD.YRes() );
		assert ( g_ImageMD.FullXRes() == g_ImageMD.XRes() && g_ImageMD.FullYRes() == g_ImageMD.YRes() );

		GlobalUtility::CopyColorRawBufToCvMat8uc3 ( (const XnRGB24Pixel *)(g_ImageMD.Data()), colorImgMat );

#ifdef SHOW_DEPTH_WINDOW

		GlobalUtility::CopyDepthRawBufToCvMat16u  ( (const XnDepthPixel *)(g_DepthMD.Data()), depthImgMat );
		// GlobalUtility::ConvertDepthCvMat16uToYellowCvMat ( depthImgMat, depthImgShow );
		GlobalUtility::ConvertDepthCvMat16uToGrayCvMat ( depthImgMat, depthImgShow );

		cv::imshow ( DEPTH_WIN_NAME, depthImgShow );

#endif

		ctlWndKey = cvWaitKey ( 15 );

		if ( ctlWndKey == 'f' || ctlWndKey == 'F' ) 
		{
			artagHelper.Clear();

			artagHelper.FindMarkerCorners ( (unsigned char *)(g_ImageMD.Data()) );
			artagHelper.PrintMarkerCornersPos2dInCam ();
			extrCalibrator.ExtrCalib ( artagHelper );

			std::cout << "\nKinect Extr Matrix:" << std::endl;
			extrCalibrator.PrintMatrix ( extrCalibrator.GetMatrix ( ExtrCalibrator::EXTR ) );

			std::cout	<< "Reprojection ERROR = " 
						<< extrCalibrator.ComputeReprojectionErr ( artagHelper ) << std::endl
						// << extrCalibrator.ComputeReprojectionErr ( artagHelper.m_MarkerCornerPosCam2d, artagHelper.m_MarkerCornerPos3d, 24 ) << std::endl
						<< "Valid Marker Number = " << artagHelper.GetValidMarkerNumber() << std::endl
						<< std::endl;

			extrCalibrator.SaveMatrix ( ExtrCalibrator::EXTR, KINECT_EXTR_FILE );
		}
		if ( ctlWndKey == 's' || ctlWndKey == 'S' )
		{
			flipColor = !flipColor;
		}

		if ( flipColor ) { 
			cv::cvtColor ( colorImgMat, colorImgMat, CV_RGB2BGR );
		}

		artagHelper.DrawMarkersInCameraImage ( colorImgMat );
		cv::imshow ( IMAGE_WIN_NAME, colorImgMat );
	}

	g_Context.Release ();
	
	system	( "pause" );
	exit	( EXIT_SUCCESS );

}
开发者ID:maddy-z,项目名称:Kinect-Explorer,代码行数:101,代码来源:main.cpp

示例5: draw

/***********************************************************************************
* This routine will draw the scene. This is the OpenGL display function / idle 
function callback routine. There have been additions to this routine (from the depth
map sample). 

a. Along with updating the context, we also update the session manager. 
b. We draw the hand point as well. The hand point is represented using a white
square. 
***********************************************************************************/
void draw(){

	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		//clear the gl buffers
	
	rc = cxt.WaitAnyUpdateAll();								//first update the context - refresh the depth/image data coming from the sensor
	
	if(rc != XN_STATUS_OK){										//if the update failed, i.e. couldn't be read
		printf("\nERROR:Read failed... Quitting!\n");			//print error message
		exit(0);												//exit the program
	}
	else if(inSession){
		
		sessionMgr->Update(&cxt);								//NEW ADDITION - update the session manager
		depthGen.GetMetaData(depthMapMetaData);					//grab the depth map meta data
		long xSize = depthMapMetaData.XRes();					//this meta data will give us the true width
		long ySize = depthMapMetaData.YRes();					//and height of the scene
		long totalSize = xSize * ySize;							//total size of the depth map is gotten this way
	
		const XnDepthPixel*	depthMapData;						//this array will contain the value of depth of each pixel in depth map
		depthMapData = depthMapMetaData.Data();					//this will grab the depth values and store it into the array
			
		int i, j,colorToSet;									//color to set will be calculated for the pixel based on its depth 
		int depth;												//to store the depth at a point
		
		glLoadIdentity();										//set the matrix to an identity matrix
		glOrtho(0, xSize, ySize, 0, -1, 1);						//set the orthogonal view. -1 and 1 define the near and far clip off points along z axis
		

		/************************************** DRAWS THE DEPTH MAP *************************************/

		glBegin(GL_POINTS);										//start the drawing of points
		
		/*
		Note: the depthMapData is a pointer to an array that is linear. It contains integer values of depth in millimeters. This linear array must be imagined
		as a matrix of dimensions --> xSize,ySize
		*/

		for(i = 0;i<xSize;i++)									//this loop will run through width of the depth map
		{
			for(j=0;j<ySize;j++)								//this will run through the height
			{
				depth = depthMapMetaData(i,j);					//get the depth info from the depthMapData.	lvalue is (i*Xmax + j) in order to translate matrix coords to linear ones	
				colorToSet = MAX_COLOR - depth/COLOR_ZONES;
								
				if((depth < DEPTH_THRESH_FAR) && (depth > DEPTH_THRESH_NEAR)) {	//if the current pixel depth is within the threshold limits (acceptable range in millimeters)
					glColor3ub(0,colorToSet,0);					//then paint this pixel
					glVertex3f(i,j,0);	
				}
			}
		}
		glEnd();												//end drawing sequence	
		glBegin(GL_POINTS);
		pixelmap[4][4].g=255;
		for(i = 0;i<xSize;i++)									//this loop will run through width of the depth map
		{
			for(j=0;j<ySize;j++)								//this will run through the height
			{
				
				
				if (pixelmap[i][j].r > 0) {
				glColor3ub(pixelmap[i][j].r,pixelmap[i][j].g, pixelmap[i][j].b);					//then paint this pixel
 				glVertex3f(i,j,0);	
				}
			}
		}
		glEnd();
		/********************************* DRAWS THE HAND POINT ***************************************/
		if(isHandPointNull() == false){
			
			glColor3f(255,255,255);					//set the color to white										
			glBegin(GL_POLYGON);					//start drawing the polygon
			int xCo = handPointCoords.X;			//xCoord of the hand point
			int yCo = handPointCoords.Y;			//yCoord of the hand point
			
			int zCo = handPointCoords.Z;
			
			int size = 4;							//size of this square
			
			glVertex3f(xCo-size,yCo-size,0);		//plot the top left corner
			glVertex3f(xCo+size,yCo-size,0);		//plot the top right corner
			glVertex3f(xCo+size,yCo+size,0);		//plot the bot right corner
			glVertex3f(xCo-size,yCo+size,0);		//plot the bot left corner
			glEnd();								//stop drawing the polygon
			
			//draws a bounding box around the hand using lines
			int boxSize = 200;
			int xBox = handPointCoords.X - boxSize/2;
			int yBox = handPointCoords.Y - boxSize/2;
			//pixelmap[-1][-1].g=233;
			if (zCo < g_dist) {
				glColor3f(255,0,0);
//.........这里部分代码省略.........
开发者ID:robotota,项目名称:edu,代码行数:101,代码来源:Test.cpp

示例6: Context_WaitAnyUpdateAll_wrapped

void Context_WaitAnyUpdateAll_wrapped(xn::Context& self) {
    check( self.WaitAnyUpdateAll() );
}
开发者ID:CaoJohn,项目名称:PyOpenNI,代码行数:3,代码来源:ContextWrapper.cpp

示例7: main

int main() {
	printf("main() START\n");
	signal(SIGINT, onSignalReceived); // hit CTRL-C keys in terminal (2)
	signal(SIGTERM, onSignalReceived); // hit stop button in eclipse CDT (15)

	mapMode.nXRes = XN_VGA_X_RES;
	mapMode.nYRes = XN_VGA_Y_RES;
	mapMode.nFPS = 30;

	CHECK_RC(ctx.Init(), "init");
	CHECK_RC(depthGenerator.Create(ctx), "create depth");
	depthGenerator.SetMapOutputMode(mapMode);

	XnStatus userAvailable = ctx.FindExistingNode(XN_NODE_TYPE_USER, userGenerator);
	if(userAvailable != XN_STATUS_OK) {
		CHECK_RC(userGenerator.Create(ctx), "create user");
	}

	XnCallbackHandle hUserCallbacks, hCalibrationCallbacks, hPoseCallbacks;
	xn::SkeletonCapability skel = userGenerator.GetSkeletonCap();
	CHECK_RC(userGenerator.RegisterUserCallbacks(onUserNew, onUserLost, NULL, hUserCallbacks), "register user");
	CHECK_RC(skel.RegisterCalibrationCallbacks(onCalibrationStart, onCalibrationEnd, NULL, hCalibrationCallbacks), "register calib");
	CHECK_RC(userGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(onPoseDetected, NULL, NULL, hPoseCallbacks), "register pose");

	XnChar poseName[20] = "";
	CHECK_RC(skel.GetCalibrationPose(poseName), "get posename");
	printf("poseName: %s\n", poseName);
	CHECK_RC(skel.SetSkeletonProfile(XN_SKEL_PROFILE_ALL), "set skel profile");
	CHECK_RC(skel.SetSmoothing(0.8), "set smoothing");
//	xnSetMirror(depth, !mirrorMode);

	CHECK_RC(ctx.StartGeneratingAll(), "start generating");

	printf("waitAnyUpdateAll ...\n");
	while(!shouldTerminate) {
		ctx.WaitAnyUpdateAll();
//		depthGenerator.GetMetaData(tempDepthMetaData);

		const XnUInt16 userCount = userGenerator.GetNumberOfUsers();
//		printf("userCount: %i\n", userCount);
		XnUserID aUsers[userCount];
		XnUInt16 nUsers = userCount;
		userGenerator.GetUsers(aUsers, nUsers);
		for (int i = 0; i < nUsers; ++i) {
			XnUserID currentUserId = aUsers[i];
			if (skel.IsTracking(aUsers[i])) {
				XnSkeletonJointPosition joint;
				skel.GetSkeletonJointPosition(currentUserId, XN_SKEL_HEAD, joint);
				XnFloat x = joint.position.X;
				XnFloat y = joint.position.Y;
				XnFloat z = joint.position.Z;
				printf("joint position: %.2f x %.2f x %.2f\n", x, y, z);
				printf("joint.fConfidence: %.2f\n", joint.fConfidence);
			}
		}
	}
	printf("STOP\n");
	CHECK_RC(ctx.StopGeneratingAll(), "stop generating");
	ctx.Shutdown();

	printf("main() END\n");
}
开发者ID:christophpickl,项目名称:ponyo-svn,代码行数:62,代码来源:AppUserTracker.cpp


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