为了账号安全,请及时绑定邮箱和手机立即绑定

在 Hololens 中运行时未调用 OnPhotoCaptureCreated

在 Hololens 中运行时未调用 OnPhotoCaptureCreated

C#
白猪掌柜的 2021-10-23 17:00:24
我正在尝试制作一个可以在 Hololens 中拍摄照片的应用程序。我跟着教程,几乎复制了教程代码。当我在 Unity 中的计算机上运行它时,它可以工作并使用我的网络摄像头拍照。但是当我在 Hololens 上运行它时,它不起作用。我有问题的代码部分在这里:void Start() {startHeadPosition = Camera.main.transform.position;newHeadPosition = startHeadPosition;dIndikator.text = "";CreateScene("Test");Debug.Log("\n Taking picture \n");PhotoCapture.CreateAsync(false, OnPhotoCaptureCreated);Debug.Log("\n Debug 2 \n");}void OnPhotoCaptureCreated(PhotoCapture captureObject){Debug.Log("\n Debug 1 \n");photoCaptureObject = captureObject;m_cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).Last();CameraParameters c = new CameraParameters();c.hologramOpacity = 0.0f;c.cameraResolutionWidth = m_cameraResolution.width;c.cameraResolutionHeight = m_cameraResolution.height;c.pixelFormat = CapturePixelFormat.JPEG;Debug.Log("\n PhotoModeStarted \n");captureObject.StartPhotoModeAsync(c, OnPhotoModeStarted);}在 Unity 中,日志如下所示:拍照调试 2调试 1照片模式已启动但是在 Hololens 时,我只能得到:拍照调试 2所以看起来它甚至没有进入 OnPhotoCaptureCreated。我已经为摄像头和麦克风设置了功能,并确保我在清单文件中有它们,所以我不知道是什么导致了这个问题。我还确保在 Hololens 隐私设置中为应用程序启用了摄像头。任何想法都非常感谢。
查看完整描述

2 回答

?
慕哥6287543

TA贡献1831条经验 获得超10个赞

通常,PhotoCapture.CreateAsync不会执行for 的回调方法,因为您的应用程序没有使用相机的权限。

转到Settings/Privacy/Camera/并启用"Let apps use my camera"


查看完整回答
反对 回复 2021-10-23
?
aluckdog

TA贡献1847条经验 获得超7个赞

所以最终可能是那个 Hololens 设备的问题。它适用于其他人,因此我们已将其恢复为出厂设置,现在可以使用了。


查看完整回答
反对 回复 2021-10-23
  • 2 回答
  • 0 关注
  • 148 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号