I'm working on the new kinect SDK for face tracking and I noticed some differences between managed and unmanaged code provided with the examples (Previous Question). I can't reproduce the fast c++ example using c# and WPF: starting with the same setting with kinect for windows, here's the two sets of code:
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);
}
The result of the same tracking call, providing the same data apparently, result false for c# and true for c++.
Any idea? I want my tracker to work besides the skeleton data, like the c++ example.