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.

Cannot access HoloLens' Camera Roll from Unity App

Greetings,

I am trying to access and display JPGs from the HoloLens' Camera Roll in my Unity app.

I am using this code:
imageRootDir = Windows.Storage.KnownFolders.CameraRoll.Path.ToString();
string[] filePaths = System.IO.Directory.GetFiles(imageRootDir);

imageRootDir resolves to this directory:
C:\Data\Users\sally\Pictures\Camera Roll

filePaths returns an array of length zero.

System.IO.Directory.Exists(imageRootDir) returns true.

I can see there are several images in the Camera Roll via the HoloLens file explorer. Any hint what I might be doing wrong in the Unity app?

Thank you for your support.

Best Answer

Answers

  • dbarrettdbarrett ✭✭✭
    edited December 2017

    Have you enabled the Pictures Library permission under the Player Settings?

    I have made an app the can save the photos but, I haven't tried to display them from memory as I display them as soon as I take the picture. The file path you are using is correct.

    Make sure when you are saving/calling from memory it is best to use string filePath = Path.Combine(imageRootPath, filename);

    AR Developer

  • Hey dbarrett, thank you for the reply: I do have Pictures Library enabled.

    The following are currently enabled:
    InternetClient
    InternetClientServer
    PicturesLibrary
    WebCam
    Microphone
    SpatialPerception

    Thank you for the ideas.

  • sallysally
    edited December 2017

    Thank you dbarrett, that solved my problem! I will include some notes below which may help the next user:

    • I had to update Unity's Scripting Runtime Version to "Experimental (.NET 4.6 Equivalent)" in order to get the async/await functionality working.

    • I set up the following using statements:
      using System.Collections.Generic;
      using System;
      #if !UNITY_EDITOR && UNITY_WSA
      using Windows.Storage;
      using Windows.Storage.Search;
      #endif

    • I created a function like this:
      #if !UNITY_EDITOR && UNITY_WSA
      public async void DoTest()
      {
      StorageFolder CameraFolder = Windows.Storage.KnownFolders.CameraRoll;
      IReadOnlyList filesInFolder = await CameraFolder.GetFilesAsync();
      }
      #endif

    filesInFolder then correctly populated to a List of four items.

    Thank you for your support!

Sign In or Register to comment.