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.

Using Windows.Media.Ocr in Unity for Hololens

I'm trying to use the Windows.Media.Ocr namespace in Unity for Hololens, but I need to import these namespaces according to https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.ocr.aspx:

using Windows.ApplicationModel;
using Windows.Globalization;
using Windows.Graphics.Imaging;
using Windows.UI.Xaml.Controls;
using Windows.Media.Ocr;

When I try to import them into my script, however, the namespace isn't found. Has anyone been able to resolve this issue in Unity? Should I be getting the DLLs for each of these directly and putting them into Unity?



  • S_LinckeS_Lincke
    edited January 2017

    You have to put them (and the calling code as well) inside some preprocessor directives, for example
    \#if !UNITY_EDITOR using Windows.Storage.Streams; using Windows.Media.Ocr; using Windows.Globalization; using Windows.Graphics.Imaging; using System.Runtime.InteropServices.WindowsRuntime; \#endif

    Maybe try UNITY_WSA_10_0 or WINDOWS_UWP instead of ! UNITY EDITOR, which both should be defined in the solution that unity builds for you.

    I tried the same thing but did not succeed. I could not figure out how to convert the byte[] data from the texture in something I could use to create a bitmap decoder from. If you figure out how to do this, I would like to see how.

    edit: code formatting does not like hashtags. the slashes are not there.

  • utekaiutekai ✭✭✭
    edited January 2017

    You're going to find that using any xaml APIs won't be allowed in 3d virtual space, such as running on unity engine. At least I've not found out how to combine the two. Seems one precludes the other. You can switch contexts back and forth, so going from unity to a xaml context and then back to unity engine.

    Likely you'll need to find a way to do the ocr in the background or off hololens if you need it seamlessly integrated. Such as using the ocr in cognitive services and using a client to send pic and retrieve back text. However, it's not worked well for me ... as in works really poorly currently.

Sign In or Register to comment.