int main (int argc, char * const argv[]) { // OpenNIコンテキストの作成 xn::Context context; xn::EnumerationErrors ctxErrors; XnStatus rc = context.InitFromXmlFile(CONFIG_XML_PATH, &ctxErrors); if (rc != XN_STATUS_OK) { XnChar strError[1024]; ctxErrors.ToString(strError, 1024); std::cout << strError << std::endl; return 1; } // NITEのセッション初期化 XnVSessionManager sessionManager; rc = sessionManager.Initialize(&context, "Wave,Click", "RaiseHand"); if (rc != XN_STATUS_OK) { std::cout << "Error at initialize NITE session" << std::endl; return 1; } // ライセンス情報の表示 xnPrintRegisteredLicenses(); std::cout << "OK!! OpenNI context and NITE session initialized" << std::endl; return 0; }
// we need to programmatically add a license when playing back a recording // file otherwise the skeleton tracker will throw an error and not work void ofxOpenNIContext::addLicense(std::string sVendor, std::string sKey) { XnLicense license = {0}; XnStatus status = XN_STATUS_OK; status = xnOSStrNCopy(license.strVendor, sVendor.c_str(),sVendor.size(), sizeof(license.strVendor)); if(status != XN_STATUS_OK) { printf("ofxOpenNIContext error creating license (vendor)\n"); return; } status = xnOSStrNCopy(license.strKey, sKey.c_str(), sKey.size(), sizeof(license.strKey)); if(status != XN_STATUS_OK) { printf("ofxOpenNIContext error creating license (key)\n"); return; } status = context.AddLicense(license); SHOW_RC(status, "AddLicense"); xnPrintRegisteredLicenses(); }
int main(int argc, char* argv[]) { const char* strVendor = NULL; const char* strKey = NULL; bool bRegister = TRUE; XnBool bVerbose = FALSE; XnBool bList = FALSE; if (argc > 1 && strcmp(argv[1], "-l") == 0) { bList = TRUE; } else { for (int i = 1; i < argc; ++i) { const XnChar* arg = argv[i]; if (arg[0] == '-') { if (arg[2] != '\0') { printUsage(argv[0]); return -1; } switch (arg[1]) { case 'r': bRegister = TRUE; break; case 'u': bRegister = FALSE; break; case 'v': bVerbose = TRUE; break; default: printf("Unknown option: -%c\n", arg[1]); printUsage(argv[0]); return -1; } } else if (strVendor == NULL) { strVendor = arg; } else if (strKey == NULL) { strKey = arg; } else { printUsage(argv[0]); return -1; } } // args for if (strVendor == NULL || strKey == NULL) { printUsage(argv[0]); return -1; } } xnLogInitSystem(); xnLogSetConsoleOutput(bVerbose || bList); xnLogSetSeverityFilter(bVerbose ? XN_LOG_VERBOSE : XN_LOG_WARNING); xnLogSetMaskState(XN_LOG_MASK_ALL, TRUE); XnStatus nRetVal = XN_STATUS_OK; XnLicense license = {0}; if (!bList) { nRetVal = xnOSStrNCopy(license.strVendor, strVendor, strlen(strVendor) + 1, sizeof(license.strVendor)); if (nRetVal != XN_STATUS_OK) { printf("Error: Vendor name is too long (should be up to %u characters).", (unsigned)sizeof(license.strVendor) - 1); return -1; } nRetVal = xnOSStrNCopy(license.strKey, strKey, strlen(strKey) + 1, sizeof(license.strKey)); if (nRetVal != XN_STATUS_OK) { printf("Error: Key is too long (should be up to %u characters).", (unsigned)sizeof(license.strKey) - 1); return -1; } } if (bList) { nRetVal = xnPrintRegisteredLicenses(); } else if (bRegister) { nRetVal = xnRegisterGlobalLicense(&license); } else { nRetVal = xnUnregisterGlobalLicense(&license); } if (nRetVal != XN_STATUS_OK) { printf("Failed: %s\n", xnGetStatusString(nRetVal)); return -1; } if (bVerbose) { printf("Done.\n"); } return 0; }