Added the option to only stream the body data (skeleton and body point cloud) instead of everything.

This commit is contained in:
marek
2015-11-06 18:48:15 +01:00
parent 948eee769e
commit ef1c5ac2ce
10 changed files with 116 additions and 40 deletions
+7
View File
@@ -25,6 +25,7 @@ ICapture::ICapture()
pDepth = NULL;
pColorRGBX = NULL;
pBodyIndex = NULL;
}
ICapture::~ICapture()
@@ -40,4 +41,10 @@ ICapture::~ICapture()
delete[] pColorRGBX;
pColorRGBX = NULL;
}
if (pBodyIndex != NULL)
{
delete[] pBodyIndex;
pBodyIndex = NULL;
}
}
+24
View File
@@ -97,6 +97,7 @@ bool KinectCapture::AcquireFrame()
GetDepthFrame(pMultiFrame);
GetColorFrame(pMultiFrame);
GetBodyFrame(pMultiFrame);
GetBodyIndexFrame(pMultiFrame);
return true;
@@ -217,4 +218,27 @@ void KinectCapture::GetBodyFrame(IMultiSourceFrame* pMultiFrame)
SafeRelease(pBodyFrame);
SafeRelease(pBodyFrameReference);
}
void KinectCapture::GetBodyIndexFrame(IMultiSourceFrame* pMultiFrame)
{
IBodyIndexFrameReference* pBodyIndexFrameReference = NULL;
IBodyIndexFrame* pBodyIndexFrame = NULL;
pMultiFrame->get_BodyIndexFrameReference(&pBodyIndexFrameReference);
HRESULT hr = pBodyIndexFrameReference->AcquireFrame(&pBodyIndexFrame);
if (SUCCEEDED(hr))
{
if (pBodyIndex == NULL)
{
pBodyIndex = new BYTE[nDepthFrameHeight * nDepthFrameWidth];
}
UINT nBufferSize = nDepthFrameHeight * nDepthFrameWidth;
hr = pBodyIndexFrame->CopyFrameDataToArray(nBufferSize, pBodyIndex);
}
SafeRelease(pBodyIndexFrame);
SafeRelease(pBodyIndexFrameReference);
}
+9 -2
View File
@@ -50,6 +50,7 @@ LiveScanClient::LiveScanClient() :
m_pDepthCoordinatesOfColor(NULL),
m_bCalibrate(false),
m_bFilter(false),
m_bStreamOnlyBodies(false),
m_bCaptureFrame(false),
m_bConnected(false),
m_bConfirmCaptured(false),
@@ -195,7 +196,7 @@ void LiveScanClient::UpdateFrame()
pCapture->MapDepthFrameToColorSpace(m_pColorCoordinatesOfDepth);
{
std::lock_guard<std::mutex> lock(m_mSocketThreadMutex);
StoreFrame(m_pCameraSpaceCoordinates, m_pColorCoordinatesOfDepth, pCapture->pColorRGBX, pCapture->vBodies);
StoreFrame(m_pCameraSpaceCoordinates, m_pColorCoordinatesOfDepth, pCapture->pColorRGBX, pCapture->vBodies, pCapture->pBodyIndex);
if (m_bCaptureFrame)
{
@@ -497,6 +498,9 @@ void LiveScanClient::HandleSocket()
i += sizeof(int);
}
m_bStreamOnlyBodies = (received[i] != 0);
i++;
//so that we do not lose the next character in the stream
i--;
}
@@ -683,7 +687,7 @@ void LiveScanClient::SendFrame(vector<Point3f> vertices, vector<RGB> RGB, vector
}
void LiveScanClient::StoreFrame(Point3f *vertices, Point2f *mapping, RGB *color, vector<Body> &bodies)
void LiveScanClient::StoreFrame(Point3f *vertices, Point2f *mapping, RGB *color, vector<Body> &bodies, BYTE* bodyIndex)
{
std::vector<Point3f> goodVertices;
std::vector<RGB> goodColorPoints;
@@ -692,6 +696,9 @@ void LiveScanClient::StoreFrame(Point3f *vertices, Point2f *mapping, RGB *color,
for (unsigned int vertexIndex = 0; vertexIndex < nVertices; vertexIndex++)
{
if (m_bStreamOnlyBodies && bodyIndex[vertexIndex] >= bodies.size())
continue;
if (vertices[vertexIndex].Z >= 0 && mapping[vertexIndex].Y >= 0 && mapping[vertexIndex].Y < pCapture->nColorFrameHeight)
{
Point3f temp = vertices[vertexIndex];