Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <XnCppWrapper.h>
- using namespace xn;
- Context commonContext;
- NodeInfoList imageList, depthList;
- XnStatus rc;
- rc = commonContext.Init();
- rc |= commonContext.EnumerateProductionTrees (XN_NODE_TYPE_IMAGE, NULL, imageList);
- rc |= commonContext.EnumerateProductionTrees (XN_NODE_TYPE_DEPTH, NULL, depthList);
- NodeInfoList::Iterator iit = imageList.Begin(), dit = depthList.Begin();
- // apre il Kinect #id
- int temp = id;
- while (temp--) {
- if (iit == imageList.End() || dit == depthList.End()) {
- std::cout << "Not enough devices!" << std::endl;
- return 1;
- }
- iit++; dit++;
- }
- NodeInfo dn(*iit), in(*dit);
- rc |= commonContext.CreateProductionTree(dn);
- rc |= commonContext.CreateProductionTree(in);
- ImageGenerator image;
- DepthGenerator depth
- rc |= dn.GetInstance(image);
- rc |= in.GetInstance(depth);
- XnMapOutputMode mode;
- mode.nFPS = 30;
- mode.nXRes = XRes = 640;
- mode.nYRes = YRes = 480;
- image.SetMapOutputMode(mode);
- depth.SetMapOutputMode(mode);
- // allineamento depth -> RGB
- depth.GetAlternativeViewPointCap().SetViewPoint(image);
- // cattura
- while(true) {
- commonContext.WaitAndUpdateAll();
- uint64_t timestamp = depth.GetTimestamp();
- ushort* depth_buffer = (ushort*)depth.GetDepthMap();
- uchar* image_buffer = (uchar*)image.GetImageMap();
- }
- // chiusura
- commonContext.Shutdown();
Add Comment
Please, Sign In to add comment