# Trying to understand FusionConfiguration

**URL:** <https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971>\
**Category:** C#\
**Created:** [April 10, 2024, 1:04pm UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971 "2024-04-10T13:04:46Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![VR\_Neo](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/v/97f17d/32.png) [@VR\_Neo](https://community.stereolabs.com/u/VR_Neo)\
**Post date:** [April 10, 2024, 1:04pm UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/1 "2024-04-10T13:04:47Z")

</div>

Hello!

I am trying to understand data contained in **FusionConfiguration** that is created from the **ReadConfigurationFile** method. My setup is two cameras ZED2 calibrated with ZED360 app with the 4.1 SDK.  
When I check data from script or debug, they don’t seem consistent compared to the json file.

[multiSetupZed4\_1.json](https://community.stereolabs.com/uploads/short-url/55zn2dVQNPQ4THNkNCN9qnvssxs.json) (1.1 KB)

```auto
var multiCamConfig = Config.ConfigDirectory + Config.MULTI_CAMERA_FILENAME;
var fusion = new Fusion();
fusion.ReadConfigurationFile(new StringBuilder(multiCamConfig), COORDINATE_SYSTEM.LEFT_HANDED_Y_UP, UNIT.METER, ref configurations, ref nbCameras);

```

The content of _configurations_ is an array of 20 elements where the three first are:  
 ![firstThree](https://community.stereolabs.com/uploads/default/original/2X/e/e3b42f3cdccbfe012e39d38b396f95e70470c7cc.png)

and the seventeen others are:  
 ![seventeenOthers](https://community.stereolabs.com/uploads/default/original/2X/b/b4492b80529444606aad60dabe1ef279b167d99f.png)

I think there is a problem with the **FusionConfiguration** class that has an enum **INPUT\_TYPE** _inputType_ attribute but is supposed to have a struct **InputType** _inputType_ that contain this enum instead.

---

<div class="post-metadata">

**Author:** ![JPlou](https://community.stereolabs.com/user_avatar/community.stereolabs.com/jplou/32/1012_2.png) [@JPlou](https://community.stereolabs.com/u/JPlou)\
**Post date:** [April 11, 2024, 4:30pm UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/2 "2024-04-11T16:30:47Z")

</div>

Hey @VR_Neo,

Thank you for the report, that’s a good catch. We’ll update it soon.

In the meantime, you can fix it on your side from the sources, the building instructions are [on the repo](https://github.com/stereolabs/zed-csharp-api).  
You should only have to change INPUT\_TYPE to InputType here: [zed-csharp-api/Stereolabs.zed/src/ZEDCommon.cs at 80fc742a9c17973778167afeb7d6e17d3938f95e · stereolabs/zed-csharp-api · GitHub](https://github.com/stereolabs/zed-csharp-api/blob/80fc742a9c17973778167afeb7d6e17d3938f95e/Stereolabs.zed/src/ZEDCommon.cs#L5121)

---

<div class="post-metadata">

**Author:** ![VR\_Neo](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/v/97f17d/32.png) [@VR\_Neo](https://community.stereolabs.com/u/VR_Neo)\
**Post date:** [May 3, 2024, 7:54am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/3 "2024-05-03T07:54:13Z")

</div>

Hello!

Fixing _InputType_ is not enought to make Fusion working, I had to do a lot of minor changes in both C and C# wrapper.  
One other important fix is in _ZEDFusion.RetrieveBodies_ method that transmit bodies as **ref** instead of **IntPtr** compared to _ZEDCamera.RetrieveBodies_ otherwise there is a Marshall error.

```auto
        /// <summary>
        /// retrieves the body data, can be the fused data (default), or the raw data provided by a specific sender
        /// </summary>
        /// <param name="bodies"></param>
        /// <param name="rtparams"></param>
        /// <param name="uuid"></param>
        /// <returns></returns>
        public FUSION_ERROR_CODE RetrieveBodies(ref Bodies bodies, ref BodyTrackingFusionRuntimeParameters rtparams, CameraIdentifier uuid)
        {
            //(Changed by VR) original method is commented, new is based on ZedCamera.RetrieveBodies
            //return dllz_fusion_retrieve_bodies(ref bodies, ref rtparams, uuid);
            
            IntPtr p = Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf<sl.Bodies>());
            sl.FUSION_ERROR_CODE err = dllz_fusion_retrieve_bodies(p, ref rtparams, uuid);

            if (p != IntPtr.Zero)
            {
                bodies = (sl.Bodies)Marshal.PtrToStructure(p, typeof(sl.Bodies));
                Marshal.FreeHGlobal(p);
                return err;
            }
            else
            {
                Marshal.FreeHGlobal(p);
                return sl.FUSION_ERROR_CODE.FAILURE;
            }
        }

```

I still have a bad result using _Fusion.ReadConfigurationFile_ method but I achieved a functional Multicamera body-tracking by parsing the ZED360 by myself to generate the required **FusionConfiguration[]**.

---

<div class="post-metadata">

**Author:** ![Rudiz](https://community.stereolabs.com/user_avatar/community.stereolabs.com/rudiz/32/3372_2.png) [@Rudiz](https://community.stereolabs.com/u/Rudiz)\
**Post date:** [July 29, 2024, 9:38am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/4 "2024-07-29T09:38:57Z")

</div>

Hello @JPlou,  
I’ve faced the same problem.  
I’ve managed to parse the json in order to create the right **FusionConfiguration[]** object.  
However I get an error on the line:

> FUSION\_ERROR\_CODE state = fusion.Subscribe(ref uuid, jsonConfigFilename, ref configurations[i].position, ref configurations[i].rotation);

the _ **state** _ value is _INVALID\_IP\_ADDRESS_ even though I have two zed2 connected via USB on the same pc and the json config “type” is set to “USB\_SERIAL” on both cameras.  
It seems that I cannot pass the **FusionConfiguration[]** object to the fusion.Subscribe method, but only the path to the json config filename.

Here’s my json calibration (sorry I cannot upload files):

```json
{
    "21772418": {
        "input": {
            "fusion": {
                "type": "INTRA_PROCESS"
            },
            "zed": {
                "configuration": "21772418",
                "type": "USB_SERIAL"
            }
        },
        "world": {
            "rotation": [
                0.0,
                0.0,
                0.0
            ],
            "translation": [
                0.0,
                -0.6605420112609863,
                0.0
            ]
        }
    },
    "26675215": {
        "input": {
            "fusion": {
                "type": "INTRA_PROCESS"
            },
            "zed": {
                "configuration": "26675215",
                "type": "USB_SERIAL"
            }
        },
        "world": {
            "rotation": [
                0.00506022060289979,
                1.0849298238754272,
                -0.03133285418152809
            ],
            "translation": [
                -0.9777283072471619,
                -0.5663315653800964,
                0.7421109676361084
            ]
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Rudiz](https://community.stereolabs.com/user_avatar/community.stereolabs.com/rudiz/32/3372_2.png) [@Rudiz](https://community.stereolabs.com/u/Rudiz)\
**Post date:** [August 26, 2024, 9:39am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/5 "2024-08-26T09:39:37Z")

</div>

Hi @JPlou ,  
any news about the fix of this issue in the next release?

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [September 9, 2024, 9:36am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/6 "2024-09-09T09:36:35Z")

</div>

Hi,

I wanted to let you know that I’m currently working on it, fixing the Fusion API as well as implementing a sample similar to the one available in C++ (and python).

---

<div class="post-metadata">

**Author:** ![VR\_Neo](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/v/97f17d/32.png) [@VR\_Neo](https://community.stereolabs.com/u/VR_Neo)\
**Post date:** [September 9, 2024, 10:27am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/7 "2024-09-09T10:27:42Z")

</div>

Hi Benjamin!

That’s good news !

My Rider IDE alert me of allocated memory issues in SOH when I’am using **fusion.RetrieveBodies** method.

This happens using **ref** or my own **IntPtr** management as above.  
On Windows it provocs my program to crash after few minutes because of “ucrtbase.dll, version 10.0.19041.3636”.

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [September 9, 2024, 12:18pm UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/8 "2024-09-09T12:18:53Z")

</div>

Thanks for the info, I’ll pay attention to that.

I have a question for you as you are an active user of our CSharp wrapper.

I’m considering updating the wrapper to (most likely) .net8.  
I’m not an expert but it does not seem to require a lot of changes. Is it something that you (or any other user) might be interested in?  
Do you think dropping the support of the current version for .net8 is doable or should we keep both versions?

Thank you for your feedback.

---

<div class="post-metadata">

**Author:** ![VR\_Neo](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/v/97f17d/32.png) [@VR\_Neo](https://community.stereolabs.com/u/VR_Neo)\
**Post date:** [September 10, 2024, 8:12am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/9 "2024-09-10T08:12:20Z")

</div>

Hi Benjamin,

I don’t know for .net8 because I am using .Net6 (on Jetson with Ubuntu 20.04 and Windows 10 X64) on my project. Anyway having .Net\* instead of .NetFramework sounds better to ease wrapper deployment on both platforms.

I can notice that I have built C# wrapper for Windows X64 in .NetFramework4.8 and only difference was to add a constructor to **RegionOfInterestParameters** in **ZEDCommons.cs** - line 605. On Jetson I am using mcs compiler.

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [September 10, 2024, 8:45am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/10 "2024-09-10T08:45:15Z")

</div>

Ok I’ll consider it then and see if I can fit this task in my backlog for 4.2.

I was thinking about .net 8 because it seems the support for .net6 will end very ([.NET and .NET Core official support policy](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core)).

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [September 11, 2024, 8:35am UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/11 "2024-09-11T08:35:30Z")

</div>

Hi @here,

I can finally share an updated version of the csharp wrapper with a working Fusion API (as well as a sample for body tracking fusion).

For now, both the sample and the package are available here : [body-tracking-fusion/csharp at master · Bvallon-sl/body-tracking-fusion · GitHub](https://github.com/Bvallon-sl/body-tracking-fusion/tree/master/csharp)

Note this requires the ZED SDK 4.1.4 that just came out yesterday to work.  
The sample is not completely finished, some features available in cpp are not implemented yet.

To use a local Nuget package, please follow the step described in this link : [c# - Getting local Nuget Package into Visual Studio Solution - Stack Overflow](https://stackoverflow.com/questions/63828503/getting-local-nuget-package-into-visual-studio-solution)

Let me know if you find any additional bug or API issues.

Best regards,  
Benjamin Vallon

---

<div class="post-metadata">

**Author:** ![VR\_Neo](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/v/97f17d/32.png) [@VR\_Neo](https://community.stereolabs.com/u/VR_Neo)\
**Post date:** [September 11, 2024, 2:42pm UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/12 "2024-09-11T14:42:40Z")

</div>

Hi Benjamin!

I don’t see anything about Fusion on Releases notes of downloading SDK page. As you said that we need to upgrade SDK, do you know if there is any change that can impact captation or memory management when retrieving data?

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [September 11, 2024, 3:32pm UTC](https://community.stereolabs.com/t/trying-to-understand-fusionconfiguration/4971/13 "2024-09-11T15:32:17Z")

</div>

I just updated the nuget package on my repo.  
You should not need to use the latest version now.

Actually, if you downloaded the latest SDK Version yesterday, you might want to resintall it again, we just published a hotfix. Sorry for the inconvenience.

You are right, there is no change regarding the Fusion module in this patch, it will perform the same.
