hello,
I want to get the skeletons from two different Kinect devices. I
followed this thread
http://groups.google.com/group/openni-dev/browse_thread/thread/689ede96786f15d3/ec60b8eb679ca644?lnk=gst&q=multiple+skeleton#ec60b8eb679ca644
And The node tree I get is indeed
User2 <-- Depth2 <-- Device2
User1 <-- Depth1 <-- Device1
The only problem is that when I get the SkeletonCapability for both
User1 and User2, the two are the exact same. The skeleton for User1 is
returned by User2 as well.
has anyone encountered this before? I tried creating a seperate
context for both userGenerators, as suggested in another thread, but
with no success.
here is my initialization code:
//Search and create all available depth nodes
NodeInfoList depthNodeInfoList;
ret = m_Context.EnumerateExistingNodes(depthNodeInfoList);
NodeInfoList::Iterator nodeinfoiter = depthNodeInfoList.Begin();
for(; nodeinfoiter != depthNodeInfoList.End(); nodeinfoiter++)
{
NodeInfo nodeInfo = *nodeinfoiter;
if(nodeInfo.GetDescription().Type == XN_NODE_TYPE_DEPTH)
{
Sensor* s = new Sensor();
s->Initialize(&m_Context,nodeInfo);
m_Sensors.push_back(s);
}
}
int Sensor::Initialize(Context* context, NodeInfo info)
{
try
{
//m_Context = context;
m_Context = new Context();
m_Context->Init();
m_Context->SetGlobalMirror(true);
XnStatus ret = m_Context-
>CreateProductionTree(info,m_DepthGenerator);
if(!CheckStatus(ret)) throw exception();
m_DepthGenerator.GetMirrorCap().SetMirror(true);
m_DepthMetaData = new DepthMetaData();
//Create a user generator for each depth node
// This is useful because there might be more than 1 userGenerator
per node
NodeInfoList userGenInfoList;
ret = context-
>EnumerateProductionTrees(XN_NODE_TYPE_USER,NULL,userGenInfoList);
NodeInfo userInfo =
FindUserForDepthGenerator(userGenInfoList,m_DepthGenerator);
if(userInfo == NULL)
{
throw exception();
}
ret = m_Context->CreateProductionTree(userInfo,m_UserGenerator);
if(!CheckStatus(ret)) throw exception();
//Register Callbacks
m_UserGenerator.RegisterUserCallbacks(Sensor::NewUser,
Sensor::LostUser, this, m_hUserCallbacks);
m_UserGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(Sensor::PoseDetected,
Sensor::PoseLost, this, m_hPoseCallbacks);
// Skeleton stuff
SkeletonCapability skelly = m_UserGenerator.GetSkeletonCap();
skelly.SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
skelly.SetSmoothing(m_SmoothingFactor);
skelly.RegisterCalibrationCallbacks(Sensor::CalibrationStart,
Sensor::CalibrationEnd, this, m_hCalibrationCallbacks);
m_Context->StartGeneratingAll();
m_Initialized = true;
return 1;
}
catch(exception e)
{
//Cannot initialize, we can only playback
m_Initialized = false;
return -1;
}
}
Then when I update, I update both the global context and the context
for each userGen:
m_PlayBackContext.WaitAnyUpdateAll();
for(int i = 0; i < m_PlayBackSensors.size(); i++)
{
m_Sensors[i]->Update();
}
int Sensor::Update()
{
m_Context->WaitOneUpdateAll(m_UserGenerator);
m_DepthGenerator.GetMetaData(*m_DepthMetaData);
return 1;
}
Any help is really appreciated!
Thanks!
Dave