本文整理汇总了C++中ImageGenerator::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageGenerator::Create方法的具体用法?C++ ImageGenerator::Create怎么用?C++ ImageGenerator::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageGenerator
的用法示例。
在下文中一共展示了ImageGenerator::Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mixRGB_Depth
void mixRGB_Depth()
{
bool bShouldRun = true;
int c;
XnStatus nRetVal = XN_STATUS_OK;
Context context;
// Initialize context object
nRetVal = context.Init();
// Check error code
if (nRetVal)
printf("Error: %s", xnGetStatusString(nRetVal));
context.SetGlobalMirror(true);
//Create Depth generator node
DepthGenerator depth;
nRetVal = depth.Create(context);
// Check error code
if (nRetVal)
printf("Error: %s", xnGetStatusString(nRetVal));
// Create an ImageGenetor node
ImageGenerator image;
nRetVal = image.Create(context);
if (nRetVal)
printf("Error: %s", xnGetStatusString(nRetVal));
// Sync the DepthGenerator with the ImageGenerator
nRetVal = depth.GetAlternativeViewPointCap().SetViewPoint(image);
if (nRetVal)
printf("Error: %s", xnGetStatusString(nRetVal));
//Set it to VGA maps at 30 fps
XnMapOutputMode mapMode;
mapMode.nXRes = XN_VGA_X_RES;
mapMode.nYRes = XN_VGA_Y_RES;
mapMode.nFPS = 30;
nRetVal = depth.SetMapOutputMode(mapMode);
// Make it start generating data
nRetVal = context.StartGeneratingAll();
if (nRetVal)
printf("Error: %s", xnGetStatusString(nRetVal));
// Create an OpenCv matrix
CvMat* depthMetersMat = cvCreateMat(480, 640, CV_16UC1);
IplImage *kinectDepthImage;
kinectDepthImage = cvCreateImage(cvSize(640,480), 16, 1);
IplImage *rgbimg = cvCreateImageHeader(cvSize(640,480), 8,3);
// Main loop
while (bShouldRun)
{
//wait for new data to be available
nRetVal = context.WaitOneUpdateAll(depth);
if (nRetVal)
{
printf("Error: %s", xnGetStatusString(nRetVal));
continue;
}
//Take current depth map
const XnDepthPixel* pDepthMap = depth.GetDepthMap();
for (int y=0; y<XN_VGA_Y_RES; y++)
{
for (int x=0; x<XN_VGA_X_RES; x++)
{
depthMetersMat->data.s[y*XN_VGA_X_RES+x]=10*pDepthMap[y*XN_VGA_X_RES+x];
}
}
cvGetImage(depthMetersMat, kinectDepthImage);
//take current image
const XnRGB24Pixel* pImage = image.GetRGB24ImageMap();
//process image data
XnRGB24Pixel* ucpImage = const_cast<XnRGB24Pixel*>(pImage);
cvSetData(rgbimg, ucpImage, 640*3);
cvShowImage("RGB", kinectDepthImage);
c = cvWaitKey(1);
if (c == 27)
bShouldRun = false;
}
cvReleaseImageHeader(&kinectDepthImage);
context.Shutdown();
}
示例2: 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);
//.........这里部分代码省略.........
示例3: main
void main()
{
//---------------------------------------------------
bool bShouldRun = true;
int c ;
XnStatus nRetVal = XN_STATUS_OK;
Context context;
// Initialize context object
nRetVal = context.Init();
// check error code
if(nRetVal)
printf("Error : %s", xnGetStatusString(nRetVal));
context.SetGlobalMirror(true); //mirror image
// Create a DepthGenerator node
DepthGenerator depth;
nRetVal = depth.Create(context);
// check error code
if(nRetVal)
printf("Failed to create depth generator: %s\n", xnGetStatusString(nRetVal));
/// Create an ImageGenerator node
ImageGenerator image;
nRetVal = image.Create(context);
if(nRetVal)
printf("Failed to create image generator: %s\n", xnGetStatusString(nRetVal));
if(nRetVal)
printf("Failed to match Depth and RGB points of view: %s\n",xnGetStatusString(nRetVal));
// Set it to VGA maps at 30 FPS
XnMapOutputMode mapMode;
mapMode.nXRes = XN_VGA_X_RES;
mapMode.nYRes = XN_VGA_Y_RES;
mapMode.nFPS = 30;
nRetVal = depth.SetMapOutputMode(mapMode);
// Make it start generating data
nRetVal = context.StartGeneratingAll();
// check error code
if(nRetVal)
printf("Error : %s", xnGetStatusString(nRetVal));
//create a OpenCv matrix
CvMat* depthMetersMat = cvCreateMat(480, 640, CV_16UC1);
IplImage *kinectDepthImage;
kinectDepthImage = cvCreateImage( cvSize(640,480),16,1);
IplImage *kinectDepthImage_raw= cvCreateImage( cvSize(640,480),16,1);
IplImage rgbimg;
XnPoint3D* pDepthPointSet = new XnPoint3D[ 640*480 ];
// Main loop
while (bShouldRun)
{
// Wait for new data to be available
nRetVal = context.WaitOneUpdateAll(depth);
if (nRetVal != XN_STATUS_OK)
{
printf("Failed updating data: %s\n", xnGetStatusString(nRetVal));
continue;
}
// Take current depth map
const XnDepthPixel* pDepthMap = depth.GetDepthMap();
xn::DepthGenerator rDepth;
//Copy the depth values
for (int y=0; y<XN_VGA_Y_RES; y++)
for(int x=0;x<XN_VGA_X_RES;x++)
{
depthMetersMat->data.s[y * XN_VGA_X_RES + x ] = 20*pDepthMap[y * XN_VGA_X_RES + x];
// Convert the coordinates in the camera coordinate system
pDepthPointSet[y * XN_VGA_X_RES + x].X = (XnFloat) x;
pDepthPointSet[y * XN_VGA_X_RES + x].Y = (XnFloat) y;
pDepthPointSet[y * XN_VGA_X_RES + x].Z = pDepthMap[y * XN_VGA_X_RES + x];
}
cvGetImage(depthMetersMat,kinectDepthImage_raw);
cvShowImage("Depth stream", kinectDepthImage_raw);
unsigned char* picture_RGB = new unsigned char[XN_VGA_X_RES * XN_VGA_Y_RES * 3];
//initialization with the retrieved data
memcpy(picture_RGB, (unsigned char*)image.GetRGB24ImageMap(),XN_VGA_Y_RES * XN_VGA_X_RES * 3);
//From BGR to RGB
for(int i = 0 ; i < XN_VGA_X_RES * XN_VGA_Y_RES ; i++)
{
unsigned char temp = picture_RGB[i*3];
//.........这里部分代码省略.........