我正在开发用于面部跟踪的新kinect SDK,我注意到示例(Previous Question)提供的托管代码和非托管代码之间存在一些差异。我无法使用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#,结果为false,对于c ++,结果为true。
有什么想法吗?我希望我的跟踪器能够在骨架数据之外工作,比如c ++示例。