简体   繁体   English

我可以在还使用相机的Hololens中录制应用程序的视频吗? 有办法做到这两者吗?

[英]Can I record a video of an app in the Hololens that also uses the camera? Is there a way to do both?

I am developing an application in the Unity engine for the Microsoft Hololens that uses the camera to take pictures. 我正在为Microsoft Hololens在Unity引擎中开发一个使用相机拍照的应用程序。 In our code, first photo mode and the camera is started, the picture is taken, then the camera is disposed of, and photo mode is ended. 在我们的代码中,首先是照片模式,然后启动相机,拍摄照片,然后丢弃相机,然后结束照片模式。 The user must take several pictures over the course of this app for its primary functionality. 用户必须在此应用过程中为其主要功能拍摄几张照片。 The pictures aren't stored anywhere, we only grab colors from them. 图片不会存储在任何地方,我们只能从中获取颜色。

Here is the photo-taking code: 这是拍照代码:

Resolution cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();
targetTexture = new Texture2D(cameraResolution.width, cameraResolution.height);

                // Create a PhotoCapture object
                PhotoCapture.CreateAsync(false, delegate (PhotoCapture captureObject)
                {

                    photoCaptureObject = captureObject;
                    CameraParameters cameraParameters = new CameraParameters();
                    cameraParameters.hologramOpacity = 0.0f;
                    cameraParameters.cameraResolutionWidth = cameraResolution.width;
                    cameraParameters.cameraResolutionHeight = cameraResolution.height;
                    cameraParameters.pixelFormat = CapturePixelFormat.BGRA32;

                    // Activate the camera
                    photoCaptureObject.StartPhotoModeAsync(cameraParameters, delegate (PhotoCapture.PhotoCaptureResult result)
                    {
                        // Take a picture
                        try
                        {
                            Debug.Log("Trying to take photo");
                            photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);
                        }
                        catch (System.ArgumentException e)
                        {
                            Debug.LogError("System.ArgumentException:\n" + e.Message);
                        }
                    });
                });

Which is then disposed of afterwards with: 然后通过以下方式处理:

    void OnStoppedPhotoMode(PhotoCapture.PhotoCaptureResult result)
    {
        // Shutdown our photo capture resource
        Debug.Log("Disposing of camera");
        photoCaptureObject.Dispose();
        photoCaptureObject = null;
    }

This code works perfectly fine for the purpose of our project - we take a picture and take a color from it each time the user taps on an object. 对于我们的项目而言,此代码工作得非常好-每次用户点击一个对象时,我们都会为其拍照并为其着色。

Since this is for a senior design project in a CS course, we are expected to show a video or a live demo to the class. 由于这是针对CS课程中的高级设计项目的,因此我们希望向全班展示视频或现场演示。

However, recording is always stopped as soon as our application attempts to take a picture. 但是,一旦我们的应用程序尝试拍照,记录总是会停止。 We are unable to both record a video with the webcam and also to take pictures using our above code while it is recording. 我们既不能使用网络摄像头录制视频,也无法在录制时使用上述代码来拍照。 This makes sense, it seems like our application has to preempt the webcam from the recording process in order to use it. 这很有道理,似乎我们的应用程序必须在录制过程中抢占网络摄像头才能使用它。 This also applies to streaming video through the device portal. 这也适用于通过设备门户网站流式传输视频。

What this means is that we can never record a demo of our functioning project. 这意味着我们永远无法记录正在运行的项目的演示。 The video recording always ends as soon as the camera is accessed by our app. 只要我们的应用程序访问了相机,视频记录就会始终结束。

I have found posts and threads from years ago asking about this, but none have ever been resolved. 几年前,我发现有帖子和主题对此进行了询问,但都还没有解决。 Is there a known way around this now? 现在有已知的解决方法吗? Any way for me to get a video of my project while still using it to take pictures inside the application? 在仍在使用应用程序内部拍照的同时,我还能获得项目视频吗?

I never found a way to. 我从来没有找到办法。

Not saying its impossible, but with the camera active while your app is open, the developer portal's screen-shot and video-capture features are disabled. 并不是说这是不可能的,而是在打开应用程序的同时激活相机,开发人员门户的屏幕截图和视频捕获功能被禁用。

I used a voice command to release the camera (but not alter the scene) so that I could take screenshots as all I was using the device's cameras for was for Vuforia object recognition, so as long as I didn't move (too much) the screenshots were acceptable. 我使用语音命令释放了相机(但不改变场景),因此我可以拍摄屏幕快照,因为我使用设备的相机的所有目的都是为了识别Vuforia,只要我不动(太多)屏幕截图是可以接受的。

As such I never looked around for another way. 因此,我从来没有环顾四周。 There probably is a way to do it (seeing as Microsoft has been able to present it), but it might not be anything that we, as external developers, can access; 可能有一种方法可以做到(看似Microsoft已经能够展示它),但是作为外部开发人员,我们可能无法访问任何东西。 like a lot of Hololens features. 像很多Hololens功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何访问 Hololens 相机字节到视频 stream - How to access Hololens camera bytes to video stream 不能用hololens录制动画 - can't Record animation with hololens 如何正确重新加载将 MRTK 用于 Hololens2 的 Unity 场景? - How do I properly reload a Unity Scene that uses MRTK for the Hololens2? 如何将我的相机用作 VR 和普通相机 - How can I use my camera as both VR and normal camera 有没有办法在hololens 2应用程序中打开不同的标签? - Is there any way to open different tabs in hololens 2 app? 使用canavas是否可以放大和缩小相机,并且我在Windows Phone应用程序的方向上也有错误 - Using canavas can i Zoom in and Zoom out the camera and i also have error in orientation its a Windows Phone app 我们可以将HoloLens应用设计为应用而非游戏吗? - Can we design a HoloLens app as an App, not a game? 我无法从相机EmguCV获取视频 - I can not get video from the camera EmguCV 如何将HoloLens应用程序的轻击手势转换为桌面应用程序的鼠标单击? - How can I convert a tap gesture for my HoloLens App to a mouse click for my Desktop App? 在 Unity 中,为什么我可以通过按下按钮将相机切换到 WorldView,但不能在使用 Face Manager 的同时在开始或更新循环中执行此操作? - In Unity, why can I switch the Camera to WorldView with a button press but cannot do it in the Start or Update loop while also using Face Manager?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM