提问者:小点点

Kinect SDK 1.5-人脸跟踪:WPF仅颜色深度跟踪器


我正在开发新的用于人脸跟踪的kinect SDK,我注意到示例中提供的托管代码和非托管代码之间的一些差异(上一个问题)。我无法使用C#和WPF复制快速C++示例:从kinect for windows的相同设置开始,下面是两组代码:

C++:

if (m_KinectSensorPresent && m_KinectSensor.GetVideoBuffer())
{
    HRESULT hrCopy = m_KinectSensor.GetVideoBuffer()->CopyTo(m_colorImage, NULL, 0, 0);
    if (SUCCEEDED(hrCopy) && m_KinectSensor.GetDepthBuffer())
    {
        hrCopy = m_KinectSensor.GetDepthBuffer()->CopyTo(m_depthImage, NULL, 0, 0);
    }
    // Do face tracking
    if (SUCCEEDED(hrCopy))
    {
        FT_SENSOR_DATA sensorData(m_colorImage, m_depthImage, m_KinectSensor.GetZoomFactor(), m_KinectSensor.GetViewOffSet());

        FT_VECTOR3D* hint = NULL;
        if (SUCCEEDED(m_KinectSensor.GetClosestHint(m_hint3D)))
        {
            hint = m_hint3D;
        }
        if (m_LastTrackSucceeded)
        {
            hrFT = m_pFaceTracker->ContinueTracking(&sensorData, hint, m_pFTResult);
        }
        else
        {
            hrFT = m_pFaceTracker->StartTracking(&sensorData, NULL, hint, m_pFTResult);
        }
    }
}
int hr;
            HeadPoints headPointsObj = null;
            Vector3DF[] headPoints = GetHeadPointsFromSkeleton(skeletonOfInterest);

        if (headPoints != null && headPoints.Length == 2)
        {
            headPointsObj = new HeadPoints { Points = headPoints };
        }

        this.copyStopwatch.Start();
        this.colorFaceTrackingImage.CopyFrom(colorImage);
        this.depthFaceTrackingImage.CopyFrom(depthImage);
        this.copyStopwatch.Stop();

        var sensorData = new SensorData(this.colorFaceTrackingImage, this.depthFaceTrackingImage, DefaultZoomFactor, Point.Empty);
        FaceTrackingSensorData faceTrackSensorData = sensorData.FaceTrackingSensorData;

        this.startOrContinueTrackingStopwatch.Start();
        if (this.trackSucceeded)
        {
            hr = this.faceTrackerInteropPtr.ContinueTracking(ref faceTrackSensorData, headPointsObj, this.frame.ResultPtr);
        }
        else
        {
            hr = this.faceTrackerInteropPtr.StartTracking(
                ref faceTrackSensorData, ref regionOfInterest, headPointsObj, this.frame.ResultPtr);
        }

你知道吗?我希望我的跟踪器除了骨架数据之外还能工作,就像C++示例一样。


共1个答案

匿名用户

我找到了一个解决方案,在这个论坛上提供了微软论坛。您必须修改SDK提供给您的工具,并且对提供的代码进行修改并不好,但它最终还是起作用了。