本文整理汇总了C++中xnGetStatusString函数的典型用法代码示例。如果您正苦于以下问题:C++ xnGetStatusString函数的具体用法?C++ xnGetStatusString怎么用?C++ xnGetStatusString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xnGetStatusString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
XnStatus XnServerSession::HandleGetStringProperty()
{
XnStatus nRetVal = XN_STATUS_OK;
// read it
XnSensorServerMessageGetPropertyRequest request;
XnUInt32 nDataSize = sizeof(request);
nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY, &request, &nDataSize);
XN_IS_STATUS_OK(nRetVal);
if (nDataSize != sizeof(request))
{
XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!");
}
// get
XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH];
XnStatus nActionResult = GetStringPropertyImpl(request.strModuleName, request.strPropertyName, strValue);
if (nActionResult != XN_STATUS_OK)
{
xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to get property '%s.%s': %s", m_nID, request.strModuleName, request.strPropertyName, xnGetStatusString(nActionResult));
}
nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY, nActionResult, sizeof(strValue), strValue);
XN_IS_STATUS_OK(nRetVal);
return (XN_STATUS_OK);
}
示例2: XN_LOG_WARNING_RETURN
XnStatus XnProperty::SetValue(const void* pValue)
{
if (m_pSetCallback == NULL)
{
XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_PROPERTY_READ_ONLY, XN_MASK_DDK, "Property %s.%s is read only.", GetModule(), GetName());
}
if (m_LogSeverity != -1)
{
XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH];
if (ConvertValueToString(strValue, pValue))
{
xnLogWrite(XN_MASK_DDK, (XnLogSeverity)m_LogSeverity, __FILE__, __LINE__, "Setting %s.%s to %s...", GetModule(), GetName(), strValue);
}
else
{
xnLogWrite(XN_MASK_DDK, (XnLogSeverity)m_LogSeverity, __FILE__, __LINE__, "Setting %s.%s...", GetModule(), GetName());
}
}
if (!m_bAlwaysSet && IsActual() && IsEqual(m_pValueHolder, pValue))
{
xnLogWrite(XN_MASK_DDK, (XnLogSeverity)m_LogSeverity, __FILE__, __LINE__, "%s.%s value did not change.", GetModule(), GetName());
}
else
{
XnStatus nRetVal = CallSetCallback(m_pSetCallback, pValue, m_pSetCallbackCookie);
if (nRetVal != XN_STATUS_OK)
{
if (m_LogSeverity != -1)
{
xnLogWrite(XN_MASK_DDK, (XnLogSeverity)m_LogSeverity, __FILE__, __LINE__, "Failed setting %s.%s: %s", GetModule(), GetName(), xnGetStatusString(nRetVal));
}
return (nRetVal);
}
else
{
xnLogWrite(XN_MASK_DDK, (XnLogSeverity)m_LogSeverity, __FILE__, __LINE__, "%s.%s was successfully set.", GetModule(), GetName());
}
}
return (XN_STATUS_OK);
}
示例3: main
int main (int argc, char * argv[])
{
IplImage* camera = 0;
try {
// コンテキストの初期化
xn::Context context;
XnStatus rc = context.InitFromXmlFile(CONFIG_XML_PATH);
if (rc != XN_STATUS_OK) {
throw std::runtime_error(xnGetStatusString(rc));
}
// 鏡モード(反転)にする
context.SetGlobalMirror(TRUE);
// イメージジェネレータの作成
xn::ImageGenerator image;
rc = context.FindExistingNode(XN_NODE_TYPE_IMAGE, image);
if (rc != XN_STATUS_OK) {
throw std::runtime_error(xnGetStatusString(rc));
}
// デプスジェネレータの作成
xn::DepthGenerator depth;
rc = context.FindExistingNode(XN_NODE_TYPE_DEPTH, depth);
if (rc != XN_STATUS_OK) {
throw std::runtime_error(xnGetStatusString(rc));
}
// デプスの座標をイメージに合わせる
depth.GetAlternativeViewPointCap().SetViewPoint(image);
// ユーザーの作成
xn::UserGenerator user;
rc = context.FindExistingNode( XN_NODE_TYPE_USER, user );
if ( rc != XN_STATUS_OK ) {
rc = user.Create(context);
if ( rc != XN_STATUS_OK ) {
throw std::runtime_error( xnGetStatusString( rc ) );
}
}
// ユーザー検出機能をサポートしているか確認
if (!user.IsCapabilitySupported(XN_CAPABILITY_SKELETON)) {
throw std::runtime_error("ユーザー検出をサポートしてません");
}
XnCallbackHandle userCallbacks, calibrationCallbacks, poseCallbacks;
XnChar pose[20] = "";
// キャリブレーションにポーズが必要
xn::SkeletonCapability skelton = user.GetSkeletonCap();
if (skelton.NeedPoseForCalibration()) {
// ポーズ検出のサポートチェック
if (!user.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION)) {
throw std::runtime_error("ポーズ検出をサポートしてません");
}
// キャリブレーションポーズの取得
skelton.GetCalibrationPose(pose);
// ポーズ検出のコールバックを登録
xn::PoseDetectionCapability pose = user.GetPoseDetectionCap();
pose.RegisterToPoseCallbacks(&::PoseDetected, &::PoseLost,
&user, poseCallbacks);
}
// ユーザー認識のコールバックを登録
user.RegisterUserCallbacks(&::UserDetected, &::UserLost, pose,
userCallbacks);
// キャリブレーションのコールバックを登録
skelton.RegisterCalibrationCallbacks(&::CalibrationStart, &::CalibrationEnd,
&user, calibrationCallbacks);
// ユーザートラッキングで、すべてをトラッキングする
skelton.SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
// ジェスチャー検出の開始
context.StartGeneratingAll();
// カメラサイズのイメージを作成(8bitのRGB)
XnMapOutputMode outputMode;
image.GetMapOutputMode(outputMode);
camera = ::cvCreateImage(cvSize(outputMode.nXRes, outputMode.nYRes),
IPL_DEPTH_8U, 3);
if (!camera) {
throw std::runtime_error("error : cvCreateImage");
}
// 表示状態
bool isShowImage = true;
bool isShowUser = true;
bool isShowSkelton = true;
// 描画状態
static enum State{
IDLE = 0,
CIRCLE,
//.........这里部分代码省略.........
示例4: main
int main(int argc, char **argv) {
ros::init(argc, argv, "PersonTracker");
ros::NodeHandle nh;
ros::Rate loop_rate(10);
ROS_INFO("Initalizing Arm Connection....");
ros::Publisher leftArmPublisher = nh.advertise<prlite_kinematics::SphereCoordinate>("/armik/n0/position", 1000);
ros::Publisher rightArmPublisher = nh.advertise<prlite_kinematics::SphereCoordinate>("/armik/n1/position", 1000);
yourmom = nh.advertise<prlite_kinematics::some_status_thing>("kinect_hack_status", 1000);
ros::Duration(2.0).sleep();
prlite_kinematics::SphereCoordinate coord;
prlite_kinematics::some_status_thing status;
coord.radius = 35.0;
coord.phi = 0.0;
coord.theta = 0.0;
status.lulz = 0; //initialized/reset
yourmom.publish(status);
leftArmPublisher.publish(coord);
rightArmPublisher.publish(coord);
ROS_INFO("Initalizing Kinect + NITE....");
XnStatus nRetVal = XN_STATUS_OK;
xn::EnumerationErrors errors;
nRetVal = g_Context.InitFromXmlFile(SAMPLE_XML_PATH, &errors);
if (nRetVal == XN_STATUS_NO_NODE_PRESENT)
{
XnChar strError[1024];
errors.ToString(strError, 1024);
printf("%s\n", strError);
return (nRetVal);
} else if (nRetVal != XN_STATUS_OK) {
printf("Open failed: %s\n", xnGetStatusString(nRetVal));
return (nRetVal);
}
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");
ROS_INFO("Ready To Go!\n");
while (ros::ok()) {
// Update OpenNI
g_Context.WaitAndUpdateAll();
xn::SceneMetaData sceneMD;
xn::DepthMetaData depthMD;
g_DepthGenerator.GetMetaData(depthMD);
g_UserGenerator.GetUserPixels(0, sceneMD);
// Print positions
XnUserID aUsers[15];
XnUInt16 nUsers = 15;
g_UserGenerator.GetUsers(aUsers, nUsers);
for (int i = 0; i < nUsers; ++i) {
if(g_UserGenerator.GetSkeletonCap().IsTracking(aUsers[i])) {
// Read joint positions for person (No WRISTs)
XnSkeletonJointPosition torsoPosition, lShoulderPosition, rShoulderPosition, neckPosition, headPosition, lElbowPosition, rElbowPosition;
XnSkeletonJointPosition rWristPosition, lWristPosition, rHipPosition, lHipPosition, lKneePosition, rKneePosition;
XnSkeletonJointPosition lFootPosition, rFootPosition;
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_TORSO, torsoPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_NECK, neckPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_HEAD, headPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_SHOULDER, lShoulderPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_SHOULDER, rShoulderPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_ELBOW, lElbowPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_ELBOW, rElbowPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_HAND, lWristPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_HAND, rWristPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_HIP, lHipPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_HIP, rHipPosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_LEFT_KNEE, lKneePosition);
g_UserGenerator.GetSkeletonCap().GetSkeletonJointPosition(aUsers[i], XN_SKEL_RIGHT_KNEE, rKneePosition);
//.........这里部分代码省略.........
示例5: 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], g_Player);
if (nRetVal != XN_STATUS_OK)
{
printf("Can't open recording %s: %s\n", argv[1], xnGetStatusString(nRetVal));
return 1;
}
}
else
{
xn::EnumerationErrors errors;
nRetVal = g_Context.InitFromXmlFile(SAMPLE_XML_PATH, g_scriptNode, &errors);
if (nRetVal == XN_STATUS_NO_NODE_PRESENT)
{
XnChar strError[1024];
errors.ToString(strError, 1024);
printf("%s\n", strError);
return (nRetVal);
}
else if (nRetVal != XN_STATUS_OK)
{
printf("Open failed: %s\n", xnGetStatusString(nRetVal));
return (nRetVal);
}
}
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
if (nRetVal != XN_STATUS_OK)
{
printf("No depth generator found. Using a default one...");
xn::MockDepthGenerator mockDepth;
nRetVal = mockDepth.Create(g_Context);
CHECK_RC(nRetVal, "Create mock depth");
// set some defaults
XnMapOutputMode defaultMode;
defaultMode.nXRes = 320;
defaultMode.nYRes = 240;
defaultMode.nFPS = 30;
nRetVal = mockDepth.SetMapOutputMode(defaultMode);
CHECK_RC(nRetVal, "set default mode");
// set FOV
XnFieldOfView fov;
fov.fHFOV = 1.0225999419141749;
fov.fVFOV = 0.79661567681716894;
nRetVal = mockDepth.SetGeneralProperty(XN_PROP_FIELD_OF_VIEW, sizeof(fov), &fov);
CHECK_RC(nRetVal, "set FOV");
XnUInt32 nDataSize = defaultMode.nXRes * defaultMode.nYRes * sizeof(XnDepthPixel);
XnDepthPixel* pData = (XnDepthPixel*)xnOSCallocAligned(nDataSize, 1, XN_DEFAULT_MEM_ALIGN);
nRetVal = mockDepth.SetData(1, 0, nDataSize, pData);
CHECK_RC(nRetVal, "set empty depth map");
g_DepthGenerator = mockDepth;
}
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, hCalibrationStart, hCalibrationComplete, hPoseDetected, hCalibrationInProgress, hPoseInProgress;
if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON))
{
printf("Supplied user generator doesn't support skeleton\n");
return 1;
}
nRetVal = g_UserGenerator.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
CHECK_RC(nRetVal, "Register to user callbacks");
nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationStart(UserCalibration_CalibrationStart, NULL, hCalibrationStart);
CHECK_RC(nRetVal, "Register to calibration start");
nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationComplete(UserCalibration_CalibrationComplete, NULL, hCalibrationComplete);
CHECK_RC(nRetVal, "Register to calibration complete");
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;
}
nRetVal = g_UserGenerator.GetPoseDetectionCap().RegisterToPoseDetected(UserPose_PoseDetected, NULL, hPoseDetected);
CHECK_RC(nRetVal, "Register to Pose Detected");
g_UserGenerator.GetSkeletonCap().GetCalibrationPose(g_strPose);
nRetVal = g_UserGenerator.GetPoseDetectionCap().RegisterToPoseInProgress(MyPoseInProgress, NULL, hPoseInProgress);
CHECK_RC(nRetVal, "Register to pose in progress");
}
//.........这里部分代码省略.........
示例6: XnDeviceManagerLoadAllDevices
XnStatus XnDeviceManagerLoadAllDevices(const XnChar* strDir)
{
XnStatus nRetVal = XN_STATUS_OK;
XnChar cpSearchString[XN_FILE_MAX_PATH] = "";
if (strDir == NULL)
{
strDir = XN_FILE_LOCAL_DIR;
}
// Build the search pattern string
XN_VALIDATE_STR_APPEND(cpSearchString, strDir, XN_FILE_MAX_PATH, nRetVal);
XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_DIR_SEP, XN_FILE_MAX_PATH, nRetVal);
XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_PREFIX, XN_FILE_MAX_PATH, nRetVal);
XN_VALIDATE_STR_APPEND(cpSearchString, XN_DEVICE_FILE_PREFIX, XN_FILE_MAX_PATH, nRetVal);
XN_VALIDATE_STR_APPEND(cpSearchString, XN_FILE_ALL_WILDCARD, XN_FILE_MAX_PATH, nRetVal);
XN_VALIDATE_STR_APPEND(cpSearchString, XN_SHARED_LIBRARY_POSTFIX, XN_FILE_MAX_PATH, nRetVal);
// Get a file list of Xiron devices
XnChar acsFileList[XN_DEVICE_MANAGER_MAX_NUMBER_OF_DEVICES][XN_FILE_MAX_PATH];
XnUInt32 nFileCount = 0;
xnLogVerbose(XN_MASK_DEVICE_MANAGER, "Searching for %s...", cpSearchString);
nRetVal = xnOSGetFileList(cpSearchString, NULL, acsFileList, XN_DEVICE_MANAGER_MAX_NUMBER_OF_DEVICES, &nFileCount);
if ((nRetVal != XN_STATUS_OS_FILE_NOT_FOUND) && (nRetVal != XN_STATUS_OK))
{
return (nRetVal);
}
// now try to load each file
for (XnUInt32 nIndex = 0; nIndex < nFileCount; ++nIndex)
{
xnLogVerbose(XN_MASK_DEVICE_MANAGER, "Trying to load a device '%s'...", acsFileList[nIndex]);
nRetVal = XnDeviceManagerLoadDevice(acsFileList[nIndex], &g_pDeviceManager->aDevices[g_pDeviceManager->nDevicesCount]);
if (nRetVal != XN_STATUS_OK)
{
xnLogWarning(XN_MASK_DEVICE_MANAGER, "'%s' is not a valid device: %s", acsFileList[nIndex], xnGetStatusString(nRetVal));
}
else
{
xnLogInfo(XN_MASK_DEVICE_MANAGER, "device '%s' loaded.", acsFileList[nIndex]);
g_pDeviceManager->nDevicesCount++;
}
}
return (XN_STATUS_OK);
}
示例7: xnLogVerbose
OniStatus Context::initialize()
{
XnBool repositoryOverridden = FALSE;
XnChar repositoryFromINI[XN_FILE_MAX_PATH] = {0};
m_initializationCounter++;
if (m_initializationCounter > 1)
{
xnLogVerbose(XN_MASK_ONI_CONTEXT, "Initialize: Already initialized");
return ONI_STATUS_OK;
}
XnStatus rc;
XnChar strModulePath[XN_FILE_MAX_PATH];
rc = xnOSGetModulePathForProcAddress(reinterpret_cast<void*>(&dummyFunctionToTakeAddress), strModulePath);
if (rc != XN_STATUS_OK)
{
m_errorLogger.Append("Couldn't get the OpenNI shared library module's path: %s", xnGetStatusString(rc));
return OniStatusFromXnStatus(rc);
}
XnChar strBaseDir[XN_FILE_MAX_PATH];
rc = xnOSGetDirName(strModulePath, strBaseDir, XN_FILE_MAX_PATH);
if (rc != XN_STATUS_OK)
{
// Very unlikely to happen, but just in case.
m_errorLogger.Append("Couldn't get the OpenNI shared library module's directory: %s", xnGetStatusString(rc));
return OniStatusFromXnStatus(rc);
}
s_valid = TRUE;
// Read configuration file
XnChar strOniConfigurationFile[XN_FILE_MAX_PATH];
XnBool configurationFileExists = FALSE;
// Search the module directory for OpenNI.ini.
xnOSStrCopy(strOniConfigurationFile, strBaseDir, XN_FILE_MAX_PATH);
rc = xnOSAppendFilePath(strOniConfigurationFile, ONI_CONFIGURATION_FILE, XN_FILE_MAX_PATH);
if (rc == XN_STATUS_OK)
{
xnOSDoesFileExist(strOniConfigurationFile, &configurationFileExists);
}
#ifdef ONI_PLATFORM_ANDROID_OS
xnLogSetMaskMinSeverity(XN_LOG_MASK_ALL, (XnLogSeverity)0);
xnLogSetAndroidOutput(TRUE);
#endif
if (configurationFileExists)
{
// First, we should process the log related configuration as early as possible.
XnInt32 nValue;
XnChar strLogPath[XN_FILE_MAX_PATH] = {0};
//Test if log redirection is needed
rc = xnOSReadStringFromINI(strOniConfigurationFile, "Log", "LogPath", strLogPath, XN_FILE_MAX_PATH);
if (rc == XN_STATUS_OK)
{
rc = xnLogSetOutputFolder(strLogPath);
if (rc != XN_STATUS_OK)
{
xnLogWarning(XN_MASK_ONI_CONTEXT, "Failed to set log output folder: %s", xnGetStatusString(rc));
}
else
{
xnLogVerbose(XN_MASK_ONI_CONTEXT, "Log directory redirected to: %s", strLogPath);
}
}
rc = xnOSReadIntFromINI(strOniConfigurationFile, "Log", "Verbosity", &nValue);
if (rc == XN_STATUS_OK)
{
xnLogSetMaskMinSeverity(XN_LOG_MASK_ALL, (XnLogSeverity)nValue);
}
rc = xnOSReadIntFromINI(strOniConfigurationFile, "Log", "LogToConsole", &nValue);
if (rc == XN_STATUS_OK)
{
xnLogSetConsoleOutput(nValue == 1);
}
rc = xnOSReadIntFromINI(strOniConfigurationFile, "Log", "LogToFile", &nValue);
if (rc == XN_STATUS_OK)
{
xnLogSetFileOutput(nValue == 1);
}
// Then, process the other device configurations.
rc = xnOSReadStringFromINI(strOniConfigurationFile, "Device", "Override", m_overrideDevice, XN_FILE_MAX_PATH);
if (rc != XN_STATUS_OK)
{
xnLogVerbose(XN_MASK_ONI_CONTEXT, "No override device in configuration file");
}
rc = xnOSReadStringFromINI(strOniConfigurationFile, "Drivers", "Repository", repositoryFromINI, XN_FILE_MAX_PATH);
//.........这里部分代码省略.........
示例8: XN_IS_STATUS_OK
XnStatus XnServerSession::HandleReadStream()
{
XnStatus nRetVal = XN_STATUS_OK;
// read it
XnChar strStreamName[XN_DEVICE_MAX_STRING_LENGTH];
XnUInt32 nDataSize = XN_DEVICE_MAX_STRING_LENGTH;
nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_READ_STREAM, strStreamName, &nDataSize);
XN_IS_STATUS_OK(nRetVal);
XnSensorServerReadReply reply;
XnStatus nActionResult = ReadStreamImpl(strStreamName, &reply);
if (nActionResult == XN_STATUS_OK)
{
m_pLogger->DumpMessage("Data", sizeof(reply), 0, strStreamName);
nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_READ_STREAM, XN_STATUS_OK, sizeof(reply), &reply);
XN_IS_STATUS_OK(nRetVal);
}
else
{
xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to read stream '%s': %s", m_nID, strStreamName, xnGetStatusString(nActionResult));
nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult);
XN_IS_STATUS_OK(nRetVal);
}
return (XN_STATUS_OK);
}
示例9: xnLogVerbose
XnStatus XnServerSession::HandleCloseSession()
{
XnStatus nRetVal = XN_STATUS_OK;
xnLogVerbose(XN_MASK_SENSOR_SERVER, "Received BYE from client %u", m_nID);
XnStatus nActionResult = CloseSessionImpl();
XN_ASSERT(nActionResult == XN_STATUS_OK);
XN_REFERENCE_VARIABLE(nActionResult);
// client shouldn't care if close succeeded or not. always send OK.
nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_BYE, XN_STATUS_OK);
if (nRetVal != XN_STATUS_OK)
{
xnLogWarning(XN_MASK_SENSOR_SERVER, "Failed to send BYE reply to client %u: %s", m_nID, xnGetStatusString(nRetVal));
}
return (XN_STATUS_OK);
}
示例10: XN_PROPERTY_SET_CREATE_ON_STACK
XnStatus XnServerSession::HandleNewStream()
{
XnStatus nRetVal = XN_STATUS_OK;
// read it
XN_PROPERTY_SET_CREATE_ON_STACK(props);
XnChar strType[XN_DEVICE_MAX_STRING_LENGTH];
XnChar strName[XN_DEVICE_MAX_STRING_LENGTH];
nRetVal = m_privateIncomingPacker.ReadNewStream(strType, strName, &props);
XN_IS_STATUS_OK(nRetVal);
XnPropertySet* pInitialValues = &props;
if (props.pData->Begin() == props.pData->End())
{
pInitialValues = NULL;
}
XnStatus nActionResult = NewStreamImpl(strType, strName, pInitialValues);
if (nActionResult != XN_STATUS_OK)
{
xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to create stream of type '%s': %s", m_nID, strType, xnGetStatusString(nActionResult));
}
nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, nActionResult);
XN_IS_STATUS_OK(nRetVal);
return (XN_STATUS_OK);
}
示例11: throw
void OpenNIDevice::getAvailableModes () throw (OpenNIException)
{
available_image_modes_.clear ();
unique_lock<mutex> image_lock (image_mutex_);
unsigned mode_count = image_generator_.GetSupportedMapOutputModesCount ();
XnMapOutputMode* modes = new XnMapOutputMode[mode_count];
XnStatus status = image_generator_.GetSupportedMapOutputModes (modes, mode_count);
if (status != XN_STATUS_OK)
{
delete[] modes;
THROW_OPENNI_EXCEPTION ("Could not enumerate image stream output modes. Reason: %s", xnGetStatusString (status));
}
image_lock.unlock ();
for (unsigned modeIdx = 0; modeIdx < mode_count; ++modeIdx)
available_image_modes_.push_back (modes[modeIdx]);
delete[] modes;
available_depth_modes_.clear ();
unique_lock<mutex> depth_lock (depth_mutex_);
mode_count = depth_generator_.GetSupportedMapOutputModesCount ();
modes = new XnMapOutputMode[mode_count];
status = depth_generator_.GetSupportedMapOutputModes (modes, mode_count);
if (status != XN_STATUS_OK)
{
delete[] modes;
THROW_OPENNI_EXCEPTION ("Could not enumerate depth stream output modes. Reason: %s", xnGetStatusString (status));
}
depth_lock.unlock ();
for (unsigned modeIdx = 0; modeIdx < mode_count; ++modeIdx)
available_depth_modes_.push_back (modes[modeIdx]);
delete[] modes;
}
示例12: sprintf
int OpenniWrapper::start()
{
XnStatus rc;
EnumerationErrors errors;
hasRGB = 0;
hasDepth = 0;
rc = g_context.InitFromXmlFile(SAMPLE_XML_PATH, g_scriptNode, &errors);
if (rc == XN_STATUS_NO_NODE_PRESENT)
{
XnChar strError[1024];
errors.ToString(strError, 1024);
sprintf(buf, "%s\n", strError);
__android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
return (rc);
}
else if (rc != XN_STATUS_OK)
{
sprintf(buf, "Open failed: %s\n", xnGetStatusString(rc));
__android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
return (rc);
}
rc = g_context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_depth);
hasDepth = 1;
if (rc != XN_STATUS_OK)
{
sprintf(buf, "No depth node exists! Check your XML.");
__android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
hasDepth = 0;
//return 1;
}
rc = g_context.FindExistingNode(XN_NODE_TYPE_IMAGE, g_image);
hasRGB=1;
if (rc != XN_STATUS_OK)
{
sprintf(buf, "No image node exists! Check your XML.");
__android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
hasRGB=0;
//return 1;
}
// rc = g_depth.SetIntProperty ("OutputFormat", 0);
// if (rc != XN_STATUS_OK)
// {
// sprintf(buf, "Cannot set depth generator property");
// __android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
// return 1;
// }
//for ASUS XTION ONLY
//see: http://dev.pointclouds.org/projects/pcl/wiki/MacOSX
rc = g_depth.SetIntProperty ("RegistrationType", 1);
if (rc != XN_STATUS_OK)
{
sprintf(buf, "Cannot set depth generator property: RegistrationType");
__android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
return 1;
}
//obviously Kinect doesn't support anything else!?
// XnMapOutputMode outputMode;
//
// outputMode.nXRes = 640;
// outputMode.nYRes = 480;
// outputMode.nFPS = 30;
////
// rc = g_depth.SetMapOutputMode(outputMode);
// if (rc != XN_STATUS_OK)
// {
// sprintf(buf, "Cannot set depth generator property");
// __android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
// return 1;
// }
////
// rc = g_image.SetMapOutputMode(outputMode);
// if (rc != XN_STATUS_OK)
// {
// sprintf(buf, "Cannot set image generator property");
// __android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
// return 1;
// }
// TODO: check error code
if(hasDepth)
g_depth.GetMetaData(g_depthMD);
if(hasRGB)
g_image.GetMetaData(g_imageMD);
// Hybrid mode isn't supported in this sample
// if (g_imageMD.FullXRes() != g_depthMD.FullXRes() || g_imageMD.FullYRes() != g_depthMD.FullYRes())
// {
// sprintf (buf, "The device depth and image resolution must be equal!\n");
// __android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
// return 1;
// }
//show some info of the device...
// sprintf(buf, "Image Resolution: %d x %d", g_imageMD.FullXRes(), g_imageMD.FullYRes());
// __android_log_print(ANDROID_LOG_DEBUG, "OPENNI", buf);
//.........这里部分代码省略.........
示例13: main
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
}
示例14: xnLogConfigurationChanged
void xnLogConfigurationChanged()
{
// if new configuration requires a log file, and we don't have one opened
if (g_xnLoggerData.m_nLogFilteringType != XN_LOG_WRITE_NONE && g_xnLoggerData.m_bWriteToFile && g_xnLoggerData.m_fLogFile == XN_INVALID_FILE_HANDLE)
{
XN_PROCESS_ID nProcID = 0;
xnOSGetCurrentProcessID(&nProcID);
XnChar strFileName[XN_FILE_MAX_PATH];
sprintf(strFileName, "%s%s_%u.log", g_xnLoggerData.m_csLogDir, g_xnLoggerData.m_csTime, nProcID);
XnStatus nRetVal = xnLogCreateFile(strFileName, &g_xnLoggerData.m_fLogFile);
if (nRetVal != XN_STATUS_OK)
{
// we don't have much to do if files can't be open. Logs will not be written to file
printf("Couldn't create log file %s! Logs will not be written (error: %s)\n", strFileName, xnGetStatusString(nRetVal));
g_xnLoggerData.m_fLogFile = XN_INVALID_FILE_HANDLE;
g_xnLoggerData.m_bWriteToFile = FALSE;
}
}
if (!g_xnLoggerData.m_bBannerPrinted && xnLogIsEnabled(XN_MASK_LOG, XN_LOG_INFO))
{
xnLogInfo(XN_MASK_LOG, "OpenNI version is %s", XN_VERSION_STRING);
g_xnLoggerData.m_bBannerPrinted = TRUE;
}
if (g_xnLoggerData.m_fLogFile != XN_INVALID_FILE_HANDLE)
{
XnChar csMasks[XN_LOG_MASKS_STRING_LEN];
xnLogGetMasksString(csMasks);
xnLogWriteImpl(XN_MASK_LOG, XN_LOG_INFO, __FILE__, __LINE__, "Log system initialized. Console: %d, File: %d, Severity: %s, Masks: %s",
g_xnLoggerData.m_bWriteToConsole, g_xnLoggerData.m_bWriteToFile, xnLogGetSeverityString(g_xnLoggerData.m_nFilterSeverity), csMasks);
}
}
示例15: main
int main ( int argc, char * argv[] )
{
//
// Initialize OpenNI Settings
//
XnStatus nRetVal = XN_STATUS_OK;
xn::ScriptNode scriptNode;
xn::EnumerationErrors errors;
//
// Initialize Context Object
//
nRetVal = g_Context.InitFromXmlFile ( CONFIG_XML_PATH, scriptNode, &errors );
if ( nRetVal == XN_STATUS_NO_NODE_PRESENT ) {
XnChar strError[1024];
errors.ToString(strError, 1024);
printf ( "XN_STATUS_NO_NODE_PRESENT:\n%s\n", strError );
system ( "pause" );
return ( nRetVal );
}
else if ( nRetVal != XN_STATUS_OK ) {
printf ( "Open failed: %s\n", xnGetStatusString(nRetVal) );
system ( "pause" );
return ( nRetVal );
}
//
// Handle Image & Depth Generator Node
//
bool colorFlag = true;
bool depthFlag = true;
nRetVal = g_Context.FindExistingNode ( XN_NODE_TYPE_DEPTH, g_DepthGen );
if ( nRetVal != XN_STATUS_OK ) {
printf("No depth node exists!\n");
depthFlag = false;
}
nRetVal = g_Context.FindExistingNode ( XN_NODE_TYPE_IMAGE, g_ImageGen );
if ( nRetVal != XN_STATUS_OK ) {
printf("No image node exists!\n");
colorFlag = false;
}
// g_DepthGen.GetAlternativeViewPointCap().SetViewPoint( g_ImageGen );
if ( depthFlag ) {
g_DepthGen.GetMetaData ( g_DepthMD );
assert ( g_DepthMD.PixelFormat() == XN_PIXEL_FORMAT_GRAYSCALE_16_BIT );
}
if ( colorFlag ) {
g_ImageGen.GetMetaData ( g_ImageMD );
assert ( g_ImageMD.PixelFormat() == XN_PIXEL_FORMAT_RGB24 );
}
g_DepthImgShow = cv::Mat ( g_DepthMD.YRes(), g_DepthMD.XRes(), CV_8UC1 );
g_DepthImgMat = cv::Mat ( g_DepthMD.YRes(), g_DepthMD.XRes(), CV_16UC1 );
g_ColorImgMat = cv::Mat ( g_ImageMD.YRes(), g_ImageMD.XRes(), CV_8UC3 );
//
// Start to Loop
//
bool flipColor = true;
int ctlWndKey = -1;
g_StartTickCount = GetTickCount();
g_HeadTrackingFrameCount = 0;
while ( ctlWndKey != ESC_KEY_VALUE )
{
nRetVal = g_Context.WaitOneUpdateAll ( g_DepthGen );
// nRetVal = g_Context.WaitAnyUpdateAll();
#ifdef HANDLING_IMAGE_DATA
if ( colorFlag )
{
g_ImageGen.GetMetaData ( g_ImageMD );
assert ( g_ImageMD.FullXRes() == g_ImageMD.XRes() );
assert ( g_ImageMD.FullYRes() == g_ImageMD.YRes() );
GlobalUtility::CopyColorRawBufToCvMat8uc3 ( (const XnRGB24Pixel *)(g_ImageMD.Data()), g_ColorImgMat );
if ( ctlWndKey == 's' || ctlWndKey == 'S' ) { // Switch
flipColor = !flipColor;
}
if ( flipColor ) {
cv::cvtColor ( g_ColorImgMat, g_ColorImgMat, CV_RGB2BGR );
}
cv::namedWindow ( IMAGE_WIN_NAME, CV_WINDOW_AUTOSIZE );
cv::imshow ( IMAGE_WIN_NAME, g_ColorImgMat );
}
//.........这里部分代码省略.........