本文整理汇总了C++中UserGenerator::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ UserGenerator::Create方法的具体用法?C++ UserGenerator::Create怎么用?C++ UserGenerator::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGenerator
的用法示例。
在下文中一共展示了UserGenerator::Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
//--------------------------------------------------------------------//
//------------------------- SETUP REQUIRED NODES ---------------------//
//--------------------------------------------------------------------//
// Setup the command line parameters.
setupParams(argc, argv);
// Setup all the sockets.
setupSockets();
// Setup the capture socket server for Mac.
#if (XN_PLATFORM == XN_PLATFORM_MACOSX)
if(_featureDepthMapCapture || _featureRGBCapture)
{
if(_useSockets)
{
g_AS3Network = network();
g_AS3Network.init(setupServer);
}
}
#endif
// Setup the status.
XnStatus _status = XN_STATUS_OK;
EnumerationErrors _errors;
// Context Init and Add license.
_status = _context.Init();
CHECK_RC(_status, "AS3OpenNI :: Initialize context");
_context.SetGlobalMirror(_mirror);
XnChar vendor[XN_MAX_NAME_LENGTH];
XnChar license[XN_MAX_LICENSE_LENGTH];
_license.strVendor[XN_MAX_NAME_LENGTH] = strcmp(vendor, "PrimeSense");
_license.strKey[XN_MAX_LICENSE_LENGTH] = strcmp(license, "0KOIk2JeIBYClPWVnMoRKn5cdY4=");
_status = _context.AddLicense(_license);
CHECK_RC(_status, "AS3OpenNI :: Added license");
// Set it to VGA maps at 30 FPS
_depthMode.nXRes = 640;
_depthMode.nYRes = 480;
_depthMode.nFPS = 30;
// Depth map create.
_status = _depth.Create(_context);
CHECK_RC(_status, "AS3OpenNI :: Create depth generator");
_status = _depth.SetMapOutputMode(_depthMode);
// Depth map create.
_status = _image.Create(_context);
CHECK_RC(_status, "AS3OpenNI :: Create image generator");
_status = _image.SetMapOutputMode(_depthMode);
_status = _image.SetPixelFormat(XN_PIXEL_FORMAT_RGB24);
// Create the hands generator.
_status = _hands.Create(_context);
CHECK_RC(_status, "AS3OpenNI :: Create hands generator");
_hands.SetSmoothing(0.1);
// Create the gesture generator.
_status = _gesture.Create(_context);
CHECK_RC(_status, "AS3OpenNI :: Create gesture generator");
// Create user generator.
_status = _userGenerator.Create(_context);
CHECK_RC(_status, "AS3OpenNI :: Find user generator");
// Create and initialize point tracker
_sessionManager = new XnVSessionManager();
_status = _sessionManager->Initialize(&_context, "Wave", "RaiseHand");
if (_status != XN_STATUS_OK)
{
printf("AS3OpenNI :: Couldn't initialize the Session Manager: %s\n", xnGetStatusString(_status));
CleanupExit();
}
_sessionManager->RegisterSession(NULL, &SessionStart, &SessionEnd, &SessionProgress);
// Start catching signals for quit indications
CatchSignals(&_quit);
//---------------------------------------------------------------//
//------------------------- SETUP FEATURES ---------------------//
//--------------------------------------------------------------//
// Define the Wave and SinglePoint detectors.
_waveDetector = new XnVWaveDetector();
// SinglePoint detector.
if(_featureSinglePoint) _waveDetector->RegisterPointUpdate(NULL, &OnPointUpdate);
// Feature Gesture.
if(_featureGesture)
{
// Wave detector.
_waveDetector->RegisterWave(NULL, &OnWave);
//.........这里部分代码省略.........
示例2: printf
/*
* Function: KinectMonitor (Constructor)
*
* Initializes all the production nodes for the kinect to get and process data.
* Sets the camera tilt to the specified (or default) angle.
* Registers the OpenNI callbacks for user events.
* Registers the system signal handlers (for terminating the program).
* Initializes the global and member variables.
*
* Parameters:
* int* tilt - A pointer to the desired tilt angle of the camera.
* If it is NULL, the default value is used.
*/
KinectMonitor::KinectMonitor(char *tilt) {
XnStatus status;
EnumerationErrors errors;
XnCallbackHandle userCallbacks;
// Setup Context from an XML configuration file (the default supplied by OpenNI)
// CONTEXT_XML is defined in monitor.h
status = context.InitFromXmlFile(CONTEXT_XML, scriptNode, &errors);
// Check to ensure that the context was initialized properly.
if( status == XN_STATUS_NO_NODE_PRESENT ) {
XnChar strError[1024];
errors.ToString(strError, 1024);
printf("%s\n", strError);
return;
} else if( status != XN_STATUS_OK ) {
printf("Could not initialize Context: %s\n", xnGetStatusString(status));
return;
}
// Setup Depth Generator production node from the context
status = context.FindExistingNode(XN_NODE_TYPE_DEPTH, depthGenerator);
// Setup User Generator production node from the context
status = context.FindExistingNode(XN_NODE_TYPE_USER, userGenerator);
// Check that the user generator is available
if( status != XN_STATUS_OK ) {
// If the context did not define a UserGenerator node, then try to create one
status = userGenerator.Create(context);
CHECK_RC(status, "Find user generator");
}
// Set FPS
status = xnFPSInit(&xnFPS, 180);
// Check for Skeletal Mapping
if( !userGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON) ) {
printf("Skeletal mapping not supported.\n");
return;
}
// Set the skeletal profile to only include the joints in the upper body.
// Profile options are XN_SKEL_PROFILE_<option>
// Where <option> could be: NONE, ALL, UPPER, LOWER, or HEAD_HANDS
userGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_UPPER);
// Tilt camera - This feature requires the program to be run with root privilege,
// because it requires writing to the usb device.
XN_USB_DEV_HANDLE dev;
// Sets the angle to either the DEFAULT_TILT (defined in monitor.h) or the given tilt.
int angle = (tilt == nullptr)? DEFAULT_TILT : atoi(tilt);
// Open the kinect usb device
status = xnUSBOpenDevice(VID_MICROSOFT, PID_NUI_MOTOR, NULL, NULL, &dev);
// Send the proper code to the usb device to set the angle.
uint8_t empty[0x1];
status = xnUSBSendControl(
dev, XN_USB_CONTROL_TYPE_VENDOR, 0x31, (XnUInt16)angle,
0x0, empty, 0x0, 0
);
// Register Callbacks
status = userGenerator.RegisterUserCallbacks(
foundUser, lostUser, NULL, userCallbacks
);
// Register Handlers
signal(SIGABRT, &stop);
signal(SIGTERM, &stop);
signal(SIGINT, &stop);
// Initialize globals
quit = false;
out = true;
}
示例3: init
bool CVKinectWrapper::init(string CalibFilePath)
{
this->CalibFilePath = CalibFilePath;
XnStatus rc;
EnumerationErrors errors;
rc = g_context.InitFromXmlFile(CalibFilePath.c_str(), g_scriptNode, &errors);
if (rc == XN_STATUS_NO_NODE_PRESENT)
{
XnChar strError[1024];
errors.ToString(strError, 1024);
printf("%s\n", strError);
error = 1;
return started;
}
else if (rc != XN_STATUS_OK)
{
printf("Open failed: %s\n", xnGetStatusString(rc));
error = 2;
return started;
}
rc = g_context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_depth);
if (rc != XN_STATUS_OK)
{
printf("No depth node exists! Check your XML.");
error = 3;
return started;
}
rc = g_context.FindExistingNode(XN_NODE_TYPE_IMAGE, g_image);
if (rc != XN_STATUS_OK)
{
printf("No image node exists! Check your XML.");
error = 4;
return started;
}
g_depth.GetMetaData(g_depthMD);
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())
{
printf ("The device depth and image resolution must be equal!\n");
error = 5;
return started;
}
// RGB is the only image format supported.
if (g_imageMD.PixelFormat() != XN_PIXEL_FORMAT_RGB24)
{
printf("The device image format must be RGB24\n");
error = 6;
return started;
}
// skeleton
rc = g_context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
if (rc != XN_STATUS_OK)
{
rc = g_UserGenerator.Create(g_context);
CHECK_RC(rc, "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");
error = 7;
return 1;
}
rc = g_UserGenerator.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
CHECK_RC(rc, "Register to user callbacks");
rc = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationStart(UserCalibration_CalibrationStart, NULL, hCalibrationStart);
CHECK_RC(rc, "Register to calibration start");
rc = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationComplete(UserCalibration_CalibrationComplete, NULL, hCalibrationComplete);
CHECK_RC(rc, "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");
error = 7;
return 1;
}
rc = g_UserGenerator.GetPoseDetectionCap().RegisterToPoseDetected(UserPose_PoseDetected, NULL, hPoseDetected);
CHECK_RC(rc, "Register to Pose Detected");
g_UserGenerator.GetSkeletonCap().GetCalibrationPose(g_strPose);
}
g_UserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
rc = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationInProgress(MyCalibrationInProgress, NULL, hCalibrationInProgress);
CHECK_RC(rc, "Register to calibration in progress");
//.........这里部分代码省略.........