Trying to understand FusionConfiguration


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 (1.1 KB)

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:

and the seventeen others are:

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.

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


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.

        /// <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));
                return err;
                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[ ].