據我瞭解官方Kinect 1.5 SDK,它帶有人臉跟蹤和骨架跟蹤。如何簡單的斑點檢測?我想要做的就是跟蹤一個圓形/橢圓形物體。我在SDK中找不到任何代碼,那麼我應該使用opencv還是其他一些庫?簡單的blob檢測與kinect SDK
(我的代碼是在C++)
EDIT1是它可以調諧臉部跟蹤器所以它會檢測在一般(而不是面)輪形狀?
EDIT2 這裏是深入處理SDK附帶示例的代碼。我如何讓OpenCV從中提取blob?
void CDepthBasics::ProcessDepth()
{
HRESULT hr;
NUI_IMAGE_FRAME imageFrame;
// Attempt to get the depth frame
hr = m_pNuiSensor->NuiImageStreamGetNextFrame(m_pDepthStreamHandle, 0, &imageFrame);
if (FAILED(hr))
{
return;
}
INuiFrameTexture * pTexture = imageFrame.pFrameTexture;
NUI_LOCKED_RECT LockedRect;
// Lock the frame data so the Kinect knows not to modify it while we're reading it
pTexture->LockRect(0, &LockedRect, NULL, 0);
// Make sure we've received valid data
if (LockedRect.Pitch != 0)
{
BYTE * rgbrun = m_depthRGBX;
const USHORT * pBufferRun = (const USHORT *)LockedRect.pBits;
// end pixel is start + width*height - 1
const USHORT * pBufferEnd = pBufferRun + (cDepthWidth * cDepthHeight);
while (pBufferRun < pBufferEnd)
{
// discard the portion of the depth that contains only the player index
USHORT depth = NuiDepthPixelToDepth(*pBufferRun);
// to convert to a byte we're looking at only the lower 8 bits
// by discarding the most significant rather than least significant data
// we're preserving detail, although the intensity will "wrap"
BYTE intensity = static_cast<BYTE>(depth % 256);
// Write out blue byte
*(rgbrun++) = intensity
// Write out green byte
*(rgbrun++) = intensity;
// Write out red byte
*(rgbrun++) = intensity;
// We're outputting BGR, the last byte in the 32 bits is unused so skip it
// If we were outputting BGRA, we would write alpha here.
++rgbrun;
// Increment our index into the Kinect's depth buffer
++pBufferRun;
}
// Draw the data with Direct2D
m_pDrawDepth->Draw(m_depthRGBX, cDepthWidth * cDepthHeight * cBytesPerPixel);
}
// We're done with the texture so unlock it
pTexture->UnlockRect(0);
// Release the frame
m_pNuiSensor->NuiImageStreamReleaseFrame(m_pDepthStreamHandle, &imageFrame);
}
謝謝。我已經添加了SDK附帶的示例性深度處理代碼。我將如何改變代碼,讓OpenCV對它進行Hough轉換? – memyself
個人而言,我還沒有使用過Kinect SDK(因爲它只在Windows 7上運行),但簡單的搜索應該有所幫助。例如[Dennis Ippel的博客文章](http://www.rozengain.com/blog/2012/08/01/using-opencv-2-with-kinect-sdk-1-5/)或這篇[wiki文章來自卡內基梅隆大學](http://wiki.etc.cmu.edu/unity3d/index.php/OpenCV_with_Kinect_-_Windows_SDK)(重點放在Unity整合之前的部分)。 HTH –