Unity3d 全息透镜2上的定位摄像机(光拍)
在全息透镜2上使用PhotoCapture时,我有两个问题,它们可能是连接的。它们没有出现在全息透镜1上Unity3d 全息透镜2上的定位摄像机(光拍),unity3d,hololens,windows-mixed-reality,Unity3d,Hololens,Windows Mixed Reality,在全息透镜2上使用PhotoCapture时,我有两个问题,它们可能是连接的。它们没有出现在全息透镜1上 唯一可获得的分辨率是3904x2196 获取CameraToWorldMatrix总是失败 从中可以看出,此分辨率没有与之关联的帧率。 我的假设是,CameraToWorldMatrix仅可用于分辨率较低的相机配置文件 我如何改变分辨率并得到统一的矩阵 最小可重复示例 我正在使用Unity 2019.2.19f1和Visual Studio 2019社区(16.4.5) 按照以下步骤创
- 唯一可获得的分辨率是3904x2196
- 获取CameraToWorldMatrix总是失败
最小可重复示例 我正在使用Unity 2019.2.19f1和Visual Studio 2019社区(16.4.5)
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Windows.WebCam;
public class PhotoCaptureController : MonoBehaviour
{
PhotoCapture photoCaptureObject = null;
bool isRunning = false;
void Start()
{
StartCoroutine(StartCameraCapture());
}
private IEnumerator StartCameraCapture()
{
if (!Application.HasUserAuthorization(UserAuthorization.WebCam))
{
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
}
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
Debug.Log("Creating PhotoCapture");
PhotoCapture.CreateAsync(false, OnPhotoCaptureCreated);
}
else
{
Debug.Log("Webcam Permission not granted");
}
}
private void Update()
{
if (isRunning)
{
photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);
}
}
void OnPhotoCaptureCreated(PhotoCapture captureObject)
{
photoCaptureObject = captureObject;
IEnumerable<Resolution> availableResolutions = PhotoCapture.SupportedResolutions;
foreach (var res in availableResolutions)
{
Debug.Log("PhotoCapture Resolution: " + res.width + "x" + res.height);
}
Resolution cameraResolution = availableResolutions.OrderByDescending((res) => res.width * res.height).First();
CameraParameters c = new CameraParameters();
c.hologramOpacity = 0.0f;
c.cameraResolutionWidth = cameraResolution.width;
c.cameraResolutionHeight = cameraResolution.height;
c.pixelFormat = CapturePixelFormat.BGRA32;
captureObject.StartPhotoModeAsync(c, OnPhotoModeStarted);
}
private void OnPhotoModeStarted(PhotoCapture.PhotoCaptureResult result)
{
if (result.success)
{
isRunning = true;
photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);
}
}
void OnCapturedPhotoToMemory(PhotoCapture.PhotoCaptureResult result, PhotoCaptureFrame frame)
{
if (result.success)
{
if (frame.TryGetCameraToWorldMatrix(out Matrix4x4 cameraToWorldMatrix))
{
Debug.Log("Successfully obtained CameraToWorldMatrix: " + cameraToWorldMatrix.ToString());
}
else
{
Debug.Log("Failed to obtain CameraToWorldMatrix");
}
}
frame.Dispose();
}
}
使用系统集合;
使用System.Collections.Generic;
使用System.Linq;
使用UnityEngine;
使用UnityEngine.Windows.WebCam;
公共类光电捕获控制器:单行为
{
PhotoCapture photoCaptureObject=null;
bool isRunning=false;
void Start()
{
startcroutine(StartCameraCapture());
}
私人IEnumerator StartCameraCapture()
{
if(!Application.HasUserAuthorization(UserAuthorization.WebCam))
{
生成返回应用程序.RequestUserAuthorization(UserAuthorization.WebCam);
}
if(Application.HasUserAuthorization(UserAuthorization.WebCam))
{
Log(“创建PhotoCapture”);
CreateAsync(false,OnPhotoCaptureCreated);
}
其他的
{
Debug.Log(“未授予网络摄像头权限”);
}
}
私有void更新()
{
如果(正在运行)
{
TakePhotoAsync(OnCapturedPhotoToMemory);
}
}
void OnPhotoCaptureCreated(PhotoCaptureCaptureObject)
{
photoCaptureObject=captureObject;
IEnumerable availableResolutions=PhotoCapture.SupportedResolutions;
foreach(可用解决方案中的var res)
{
调试日志(“光电捕获分辨率:+res.width+“x”+res.height);
}
分辨率cameraResolution=availableResolutions.OrderByDescending((res)=>res.width*res.height).First();
CameraParameters c=新的CameraParameters();
c、 全息容量=0.0f;
c、 cameraResolutionWidth=cameraResolution.width;
c、 cameraResolutionHeight=cameraResolution.height;
c、 pixelFormat=CapturePixelFormat.BGRA32;
captureObject.StartPhotoModeAsync(c,OnPhotoModeStarted);
}
已启动PhotoCodes上的私有无效(PhotoCapture.PhotoCaptureResult)
{
如果(结果、成功)
{
isRunning=true;
TakePhotoAsync(OnCapturedPhotoToMemory);
}
}
void onCapturedPhototomory(PhotoCapture.PhotoCaptureResult结果,PhotoCaptureFrame)
{
如果(结果、成功)
{
if(帧TryGetCameraToWorldMatrix(输出矩阵x4x4 cameraToWorldMatrix))
{
Log(“成功获取CameraToWorldMatrix:+CameraToWorldMatrix.ToString());
}
其他的
{
Log(“未能获取CameraToWorldMatrix”);
}
}
frame.Dispose();
}
}
这方面的支持很少,但是所有的代码都在repo中您可以添加您正在使用的代码吗?@derHugo-its基本上是从比特复制并改编的,您使用的是什么版本的unity?是否在任何步骤中发生错误?目前,我们很难从您当前的帖子中找到问题的原因。我们建议您提供MVCE()和重现问题的步骤,以便我们能够找到问题或找到解决方案。@Hernando MSFT您知道有谁没有遇到过这两个问题吗?我可以提供代码,但我真的怀疑问题是否在我这边,因为相同的代码在Hololens上按预期工作1@Hernando-MSFT的问题发生在Unity 2019.2.19和2018.4.17(LTS)上。谢谢,看起来很有用-很遗憾,我现在没有时间检查这个问题