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.

Mixed Reality Capture Hololens Failure - Failed capturing photo (hr = 0x887A0005)

(Posted concurrently via StackOverflow: http://stackoverflow.com/questions/39420707/mixed-reality-capture-hololens-failure-failed-capturing-photo-hr-0x887a0005)

Currently working on a feature in our Hololens application that allows the user to take Mixed Reality Capture photos on command.

My first stab at this involved verbatim copy and pasting the code snippets from this tutorial:

https://developer.microsoft.com/en-us/windows/holographic/locatable_camera_in_unity

Specifically, only the snippets in sections "Common Set Up for PhotoCapture" and "Capture a Photo to a File".

When testing in the Unity player, photo capture worked seamlessly.

However, when using the same feature when deployed to the Hololens, the following error would show up in the Debug log:

" Failed capturing photo (hr = 0x887A0005) "

In addition to this, OnCapturedPhotoToDisk callback function defined in my file and passed in as the OnCapturedPhotoToDiskCallback to the photoCaptureObject.TakePhotoAsync(...) function was not called at all.

I'm quite at a loss with how to proceed, besides looking to examples of using other API's to access Mixed Reality Capture. It seems to me there is a lot of seemingly contradictory information on the topic, or perhaps just a bunch of different API's to access the MRC resources available on the Hololens - but maybe I am just missing a very obvious detail!

Has anyone else seen such an error when trying to use this tutorial as a starting point?

P.S. Would like to mention that I am setting the Webcam and Microphone property to enabled in my Player Settings in Unity, as detailed in the tutorial.

Answers

  • ahillierahillier mod
    edited September 2016

    @brandonstchow,
    I copied and pasted the same code into a sample project today and was able to take a picture without error. The only difference between my code vs the sample code was that I moved the 'CreateAsync' call to the handler for my keyword recognizer instead of having it in the start method.

        // Use this for initialization
        void Start ()
        {
            // Setup a keyword recognizer.
            List<string> keywords = new List<string>();
            keywords.Add("Take Picture");
            keywordRecognizer = new KeywordRecognizer(keywords.ToArray());
            keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
            keywordRecognizer.Start();  
        }
    
        // Handle the keyword to take a picture.
        private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
        {
            PhotoCapture.CreateAsync(false, OnPhotoCaptureCreated);
        }
    

    Double-check that your Package.appmanifest file has the correct capabilities enabled (Microphone and Webcam). If you happened to build before setting these capabilities in Unity, then they would not have been picked-up by the VS solution. You can manually check them in VS to fix it, or delete your build folder and then rebuild from Unity again to get back in sync.

    The sample code will save your picture to the persistentDataPath. To double-check that your pictures were saved correctly, you can open the Device Portal, select the 'File Explorer' option and then navigate to the LocalAppData\\LocalState directory.

    Note: Holograms will not be visible in photos taken by the locatable camera (webcam). If you need to capture holograms in a photo, then you should use MRC via Cortana ("Hey Cortana, Take a Picture") or by pressing the volume up and down buttons simultaneously on your HoloLens. When you take a photo like this, you can find it under the Device Portal's 'Mixed Reality Capture' page. Also, this method will work with any app and does not require any additional code or capabilities to work.

  • edited July 2017

    I am having the same issue, Webcam and Microphone are checked in Unity's player settings. And it was already a part of my keword recognizer. I want to note, however, that you just need to set the first parameter of CreateAsync to true in order to see holograms in the capture as well as setting the CameraParameters object's hologramOpacity to 1.0f, or whatever transparency.

  • Are either of you using Vuforia? You need to disable Vuforia's capture before trying to take a photo.

    Taqtile

  • I am not using Vuforia that I know of... If I were, how would I find that out?

  • Pretty certain I'm not using it though.

  • You'd have to download and import it. You'd know.

    That was my main issue when trying to capture photos. Not sure what else could be off. Just noticed this thread is from Sept 2016... What version of Unity are you using?

    Can you post some of your log?

    Taqtile

  • Yes but it will be a bit. I'll be back on this project tomorrow. Thank you for your help.

  • DiegoVDiegoV ✭✭

    I am having the same issue. The issue comes to me when debugging. I think when you do not close the camera this issue raises.

      void OnStoppedPhotoMode(PhotoCapture.PhotoCaptureResult result)
        {
            // Shutdown the photo capture resource
            photoCaptureObject.Dispose();
            photoCaptureObject = null;
        }
    
  • edited July 2017

    I am now using Unity 2017 but had the issue with 5.6.2 as well. This is the only clue in the output window in VS:

    Failed capturing photo (hr = 0xC00D3E85)

    (Filename: C:/buildslave/unity/build/Runtime/VR/HoloLens/WebCam/PhotoCaptureOperation.cpp Line: 111)

    When I try taking a photo again:
    Photo Mode has already been started.

    (Filename: C:/buildslave/unity/build/Runtime/VR/HoloLens/WebCam/PhotoCapture.cpp Line: 535)

    Unable to start photo mode!

    (Filename: C:/buildslave/unity/build/artifacts/generated/Metro/runtime/DebugBindings.gen.cpp Line: 51)

    I'm also using HoloToolkit, but it is not accessing the actual webcam as far as I can tell.

  • Okay, so I was thinking - what could even POSSIBLY be using the webcam. I still can't tell if it is actually using the webcam, but I just disabled spatial mapping and spatial understanding, which were running constantly, and everything is good. I can only think that if the framerate is possibly below a certain level (which I'm sure those things were) it cannot initiate photo capture mode or video capture mode.

    I will try and delve further and post my final solution whenever I chance to get there. Thank you for your help.

  • From what I can tell, the problem seems to stem from SpatialUnderstandingDll.Imports.SpatialUnderstanding_Init();
    called in the Start method. Something it uses (although not visible to me) seems to be doing it. I tried numerous things, including calling
    SpatialUnderstandingDll.Imports.SpatialUnderstanding_Term();
    which is called in the destroy method, but it didn't seem to do anything at all. So I figured, the easiest way to get something to free up whatever resources is to call its destroy method.. So.. Yeah, probably not the BEST or CLEANEST way to solve the problem, but I just do:

        Destroy(spatialUnderstanding.GetComponent<SpatialUnderstanding>());
        PhotoCapture.CreateAsync(true, OnPhotoCaptureCreated);
    

    Where that is called, and then:

        photoCaptureObject.Dispose();
        photoCaptureObject = null;
        spatialUnderstanding.AddComponent<SpatialUnderstanding>();
    

    Where that occurs in the same script. It works for my purposes, for now at least. Although now I am having a separate issue where the microphone is not recognizing my command to stop the video, or anything else until I exit the app.... I am going to assume they are unrelated, but who knows..

    If anyone else has any other suggestions or input I am all ears. Thank you.

  • Maybe you're not aware of that, but Spatialunderstanding isn't meant to be constantly running in the background. It's mainly used when you want a precise scan with objects recognition. So you kinda run it, let the user scan whatever he wants, then turn it off when he's done scanning

Sign In or Register to comment.