【发布时间】:2020-07-09 11:47:37
【问题描述】:
我无法让 FaceTracker Class 在 HoloLens 2 上工作。
一旦我尝试使用ProcessNextFrameAsync Method 检测人脸,就会出现以下异常:
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error
这只是错误信息的第一部分,如果需要更多信息,我可以补充。
请参阅此以获取最小示例。
public async void Start()
{
var selectedGroup = await FindCameraAsync();
await StartMediaCaptureAsync(selectedGroup);
}
private async Task StartMediaCaptureAsync(MediaFrameSourceGroup sourceGroup)
{
faceTracker = await FaceTracker.CreateAsync();
this.mediaCapture = new MediaCapture();
await this.mediaCapture.InitializeAsync(settings);
this.frameProcessingTimer = ThreadPoolTimer.CreatePeriodicTimer(ProcessCurrentVideoFrameAsync, timerInterval);
}
private async Task ProcessCurrentVideoFrameAsync()
{
const BitmapPixelFormat InputPixelFormat = BitmapPixelFormat.Nv12;
var deviceController = this.mediaCapture.VideoDeviceController;
this.videoProperties = deviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;
VideoFrame videoFrame = new VideoFrame(InputPixelFormat, (int)this.videoProperties.Width (int)this.videoProperties.Height);
IList<DetectedFace> detectedFaces;
try
{
detectedFaces = await faceTracker.ProcessNextFrameAsync(videoFrame);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine($"Failed with Exception: {e.ToString()}");
return;
}
videoFrame.Dispose();
}
- 我用
MediaFrameSourceKind.Color和MediaStreamType.VideoPreview和FindCameraAsync()得到了一个合适的相机。我认为这很好用。 - 启动
MediaCapture和StartMediaCaptureAsync()内的FaceTracker - 尝试在
ProcessCurrentVideoFrameAsync()中检测人脸
以下是我测试过的东西和我收到的信息:
- 我有一张格式为
Nv12、PixelWidth1504 和PixelHeigt846 的图片 - 在 Unity 中为网络摄像头、图片库和麦克风授予权限
- 应用程序使用 Il2CPP 编译
- 启动应用程序后出现消息
No capture devices are available.。在其他文章中提到缺少权限(网络摄像头或麦克风),但事实并非如此。但仍然可以连接。 - 我使用了Track faces in a sequence of frames 和Basic Face Tracking sample 作为参考
我非常感谢每一个激励和想法。
2020 年 7 月 14 日更新
我刚刚在 HoloLens 2 上本地存储的几个单独图像上尝试了FaceDetector。效果很好。
尽管FaceDetector 和FaceTracker 不相同,但它们非常相似。所以我猜这个问题与MediaCapture有关。
接下来我将尝试使用MediaCapture 捕获图像并使用FaceDetector 处理它。
如果有人在此期间有更多想法,我将不胜感激。
【问题讨论】:
-
我可以知道你的 HoloLen2 真机的操作系统版本吗? Unity3D版本也很好分享。如果您将 Holographic 面部跟踪示例部署到您的设备,我可以知道您这边会发生什么吗? github.com/microsoft/Windows-universal-samples/tree/master/…
-
@FranklinChen-MSFT HoloLens 2 的操作系统版本是 10.0.19041.1106。我使用的 Unity 版本为 2018.4.22f1。这个例子的想法很好,我已经尝试过了,并且面部跟踪工作。但由于它是一个编译版本,而且我对编程还很陌生,所以我无法使用它对其进行逆向工程。