The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Locatable camera in Unity. When will Hologram photo capture will be enabled?
The documentation states the following:
-Holograms cannot be captured in images and videos regardless of settings
-Hologram capture will be enabled by a future update
I am just wondering, when the community will have access to this feature? What is the best way to go about photo capturing mixed reality within Unity application?
Best Answer
-
OptionsPatrick mod
So getting holograms in your photos in Unity is tricky because you have to implement interfacing with the webcam with the Windows.Media.Capture interface rather than the interface Unity provides. TBH, I just figured this out yesterday to help someone else out, but here's some really messy code that will take pictures with holograms in them.
using UnityEngine; using System.Collections.Generic; #if !UNITY_EDITOR using System; using Windows.Media.MediaProperties; using Windows.Storage; using Windows.Foundation.Collections; using Windows.Media.Effects; using Windows.Media.Capture; #endif public class AnotherPicOMatic : MonoBehaviour { #if !UNITY_EDITOR public class VideoMRCSettings : IVideoEffectDefinition { public string ActivatableClassId { get { return "Windows.Media.MixedRealityCapture.MixedRealityCaptureVideoEffect"; } } public IPropertySet Properties { get { return _Properties; } } private IPropertySet _Properties; public VideoMRCSettings() { _Properties = (IPropertySet)new PropertySet(); _Properties.Add("HologramCompositionEnabled", true); _Properties.Add("RecordingIndicatorEnabled", false); _Properties.Add("VideoStabilizationEnabled", false); _Properties.Add("VideoStabilizationBufferLength", 0); _Properties.Add("GlobalOpacityCoefficient", 0.9f); } } MediaCapture captureManager; bool open = false; async private void InitCamera_Click() { Debug.Log("Init"); captureManager = new MediaCapture(); MediaCaptureInitializationSettings mcsi = new MediaCaptureInitializationSettings(); await captureManager.InitializeAsync(); IVideoEffectDefinition ved = new VideoMRCSettings(); await captureManager.AddVideoEffectAsync(ved, MediaStreamType.Photo); open = true; Debug.Log("Done"); } async private void CapturePhoto_Click() { Debug.Log("Photo"); ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg(); // create storage file in local app storage StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync( "TestPhoto.jpg", CreationCollisionOption.GenerateUniqueName); // take photo await captureManager.CapturePhotoToStorageFileAsync(imgFormat, file); open = true; Debug.Log("done"); } // Use this for initialization void Start () { InitCamera_Click(); } // Update is called once per frame void Update () { if (Time.frameCount % 600 == 0 && open) { open = false; CapturePhoto_Click(); } } #endif }
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.(Daddy, what does 'now formatting drive C:' mean?)
6
Answers
You can get an image which includes what the hololens camera sees as well as any holograms in view. Use PhotoCapture class and when calling StartPhotoModeAsync then ensure you pass CameraParameters which have hologramOpacity set to 0 (I think 0 so it is not opaque).
After making sure hologramOpacity was set it 0 in CameraParameters. I still didn't get a successful mixed reality capture. After checking the code I released "PhotoCapture.CreateAsync" bool showHolograms was set to false. After turning showHolograms bool to true, mixed capture still didn't work. Any other suggestions to try?
So getting holograms in your photos in Unity is tricky because you have to implement interfacing with the webcam with the Windows.Media.Capture interface rather than the interface Unity provides. TBH, I just figured this out yesterday to help someone else out, but here's some really messy code that will take pictures with holograms in them.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
Thank you Patrick for the code! I'll check it out and let you know the results.
hello,
I used the sample code for taking pictures, here https://developer.microsoft.com/en-us/windows/holographic/locatable_camera_in_unity
Then modified opacity to 1 from 0.
CameraParameters c = new CameraParameters();
c.hologramOpacity = 1.0f;
For C++ there is a Holographic Mixed Reality Capture Example on GitHub
@Patrick
I want to record mixedreality video in unity. I already tried using VideoCapture ( https://developer.microsoft.com/en-us/windows/holographic/locatable_camera_in_unity) .
but hologram is not appeared even if cameraParameters.hologramOpacity = 1.0f.
how can I use above code for capturing video instead of picture?
As of a couple of months ago, the Hololens is able to capture mixed-reality photos using the locatable-camera standard code (i.e. PhotoCapture.CreateAsync).
You no longer need to use the technique posted by Patrick above (though it must have helped a lot back then).
Just ensure that you set the showHolograms parameter to 'True' when calling CreateAsync, and that you set the hologramsOpacity under cameraParameters to 1.0f as utekai's answer suggested above.