Hello everyone.

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.

Unable to capture holograms with Unity PhotoCapture

I am using UNITY 5.5.2f1.
I would like to do Mixed Reality Capture of hololens.
I was able to do the capture with reference to the script below.

https://docs.unity3d.com/Manual/windowsholographic-photocapture.html

However, the image contains only the camera's capture, not the 3D objects.
Even if you set hologramOpacity to 1.0.

How can I solve it?

Thanks.

Best Answer

Answers

  • I followed the instructions for the locatable camera and it worked fine for me.
    The code uses Application.persistentDataPath as directory, which points to %userprofile%\AppData\Local\Packages\[productname]\LocalState. You can use the device portals file explorer to access this directory.

  • I'm running into the exact same issue! I declare capture holograms with PhotoCapture.CreateAsync(true, OnPhotoCaptureCreated); [first argument is false in the tutorial], and then set hologramOpacity to 1.0f... this might solve your issue, but for me I'm still not getting holograms.

    I don't have the file explorer in the device portal, but I'm using a script that copys the photo from the local directory into the camera roll which I do see in the file explorer.

  • Thanks JannikLassahn.

    Photos are saved in LocalState.
    However, hologram such as 3D model is not attached
    I will write my code.
    Is there any difference from your code?

    `
    //

    public void TakeScreenShot(){

        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 = 1.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
                //photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);
    
                string filename = string.Format(@"CapturedImage{0}_n.jpg", Time.time);
                string filePath = System.IO.Path.Combine(Application.persistentDataPath, filename);
                photoCaptureObject.TakePhotoAsync(filePath, PhotoCaptureFileOutputFormat.JPG, OnCapturedPhotoToDisk);
    
            });
        });
    
    }
    
    
    void OnCapturedPhotoToDisk(PhotoCapture.PhotoCaptureResult result)
    {
        if (result.success)
        {
            Debug.Log("Saved Photo to disk!");
            photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode);
        }
        else
        {
            Debug.Log("Failed to save Photo to disk");
        }
    }
    
    void OnStoppedPhotoMode(PhotoCapture.PhotoCaptureResult result)
    {
        photoCaptureObject.Dispose();
        photoCaptureObject = null;
    }
    

    `

  • @hys73 Do you still have this problem? I could share my sample project, maybe it works for you.

  • Thank you JannikLassahn.

    I have not solved this problem yet.
    I would like you to share your code if possible.

    Regards.

  • Thank you JannikLassahn.

    Great!

    It went well.

    Thank you very much!

Sign In or Register to comment.