本文整理汇总了C++中xn::Context::InitFromXmlFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::InitFromXmlFile方法的具体用法?C++ Context::InitFromXmlFile怎么用?C++ Context::InitFromXmlFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xn::Context
的用法示例。
在下文中一共展示了Context::InitFromXmlFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// 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;
XnStatus rc = XN_STATUS_OK;
xn::EnumerationErrors errors;
rc = g_Context.InitFromXmlFile(SAMPLE_XML_FILE, g_ScripeNode, &errors);
//CHECK_ERRORS(rc, errors, "InitFromXmlFile");
//CHECK_RC(rc, "InitFromXml");
rc = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
//CHECK_RC(rc, "Find depth generator");
rc = g_Context.FindExistingNode(XN_NODE_TYPE_SCENE, g_SceneAnalyzer);
//CHECK_RC(rc, "Find scene analyzer");
rc = g_Context.StartGeneratingAll();
//CHECK_RC(rc, "StartGenerating");
// Main loop
while (!xnOSWasKeyboardHit())
{
}
return 0;
}
示例2: setup
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");
}
示例3: main
int main(int argc, char **argv)
{
XnStatus nRetVal = XN_STATUS_OK;
if (argc > 1)
{
nRetVal = g_Context.Init();
CHECK_RC(nRetVal, "Init");
nRetVal = g_Context.OpenFileRecording(argv[1]);
if (nRetVal != XN_STATUS_OK)
{
printf("Can't open recording %s: %s\n", argv[1], xnGetStatusString(nRetVal));
return 1;
}
}
else
{
nRetVal = g_Context.InitFromXmlFile(SAMPLE_XML_PATH);
CHECK_RC(nRetVal, "InitFromXml");
}
g_tunnel = new Tunnel();
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
CHECK_RC(nRetVal, "Find depth generator");
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
if (nRetVal != XN_STATUS_OK)
{
nRetVal = g_UserGenerator.Create(g_Context);
CHECK_RC(nRetVal, "Find user generator");
}
XnCallbackHandle hUserCallbacks, hCalibrationCallbacks, hPoseCallbacks;
if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON))
{
printf("Supplied user generator doesn't support skeleton\n");
return 1;
}
g_UserGenerator.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
g_UserGenerator.GetSkeletonCap().RegisterCalibrationCallbacks(UserCalibration_CalibrationStart, UserCalibration_CalibrationEnd, NULL, hCalibrationCallbacks);
if (g_UserGenerator.GetSkeletonCap().NeedPoseForCalibration())
{
g_bNeedPose = TRUE;
if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION))
{
printf("Pose required, but not supported\n");
return 1;
}
g_UserGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(UserPose_PoseDetected, NULL, NULL, hPoseCallbacks);
g_UserGenerator.GetSkeletonCap().GetCalibrationPose(g_strPose);
}
g_UserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
nRetVal = g_Context.StartGeneratingAll();
CHECK_RC(nRetVal, "StartGenerating");
glInit(&argc, argv);
glutMainLoop();
}
示例4: AllocateAllGlobals
void AllocateAllGlobals()
{
// Configure
XnStatus rc = g_Context.InitFromXmlFile(SAMPLE_XML_FILE, g_ScriptNode);
if (rc != XN_STATUS_OK)
{
printf("Error initializing: %s\n", xnGetStatusString(rc));
CleanupExit();
}
if(NULL == g_pSessionManager)
{
g_pSessionManager = new XnVSessionManager();
}
if(NULL == g_pSessionManager)
{
printf("Couldn't create PointTracker!! (out of memory)\n");
CleanupExit();
}
if(NULL == g_pTrackPad)
{
g_pTrackPad = new XnVSelectableSlider2D(g_TP_XDim, g_TP_YDim);
}
if(NULL == g_pTrackPad)
{
printf("Couldn't create TrackPad!! (out of memory)\n");
CleanupExit();
}
g_Context.StartGeneratingAll();
}
示例5: main
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();
}
示例6: initKinect
/**
* @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;
}
示例7: main
int main(int argc, char **argv)
{
XnStatus rc = XN_STATUS_OK;
xn::EnumerationErrors errors;
rc = g_Context.InitFromXmlFile(SAMPLE_XML_PATH);
CHECK_ERRORS(rc, errors, "InitFromXmlFile");
CHECK_RC(rc, "InitFromXml");
rc = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
CHECK_RC(rc, "Find depth generator");
rc = g_Context.FindExistingNode(XN_NODE_TYPE_SCENE, g_SceneAnalyzer);
CHECK_RC(rc, "Find scene analyzer");
rc = g_Context.StartGeneratingAll();
CHECK_RC(rc, "StartGenerating");
#ifdef USE_GLUT
glInit(&argc, argv);
glutMainLoop();
#elif defined(USE_GLES)
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
}
示例8: initOpenNI
int initOpenNI(const XnChar* fname) {
XnStatus nRetVal = XN_STATUS_OK;
// initialize context
nRetVal = xnContext.InitFromXmlFile(fname);
CHECK_RC(nRetVal, "InitFromXmlFile");
// initialize depth generator
nRetVal = xnContext.FindExistingNode(XN_NODE_TYPE_DEPTH, xnDepthGenerator);
CHECK_RC(nRetVal, "FindExistingNode(XN_NODE_TYPE_DEPTH)");
// initialize image generator
nRetVal = xnContext.FindExistingNode(XN_NODE_TYPE_IMAGE, xnImgeGenertor);
CHECK_RC(nRetVal, "FindExistingNode(XN_NODE_TYPE_IMAGE)");
return nRetVal;
}
示例9: open
bool open(void)
{
// 途中で初期化に失敗したときに、適切にクリーンアップされるようにすべき
XnStatus status = context_.InitFromXmlFile(Config_file);
if (status != XN_STATUS_OK) {
fprintf(stderr, "InitFromXmlFile() failed.\n");
return false;
}
status = context_.FindExistingNode(XN_NODE_TYPE_DEPTH, depth_);
if (status != XN_STATUS_OK) {
fprintf(stderr, "FindExistingNode() failed.\n");
return false;
}
return true;
}
示例10: xn_init
void xn_init(char *argv)
{
xn_call_and_check(gContext.InitFromXmlFile("../conf/SamplesConfig.xml"), "init from xml");
xn::ImageGenerator image;
xn_call_and_check(gContext.FindExistingNode(XN_NODE_TYPE_IMAGE, image),
"find image node");
xn_call_and_check(gContext.FindExistingNode(XN_NODE_TYPE_DEPTH, gDepthGenerator),
"find depth node");
xn_call_and_check(gContext.FindExistingNode(XN_NODE_TYPE_USER, gUserGenerator),
"find user node");
XnCallbackHandle userCB, poseCB, calibrationCB;
gUserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
gUserGenerator.RegisterUserCallbacks(xn_onFoundUser, xn_onLostUser, NULL, userCB);
gUserGenerator.GetSkeletonCap().RegisterCalibrationCallbacks(NULL, xn_onCalibrated, NULL, calibrationCB);
gUserGenerator.GetSkeletonCap().GetCalibrationPose(gPose);
gUserGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(xn_onPoseDetected, NULL, NULL, poseCB);
gImageDrawer = new ImageDrawer(image);
gImageDrawer->setDrawRegion(WIN_SIZE_X/15, WIN_SIZE_Y/15, WIN_SIZE_X/3, WIN_SIZE_Y/3);
gDepthDrawer = new DepthDrawer(gDepthGenerator, gUserGenerator);
gDepthDrawer->setDrawRegion(0, 0, WIN_SIZE_X, WIN_SIZE_Y);
gSkeletonDrawer = new SkeletonDrawer(gUserGenerator, gDepthGenerator);
gSkeletonDrawer->setDrawRegion(0, 0, WIN_SIZE_X, WIN_SIZE_Y);
capture = new Capture(&gContext);
capture->setFileName(argv);
XnSkeletonJoint joints[] = {
XN_SKEL_HEAD, XN_SKEL_NECK, XN_SKEL_TORSO,
XN_SKEL_LEFT_SHOULDER, XN_SKEL_LEFT_ELBOW, XN_SKEL_LEFT_HAND,
XN_SKEL_RIGHT_SHOULDER, XN_SKEL_RIGHT_ELBOW, XN_SKEL_RIGHT_HAND,
XN_SKEL_LEFT_HIP, XN_SKEL_LEFT_KNEE, XN_SKEL_LEFT_FOOT,
XN_SKEL_RIGHT_HIP, XN_SKEL_RIGHT_KNEE, XN_SKEL_RIGHT_FOOT,
};
for(int i = 0; i < sizeof(joints)/sizeof(XnSkeletonJoint); i++){
capture->addSkeletonJoint(joints[i]);
}
}
示例11: Context_InitFromXmlFile_wrapped
void Context_InitFromXmlFile_wrapped(xn::Context& self, const std::string& initializationFilename) {
#ifdef _DEBUG
PyCout << "Initializing OpenNI.." << std::endl;
#endif
XnStatus returnCode;
returnCode = self.InitFromXmlFile(initializationFilename.c_str());
#ifdef _DEBUG
if (returnCode == XN_STATUS_OK)
PyCout << "OpenNI was initialized successfully" << std::endl;
else {
PyCout << "OpenNI failed to initialize: " <<
xnGetStatusName(returnCode) << std::endl;
}
#endif
return check(returnCode);
}
示例12: main
/***********************************************************************************
* Main routine - additions here also. Session manager and Point control objects
will be initialized and the callbacks assigned
***********************************************************************************/
int main(int argc,char *argv[]){
//------------------ Context initializations go in here ------------------
xn::EnumerationErrors errors;
rc = cxt.InitFromXmlFile(SAMPLE_XML_PATH,&errors); //initialize the context from the xml file
if(rc != XN_STATUS_OK){
printf("Failed to open:%s", xnGetStatusString(rc)); //handle error in reading from XML
return rc;
}
rc = cxt.FindExistingNode(XN_NODE_TYPE_DEPTH,depthGen); //try to find the depth node from the context
if(rc != XN_STATUS_OK){ //handle error if node is not found
printf("Failed to open Depth node!");
return rc;
}
//-------------------- Init Nite objects -----------------------
sessionMgr = new XnVSessionManager(); //session manager is created
rc = sessionMgr->Initialize(&cxt,"Click,Wave","RaiseHand"); //session manager is initialized
if(rc!= XN_STATUS_OK){ //check if this init operation was good
printf("Session manager couldn't be initialized");
return rc;
}
sessionMgr->RegisterSession(&cxt,sessionStart,sessionEnd); //register the callbacks for the session manager
pointCtrl = new XnVPointControl("Point Tracker"); //create the point control object
pointCtrl->RegisterPrimaryPointCreate(&cxt,pointCreate); //register the primary point created handler
pointCtrl->RegisterPrimaryPointUpdate(&cxt,pointUpdate); //register the primary point updated handler
pointCtrl->RegisterPrimaryPointDestroy(&cxt,pointDestroy); //register the primary point destroyed handler
sessionMgr->AddListener(pointCtrl); //make the session manager listen to the point control object
nullifyHandPoint(); //initialize the global variable to track hand points
//----------------- GL initializations go in here --------------
initGraphics(argc,argv); //init GL routine
glutMainLoop(); //start the main loop for openGL
return 0;
}
示例13: configKinect
int configKinect(){
XnStatus rc = XN_STATUS_OK;
xn::EnumerationErrors errors;
// Initialize OpenNI
rc = g_Context.InitFromXmlFile(SAMPLE_XML_PATH, g_ScriptNode, &errors);
CHECK_ERRORS(rc, errors, "InitFromXmlFile");
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_GESTURE, g_GestureGenerator);
CHECK_RC(rc, "Find gesture generator");
XnCallbackHandle hGestureIntermediateStageCompleted, hGestureProgress, hGestureReadyForNextIntermediateStage;
g_GestureGenerator.RegisterToGestureIntermediateStageCompleted(GestureIntermediateStageCompletedHandler, NULL, hGestureIntermediateStageCompleted);
g_GestureGenerator.RegisterToGestureReadyForNextIntermediateStage(GestureReadyForNextIntermediateStageHandler, NULL, hGestureReadyForNextIntermediateStage);
g_GestureGenerator.RegisterGestureCallbacks(NULL, GestureProgressHandler, NULL, hGestureProgress);
// 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, FocusProgress);
pointHandler = new PointHandler(20, g_DepthGenerator);
g_pFlowRouter = new XnVFlowRouter;
g_pFlowRouter->SetActive(pointHandler);
g_pSessionManager->AddListener(g_pFlowRouter);
pointHandler->RegisterNoPoints(NULL, NoHands);
// Initialization done. Start generating
rc = g_Context.StartGeneratingAll();
CHECK_RC(rc, "StartGenerating");
return rc;
}
示例14: main
int main(int argc, char **argv) {
ros::init(argc, argv, "scene_tracker");
ros::NodeHandle nh;
string configFilename = ros::package::getPath("openni_tracker") + "/openni_tracker.xml";
XnStatus nRetVal = g_Context.InitFromXmlFile(configFilename.c_str());
CHECK_RC(nRetVal, "InitFromXml");
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
CHECK_RC(nRetVal, "Find depth generator");
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
if (nRetVal != XN_STATUS_OK) {
nRetVal = g_UserGenerator.Create(g_Context);
CHECK_RC(nRetVal, "Find user generator");
}
XnCallbackHandle hUserCallbacks;
g_UserGenerator.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
nRetVal = g_Context.StartGeneratingAll();
CHECK_RC(nRetVal, "StartGenerating");
ros::Rate r(30);
ros::NodeHandle pnh("~");
string frame_id("openni_depth_frame");
pnh.getParam("camera_frame_id", frame_id);
while (ros::ok()) {
g_Context.WaitAndUpdateAll();
publishTransforms(frame_id);
r.sleep();
}
g_Context.Shutdown();
return 0;
}
示例15: main
int main(int argc, char* argv[])
{
XnStatus rc;
xn::EnumerationErrors errors;
// Create a context with default settings
rc = g_context.InitFromXmlFile(SAMPLE_XML_PATH, g_scriptNode, &errors);
if (rc == XN_STATUS_NO_NODE_PRESENT)
{
XnChar strError[1024];
errors.ToString(strError, 1024);
printf("%s\n", strError);
return (rc);
}
else if (rc != XN_STATUS_OK)
{
printf("Open failed: %s\n", xnGetStatusString(rc));
return (rc);
}
SimpleViewer& viewer = HandViewer::CreateInstance(g_context);
rc = viewer.Init(argc, argv);
if (rc != XN_STATUS_OK)
{
printf("Viewer init failed: %s\n", xnGetStatusString(rc));
return 1;
}
rc = viewer.Run();
if (rc != XN_STATUS_OK)
{
printf("Viewer run failed: %s\n", xnGetStatusString(rc));
return 1;
}
return 0;
}