Пример #1
0
void OniTrackApp::setup()
{
	bRemoting = FALSE;
	
	XnStatus rc = context.InitFromXmlFile(SAMPLE_XML_FILE);
	if (rc != XN_STATUS_OK)
	{
		printf("Couldn't initialize: %s\n", xnGetStatusString(rc));
		shutdown();
	}
	
	pSessionGenerator = new XnVSessionManager();
	rc = ((XnVSessionManager*)pSessionGenerator)->Initialize(&context, "Click", "RaiseHand");
	if (rc != XN_STATUS_OK)
	{
		printf("Session Manager couldn't initialize: %s\n", xnGetStatusString(rc));
		delete pSessionGenerator;
		shutdown();
	}
	
	
	context.StartGeneratingAll();
	
	pSessionGenerator->RegisterSession(NULL, &SessionStart, &SessionEnd, &SessionProgress);
	
	
	wc.RegisterWave(NULL, OnWaveCB);
	wc.RegisterPointUpdate(NULL, OnPointUpdate);
	pSessionGenerator->AddListener(&wc);
	
	printf("Please perform focus gesture to start session\n");
	printf("Hit any key to exit\n");
	
}
Пример #2
0
int main(int argc, char ** argv)
{
	XnStatus rc = XN_STATUS_OK;

	// Initialize OpenNI
	rc = g_Context.InitFromXmlFile(SAMPLE_XML_PATH);
	CHECK_RC(rc, "InitFromXmlFile");

	rc = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
	CHECK_RC(rc, "Find depth generator");
	rc = g_Context.FindExistingNode(XN_NODE_TYPE_HANDS, g_HandsGenerator);
	CHECK_RC(rc, "Find hands generator");

	// Create NITE objects
	g_pSessionManager = new XnVSessionManager;
	rc = g_pSessionManager->Initialize(&g_Context, "Click,Wave", "RaiseHand");
	CHECK_RC(rc, "SessionManager::Initialize");

	g_pSessionManager->RegisterSession(NULL, SessionStarting, SessionEnding, NULL);

	g_pDrawer = new XnVPointDrawer(20, g_DepthGenerator);
	g_pFlowRouter = new XnVFlowRouter;
	g_pFlowRouter->SetActive(g_pDrawer);
	g_pSessionManager->AddListener(g_pFlowRouter);

	g_pDrawer->RegisterNoPoints(NULL, NoHands);
	g_pDrawer->SetDepthMap(g_bDrawDepthMap);

	// init & register circle control
	XnVCircleDetector circle;
	circle.RegisterCircle(NULL, OnCircleCB);
	circle.RegisterNoCircle(NULL, OnNoCircleCB);
	g_pSessionManager->AddListener(&circle);

	// init & register swipe control
	XnVSwipeDetector swipe;
	swipe.RegisterSwipeUp(NULL, OnSwipeUpCB);
	swipe.RegisterSwipeDown(NULL, OnSwipeDownCB);
	swipe.RegisterSwipeLeft(NULL, OnSwipeLeftCB);
	swipe.RegisterSwipeRight(NULL, OnSwipeRightCB);
	g_pSessionManager->AddListener(&swipe);

	// init & register wave control
	XnVWaveDetector wave;
	wave.RegisterWave(NULL, OnWaveCB);
	g_pSessionManager->AddListener(&wave);

	// Initialization done. Start generating
	rc = g_Context.StartGeneratingAll();
	CHECK_RC(rc, "StartGenerating");

	// Mainloop
	glInit(&argc, argv);
	glutMainLoop();
}
Пример #3
0
// this sample can run either as a regular sample, or as a client for multi-process (remote mode)
int main(int argc, char** argv)
{  	

  //ros::Subscriber subcommand = rosnode.subscribe("/camera/rgb/image_color", 10, cameracallback);



  	/*ros::Subscriber subcommand = rosnode.subscribe("/camera/depth_registered/image_raw", 10, cameracallback);
  	printf("subscribe get\n");
*/
	xn::Context context;
	xn::ScriptNode scriptNode;
	XnVSessionGenerator* pSessionGenerator;
	XnBool bRemoting = FALSE;

	ros::init(argc, argv, "detect_people", ros::init_options::NoSigintHandler);
  	ros::NodeHandle rosnode = ros::NodeHandle();

	if (argc > 1)
	{
		// remote mode
		context.Init();
		printf("Running in 'Remoting' mode (Section name: %s)\n", argv[1]);
		bRemoting = TRUE;

		// Create multi-process client
		pSessionGenerator = new XnVMultiProcessFlowClient(argv[1]);

		XnStatus rc = ((XnVMultiProcessFlowClient*)pSessionGenerator)->Initialize();
		if (rc != XN_STATUS_OK)
		{
			printf("Initialize failed: %s\n", xnGetStatusString(rc));
			delete pSessionGenerator;
			return 1;
		}
	}
	else
	{
		// Local mode
		// Create context
		const char *fn = NULL;
		if      (fileExists(SAMPLE_XML_FILE)) fn = SAMPLE_XML_FILE;
		else if (fileExists(SAMPLE_XML_FILE_LOCAL)) fn = SAMPLE_XML_FILE_LOCAL;
		else {
			printf("Could not find '%s' nor '%s'. Aborting.\n" , SAMPLE_XML_FILE, SAMPLE_XML_FILE_LOCAL);
			return XN_STATUS_ERROR;
		}
		XnStatus rc = context.InitFromXmlFile(fn, scriptNode);
		if (rc != XN_STATUS_OK)
		{
			printf("Couldn't initialize: %s\n", xnGetStatusString(rc));
			return 1;
		}

		// Create the Session Manager
		pSessionGenerator = new XnVSessionManager();
		rc = ((XnVSessionManager*)pSessionGenerator)->Initialize(&context, "Click", "RaiseHand");
		if (rc != XN_STATUS_OK)
		{
			printf("Session Manager couldn't initialize: %s\n", xnGetStatusString(rc));
			delete pSessionGenerator;
			return 1;
		}

		// Initialization done. Start generating
		context.StartGeneratingAll();
	}

	// Register session callbacks
	pSessionGenerator->RegisterSession(NULL, &SessionStart, &SessionEnd, &SessionProgress);

	// init & register wave control
	XnVWaveDetector wc;
	wc.RegisterWave(NULL, OnWaveCB);
	wc.RegisterPointUpdate(NULL, OnPointUpdate);
	pSessionGenerator->AddListener(&wc);

	printf("Please perform focus gesture to start session\n");
	printf("Hit any key to exit\n");

	// Main loop
	while (!xnOSWasKeyboardHit())
	{
		if (bRemoting)
		{
			((XnVMultiProcessFlowClient*)pSessionGenerator)->ReadState();
		}
		else
		{
			context.WaitAnyUpdateAll();
			((XnVSessionManager*)pSessionGenerator)->Update(&context);
		}
	}

	delete pSessionGenerator;

	return 0;
}
Пример #4
0
// this sample can run either as a regular sample, or as a client for multi-process (remote mode)
int main(int argc, char** argv)
{
	xn::Context context;
	xn::ScriptNode scriptNode;
	XnVSessionGenerator* pSessionGenerator;
	XnBool bRemoting = FALSE;



	if (argc > 1)
	{
		// remote mode
		context.Init();
		printf("Running in 'Remoting' mode (Section name: %s)\n", argv[1]);
		bRemoting = TRUE;

		// Create multi-process client
		pSessionGenerator = new XnVMultiProcessFlowClient(argv[1]);

		XnStatus rc = ((XnVMultiProcessFlowClient*)pSessionGenerator)->Initialize();
		if (rc != XN_STATUS_OK)
		{
			printf("Initialize failed: %s\n", xnGetStatusString(rc));
			delete pSessionGenerator;
			return 1;
		}
	}
	else
	{
		const char *fn = NULL;
		if      (fileExists(SAMPLE_XML_FILE)) fn = SAMPLE_XML_FILE;
		else if (fileExists(SAMPLE_XML_FILE_LOCAL)) fn = SAMPLE_XML_FILE_LOCAL;
		else {
			printf("Could not find '%s' nor '%s'. Aborting.\n" , SAMPLE_XML_FILE, SAMPLE_XML_FILE_LOCAL);
			return XN_STATUS_ERROR;
		}
		XnStatus rc = context.InitFromXmlFile(fn, scriptNode);
		if (rc != XN_STATUS_OK)
		{
			printf("Couldn't initialize: %s\n", xnGetStatusString(rc));
			return 1;
		}

		// Create the Session Manager
		pSessionGenerator = new XnVSessionManager();
		rc = ((XnVSessionManager*)pSessionGenerator)->Initialize(&context, "Click", "RaiseHand");
		if (rc != XN_STATUS_OK)
		{
			printf("Session Manager couldn't initialize: %s\n", xnGetStatusString(rc));
			delete pSessionGenerator;
			return 1;
		}

		// Initialization done. Start generating
		context.StartGeneratingAll();
	}

	// Register session callbacks
	pSessionGenerator->RegisterSession(NULL, &SessionStart, &SessionEnd, &SessionProgress);

	// init & register wave control
	XnVWaveDetector wc;
	wc.RegisterWave(NULL, OnWaveCB);
	wc.RegisterPointUpdate(NULL, OnPointUpdate);
	pSessionGenerator->AddListener(&wc);

	printf("Please perform focus gesture to start session\n");
	printf("Hit any key to exit\n");


	//We initialize our ROS nodes and publishers here
	ros::init(argc, argv, "pointcontrol", ros::init_options::NoSigintHandler);
  	ros::NodeHandle rosnode = ros::NodeHandle();

/*  	ros::Publisher pub = rosnode.advertise<jimmy::pointerpos>("point_location", 10); //publisher for hand XYZ positions
  	jimmy::pointerpos msg;

  	ros::Publisher pub_gestures = rosnode.advertise<jimmy::gestures>("detected_gestures", 10); //publisher for gesture booleans
  	jimmy::gestures msg_gestures;
*/

  	ros::Publisher pub_single_servo = rosnode.advertise<std_msgs::Int16>("single_servo", 10); //publisher for gesture booleans
  	std_msgs::Int16 msg_single_servo;

	// Main loop
	while (!xnOSWasKeyboardHit())
	{
		if (bRemoting)
		{
			((XnVMultiProcessFlowClient*)pSessionGenerator)->ReadState();
		}
		else
		{
			context.WaitAnyUpdateAll();
			((XnVSessionManager*)pSessionGenerator)->Update(&context);

			//fill out the custom message fields with the placeholders we've previously defined
/*			msg.positionx = xpos;
			msg.positiony = ypos;
			msg.positionz = zpos;
			pub.publish(msg);

			msg_gestures.wave = wave;
			msg_gestures.hello = sess_start;
			msg_gestures.goodbye = sess_end;
			pub_gestures.publish(msg_gestures);
*/
			if(wave){
				int num = 1;
				msg_single_servo.data = num;
				pub_single_servo.publish(msg_single_servo);
			}

			//set gesture booleans back to false for re-initialization again
			wave = false;
			sess_start = false;
			sess_end = false;

			ros::spinOnce();
		}
	}

	delete pSessionGenerator;

	return 0;
}
Пример #5
0
int main(int argc, char ** argv)
{
  AllocateAllGlobals();
  init_eventsocket("EVENT_SERVER_IP",8000);

  
  // Initialize the point tracker
  XnStatus rc = g_pSessionManager->Initialize(&g_Context, "Wave", "RaiseHand");
  if (rc != XN_STATUS_OK)
    {
      printf("Couldn't initialize the Session Manager: %s\n", xnGetStatusString(rc));
      CleanupExit();
    }
  g_pSessionManager->RegisterSession(NULL, &SessionStart, &SessionEnd);

  // init & register wave control
  XnVWaveDetector wc;
  wc.RegisterWave(NULL, OnWaveCB);
  g_pSessionManager->AddListener(&wc);
  
  // Add TrackPad to the point tracker
  g_TrackPadHandle = g_pSessionManager->AddListener(g_pTrackPad);
  
  // Register for the Hover event of the TrackPad
  g_nItemHoverHandle = g_pTrackPad->RegisterItemHover(NULL, &TrackPad_ItemHover);
  // Register for the Value Change event of the TrackPad
  g_nValueChangeHandle = g_pTrackPad->RegisterValueChange(NULL, &TrackPad_ValueChange);
  // Register for the Select event of the TrackPad
  g_nItemSelectHandle = g_pTrackPad->RegisterItemSelect(NULL, &TrackPad_ItemSelect);
  
  // Register for Input Start event of the TrackPad
  g_nPrimaryCreateHandle = g_pTrackPad->RegisterPrimaryPointCreate(NULL, &TrackPad_PrimaryCreate);
  // Register for Input Stop event of the TrackPad
  g_nPrimaryDestroyHandle = g_pTrackPad->RegisterPrimaryPointDestroy(NULL, &TrackPad_PrimaryDestroy);

  // Start catching signals for quit indications
  CatchSignals(&g_bQuit);

  
  
#ifdef USE_GLUT
  
  glInit(&argc, argv);
  glutMainLoop();
  
#else
  
  
  if (!opengles_init(GL_WIN_SIZE_X, GL_WIN_SIZE_Y, &display, &surface, &context))
    {
      printf("Error initing opengles\n");
      CleanupExit();
    }
  
  glDisable(GL_DEPTH_TEST);
  //	glEnable(GL_TEXTURE_2D);
  glEnableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
  
  while ((!_kbhit()) && (!g_bQuit))
    {
      glutDisplay();
      eglSwapBuffers(display, surface);
    }
  
  opengles_shutdown(display, surface, context);
  
  CleanupExit();
  
  
#endif
}