我正在开发用于面部跟踪的新 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);
}
}
}
C#:
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# 和 c++ 的结果为 false 和 true。
任何想法?我希望我的跟踪器能够在骨架数据之外工作,例如 c++ 示例。