Esempio n. 1
0
/**   
	* @fn initKinect
	* Start Kinect
    * This is where you start the kinect and s are checked for connection of the same
    * If you activate the state variables and unicia session for Kinect
    * Starts motion capture
    * The flow of movements
    * It is finished start the kinect once you register a movement with the same
*/
int initKinect()
{
	XnStatus rc = XN_STATUS_OK;
	xn::EnumerationErrors errors;

	rc = g_Context.InitFromXmlFile(SAMPLE_XML_FILE, g_ScriptNode, &errors);
	CHECK_ERRORS(rc, errors, KNT_Msgs[KNT_INIT_FROM_XML_FILE]);
	CHECK_RC(rc, KNT_Msgs[KNT_INIT_FROM_XML]);

	rc = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
	CHECK_RC(rc, KNT_Msgs[KNT_FIND_DEPTH_GEN]);

	// Create and initialize point tracker
	g_pSessionManager = new XnVSessionManager;
	rc = g_pSessionManager->Initialize(&g_Context, "Wave", "RaiseHand");
	if (rc != XN_STATUS_OK)
	{
		printf(KNT_Msgs[KNT_COULD_NOT_INIT_SESSION], xnGetStatusString(rc));
		delete g_pSessionManager;
		return rc;
	}

	g_pSessionManager->RegisterSession(NULL, &SessionStart, &SessionEnd);

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

	// Create and initialize the main slider
	g_pMainSlider = new XnVSelectableSlider1D(3);
	g_pMainSlider->RegisterItemSelect(NULL, &MainSlider_OnSelect);
	g_pMainSlider->RegisterActivate(NULL, &MainSlider_OnActivate);
	g_pMainSlider->RegisterDeactivate(NULL, &MainSlider_OnDeactivate);
	g_pMainSlider->RegisterPrimaryPointCreate(NULL, &MainSlider_OnPrimaryCreate);
	g_pMainSlider->RegisterPrimaryPointDestroy(NULL, &MainSlider_OnPrimaryDestroy);
	g_pMainSlider->RegisterValueChange(NULL, &MainSlider_OnValueChange);
	g_pMainSlider->SetValueChangeOnOffAxis(true);

	// Creat the flow manager
	g_pMainFlowRouter = new XnVFlowRouter;

	// Connect flow manager to the point tracker
	g_pSessionManager->AddListener(g_pMainFlowRouter);

	g_Context.StartGeneratingAll();

	g_init_kinect = true;

	printf(KNT_Msgs[KNT_WAVE_GESTURE]);
	printf(KNT_Msgs[KNT_HIT_ANY_2_EXIT]); 

	return 0;
}
Esempio n. 2
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
}
Esempio n. 3
0
int main(int argc, char ** argv)
{
    XnStatus rc = XN_STATUS_OK;
    xn::EnumerationErrors errors;

    // Configure
    rc = g_Context.InitFromXmlFile(SAMPLE_XML_FILE, g_ScriptNode, &errors);
    if (rc == XN_STATUS_NO_NODE_PRESENT)
    {
        XnChar strError[1024];
        errors.ToString(strError, 1024);
        printf("%s\n", strError);
        return (rc);
    }
    if (rc != XN_STATUS_OK)
    {
        printf("Couldn't initialize from file: %s\n", xnGetStatusString(rc));
        return 1;
    }

    // Create and initialize point tracker
    g_pSessionManager = new XnVSessionManager();
    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);

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

    // init and register circle control
    g_pCircle = new XnVCircleDetector;
    g_pCircle->RegisterCircle(NULL, &CircleCB);
    g_pCircle->RegisterNoCircle(NULL, &NoCircleCB);
    g_pCircle->RegisterPrimaryPointCreate(NULL, &Circle_PrimaryCreate);
    g_pCircle->RegisterPrimaryPointDestroy(NULL, &Circle_PrimaryDestroy);
    g_pSessionManager->AddListener(g_pCircle);

    SetCircle(true, 0);
    SetCircleColor(1,1,1);
    SetCircleLineColor(0.7,0.7,0.7);

    g_Context.StartGeneratingAll();

#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();
    }

    opengles_shutdown(display, surface, context);

    CleanupExit();

#endif
}
Esempio n. 4
0
int main(int argc, char **argv)
{
	XnStatus rc = XN_STATUS_OK;

	rc = g_Context.InitFromXmlFile(SAMPLE_XML_PATH);
	CHECK_RC(rc, "InitFromXml");

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

	// Create and initialize point tracker
	g_pSessionManager = new XnVSessionManager;
	rc = g_pSessionManager->Initialize(&g_Context, "Wave", "RaiseHand");
	if (rc != XN_STATUS_OK)
	{
		printf("Couldn't initialize the Session Manager: %s\n", xnGetStatusString(rc));
		delete g_pSessionManager;
		return rc;
	}

	g_pSessionManager->RegisterSession(NULL, &SessionStart, &SessionEnd);

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

	// Create and initialize the main slider
	g_pMainSlider = new XnVSelectableSlider1D(3);
	g_pMainSlider->RegisterItemHover(NULL, &MainSlider_OnHover);
	g_pMainSlider->RegisterItemSelect(NULL, &MainSlider_OnSelect);
	g_pMainSlider->RegisterActivate(NULL, &MainSlider_OnActivate);
	g_pMainSlider->RegisterDeactivate(NULL, &MainSlider_OnDeactivate);
	g_pMainSlider->RegisterPrimaryPointCreate(NULL, &MainSlider_OnPrimaryCreate);
	g_pMainSlider->RegisterPrimaryPointDestroy(NULL, &MainSlider_OnPrimaryDestroy);
	g_pMainSlider->RegisterValueChange(NULL, &MainSlider_OnValueChange);
	g_pMainSlider->SetValueChangeOnOffAxis(true);

	// Creat the flow manager
	g_pMainFlowRouter = new XnVFlowRouter;

	// Connect flow manager to the point tracker
	g_pSessionManager->AddListener(g_pMainFlowRouter);

	// Create the MyBox objects
	XnPoint3D ptMax, ptMin;
	ptMax.Z = ptMin.Z = 0;
	ptMax.Y = GL_WIN_SIZE_Y-50;
	ptMin.Y = GL_WIN_SIZE_Y-300;

	ptMax.X = 50; ptMin.X = 240;
	g_pBox[0] = new MyBox(ptMax, ptMin);
	ptMax.X = 260; ptMin.X = 450;
	g_pBox[1] = new MyBox(ptMax, ptMin);
	ptMax.X = 470; ptMin.X = 650;
	g_pBox[2] = new MyBox(ptMax, ptMin);

	// Register callback to the MyBox objects for their Leave event.
	g_pBox[0]->RegisterLeave(NULL, &MyBox_Leave);
	g_pBox[1]->RegisterLeave(NULL, &MyBox_Leave);
	g_pBox[2]->RegisterLeave(NULL, &MyBox_Leave);

	g_Context.StartGeneratingAll();

	#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
}