7 Replies Latest reply on Feb 10, 2017 12:46 PM by Intel Corporation

    Unable to initialize all modalities - Unity C#

    ConstructiveMedia

      Hey,

       

      I'm trying to use the Hand Gesture recognition and 3D Segmentation in unison, they both work flawlessly individually however when they're both enabled together I get the following issue:

       

      Unable to initialize all modalities

      UnityEngine.Debug:LogError(Object)

      RSUnityToolkit.SenseToolkitManager:OnEnable() (at Assets/RSUnityToolkit/Internals/RealSenseInput/SenseToolkitManager.cs:346)

      RSUnityToolkit.SenseToolkitManager:Update() (at Assets/RSUnityToolkit/Internals/RealSenseInput/SenseToolkitManager.cs:596)

       

      Line 346:

       

       

                  /* Initialize the execution */
                  _sts = SenseManager.Init();
                  if (_sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
                  {
                      if (numberOfEnabledModalities > 0)
                      {
                          Debug.LogError("Unable to initialize all modalities");
                      }
                      return;
                  } 
      

       

      Line 596:

       

      else if (option.RefCounter > 0  && !option.Enabled)
        {
        if (!option.Initialized)
        {
        OnDisable();
                       OnEnable();
                       Start();
        }
      

       

       

      I assume its struggling to initialize all funtions of the camera at the same time, even though the segmentation i imagine uses depth and VGA?

       

      Cheers

        • 1. Re: Unable to initialize all modalities - Unity C#
          MartyG

          In my own Unity project I use multiple types of tracking script simultaneously without conflict (hand, face, gesture).  So it is unusual that using hand and segmentation together would cause a problem.  Admittedly though I have never used segmentation, so have not had the opportunity to experience if the two can conflict.

           

          I remember the fun I had editing this file (SenseToolkitManager) in 2014 to add an 'if camera not present' status.  You have to be very careful in modding it, as one small change can make the whole house of cards fall down!

           

          I suspect I may have had the same problem as you back then, though I cannot recall it, as I have apparently edited the troublesome lines out of my version of SenseToolkitManager with no ill effects.

           

            /* Initialize the execution */

                      _sts = SenseManager.Init();

                      if (_sts < pxcmStatus.PXCM_STATUS_NO_ERROR)

                      {

           

                          return;

                      }

           

          In other words, the four lines I edited out were:

           

          if (numberOfEnabledModalities > 0)

                          {

                              Debug.LogError("Unable to initialize all modalities");

                          }

          • 2. Re: Unable to initialize all modalities - Unity C#
            ConstructiveMedia

            I edited out those exact lines just before posting which resulted in it not longer popping up but the whole thing just remains blank and the camera isnt initialized, the hand gestures work but not the camera segmentation in this case. ODdly enough though the backgrond removal and sphere grabbing transform work in perfect unison together.

            • 3. Re: Unable to initialize all modalities - Unity C#
              MartyG

              I've attached the code of my SenseToolkitManager in a Word doc, with my camera-present check removed.  Since I can't recall all the edits I did.  If you select-all and copy on the doc contents and then select-all and paste on your SenseToolkitManager script, you may have better luck.  If it doesn't work, you can always ctrl-Z to undo and restore your own script.

              • 4. Re: Unable to initialize all modalities - Unity C#
                ConstructiveMedia

                Hey MartyG,

                 

                Thanks for that, unfortunately it kicks out even more errors, one of which is the same error that I believe was causing the segmentation to fail:

                 

                NullReferenceException: Object reference not set to an instance of an object
                Draw3DSegmentation.SetSenseOptions () (at Assets/RSUnityToolkit/Internals/Actions Utils/Draw3DSegmentation.cs:39)
                Draw3DSegmentation.Start () (at Assets/RSUnityToolkit/Internals/Actions Utils/Draw3DSegmentation.cs:107)
                

                 

                 

                It's no longer assignign the texture to the texture slow in the Segmentation script (which was working fine before) so I assume theres some check failing.

                 

                Other lines are:

                 

                NullReferenceException: Object reference not set to an instance of an object
                Draw3DSegmentation.UnsetSenseOptions () (at Assets/RSUnityToolkit/Internals/Actions Utils/Draw3DSegmentation.cs:47)
                Draw3DSegmentation.OnDisable () (at Assets/RSUnityToolkit/Internals/Actions Utils/Draw3DSegmentation.cs:148)
                

                 

                 

                Regards,

                • 5. Re: Unable to initialize all modalities - Unity C#
                  MartyG

                  Oops!  Although I removed my camera-present checker, I forgot to remove the references to its related objects (which are only in my project) at the top of the script on lines 29 and 30, and 144 and 145.  My bad!  That is surely what is causing the object reference errors.  I'm very sorry!

                   

                  Here's the code again (attached) with those lines edited out.

                  • 6. Re: Unable to initialize all modalities - Unity C#
                    ConstructiveMedia

                    Hey,

                     

                    No problems at all! The issue is still persisting, the hand works but the camera 3D segmentation doesn't with that script. (And the modalities error doesn't come up as its been removed from the code). I'm wondering if its a USB 3.0 power issue again (I'll try a powered usb 3.0 hub tomorrow) or the order in which they're been initialed (Ie Hand then camera or camera then hand). 

                     

                    Very confusing error!

                     

                    Regards

                    • 7. Re: Unable to initialize all modalities - Unity C#
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Hi ConstructiveMedia,

                      Do you still need assistance with this thread? Does the issue persist after using a powered USB 3.0 hub and changing the initialization order?

                      -Sergio A