Hey,
I'm currently using the Windows.Media.FaceAnalysis namespace to detect faces in the HoloLens. The face detection works fine. However, the DLL sometimes (but really rarely) throws an "Access Violation: reading location 0x00000008" error, leading
to an app crash.
Also, ProcessNextFrameAsync often throws a System.Runtime.InteropServices.COMException that I'm ignoring without leading to any crash, but that may be related to the issue.
I'm developping using Unity & .NET 4.6. I verified the inputs I'm passing to the DLL, to be sure the VideoFrames are compatible with the ProcessNextFrameAsync requirements.
Here's the code:
async void FrameReader_FrameArrived(MediaFrameReader _sender, MediaFrameArrivedEventArgs _args)
{
if (!faceTrackingStarted)
return;
if (_sender == null)
return;
MediaFrameReference lastFrame = _sender.TryAcquireLatestFrame();
if (lastFrame == null || lastFrame.VideoMediaFrame == null)
return;
if (lastFrame.VideoMediaFrame.SoftwareBitmap == null || !FaceTracker.IsBitmapPixelFormatSupported(lastFrame.VideoMediaFrame.SoftwareBitmap.BitmapPixelFormat))
return;
if (faceTracker == null)
return;
if (lockFrameArrived)
return;
lockFrameArrived = true;
VideoFrame videoFrame = lastFrame.VideoMediaFrame.GetVideoFrame();
if (videoFrame == null)
return;
try
{
_faces = await faceTracker.ProcessNextFrameAsync(videoFrame);
}
catch (System.Runtime.InteropServices.COMException e)
{
lockFrameArrived = false;
}
// Continue performing some operations on the detected faces
}
By the way, when quickly moving the head, the camera pose estimation at the moment when the image was acquired does not seem to be precise. That's problematic when trying to estimate where the face was in the 3D space. I noticed the same problem in the microsoft
sample : https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/HolographicFaceTracking
If anyone knows what's going on, I'll be really thankfull!
Best regards,
Clément.