1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/****************************************************************************
* *
* OpenNI 1.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
****************************************************************************/
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnOpenNI.h>
#include <XnLog.h>
//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------
void printUsage(const char* procName)
{
printf("Usage: %s [options] FILE [CONFIG_DIR] (1st form)\n", procName);
printf(" or: %s -l (2nd form)\n", procName);
printf("\n");
printf("In the 1st form, registers or unregisters module FILE with OpenNI. When registering, it\n");
printf("is also possible to provide configuration dir CONFIG_DIR to be passed to that module.\n");
printf("In the 2nd form, lists all registered modules and production nodes.\n");
printf("\n");
printf("Options:\n");
printf("-r Register (default)\n");
printf("-u Unregister\n");
printf("-v Verbose mode\n");
}
int main(XnInt argc, XnChar* argv[])
{
const XnChar* strFilePath = NULL;
const XnChar* strConfigDir = NULL;
XnBool 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 (strFilePath == NULL)
{
strFilePath = arg;
}
else if (strConfigDir == NULL)
{
strConfigDir = arg;
}
else
{
printUsage(argv[0]);
return -1;
}
} // args for
if (strFilePath == NULL)
{
printUsage(argv[0]);
return -1;
}
}
xnLogInitSystem();
xnLogSetConsoleOutput(bVerbose || bList);
xnLogSetMaskMinSeverity(XN_LOG_MASK_ALL, bVerbose ? XN_LOG_VERBOSE : XN_LOG_WARNING);
XnStatus nRetVal = XN_STATUS_OK;
if (bList)
{
nRetVal = xnPrintRegisteredModules();
}
else if (bRegister)
{
nRetVal = xnRegisterModule(strFilePath, strConfigDir);
}
else
{
nRetVal = xnUnregisterModule(strFilePath);
}
if (nRetVal != XN_STATUS_OK)
{
printf("Failed: %s\n", xnGetStatusString(nRetVal));
return -1;
}
if (bVerbose)
{
printf("Done.\n");
}
return 0;
}
|