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.
Options

Matlab/Unity/C# integration

I was wondering if anyone has experience integrating Matlab into Unity/C#. I have a bunch of image/video processing software I have already developed, and was wondering if it would be possible to utilize those for HoloLens development. For example call a Matlab function.

Any ideas?

Comments

  • Options
    Jarrod1937Jarrod1937 ✭✭✭
    Matlabs programming is already pretty high level. I would look at making a native plugin and migrating your matlab algorithms to it. Largely for performance considerations as the hololens is like a mobile phone in computing power.
  • Options

    I guess the fact that it is high level is what is attractive in terms of testing out ideas, (and the fact that I already have a library of stuff I have written). This is only to help testing/development go smoother.

  • Options
    Jarrod1937Jarrod1937 ✭✭✭

    I am with you, I suppose if you don't mind poor performance, you may be able to find a Matlab c# interpreter of sorts out there. I did a quick search and I found a few people discussing Matlab in .NET. Some look to be even interfacing with Matlab that's installed and having it run and passing the results to .NET. It's something to check out, but will require a bit of effort.

  • Options

    Thanks, I checked those out, will update if I get something working.

  • Options

    I did some poking around, and I couldn't find anything made available publicly. The most plausible suggestion I saw suggested using UDP to transfer data between the Unity application and MatLab.

    ===
    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?)

  • Options
    Jarrod1937Jarrod1937 ✭✭✭
    edited May 2016

    Well, I didn't post any links before because this forum flags my posts for review, but the "dot" thing seems to do the trick. Matlab has .NET libraries you can integrate:
    mathworks dot com/help/matlab/using-net-libraries-in-matlab.html

    You can then make a .NET plugin for Unity. I am not sure, but I'd assume you'd still have to migrate over your code to c#, but you'd at least have the help of Matlab specific functions.

  • Options

    Thanks for the tips, will update more if I can get a smooth Matlab integration up and running.

  • Options

    If I understand correctly you're essentially wanting to call Matlab from C#. I have not had luck using the Matlab COM approach. Instead I preferred using the automation flag.

    Change the following path to your enviro and run this from a command line:
    "C:\Program Files\MATLAB\R2016a\bin\win64\MATLAB.exe -automation"
    This will simply start up a Matlab automation server window.

    The -r switch will automatically run your Matlab function:
    "C:\Program Files\MATLAB\R2016a\bin\win64\MATLAB.exe -automation" -r MyFuncName(param1 param2)

    If you use Powershell instead of cmd.exe you can pipe the Matlab results back to your calling C# app.

    Don't see why you couldn't write a C# app running on Hololens that spawned a remote Powershell instance,(cloud VM or another machine) and retrieved the results. The Hololens would just be the caller/retriever

    N6MAA10816

This discussion has been closed.