orbbec / OrbbecUnitySDK

Apache License 2.0
14 stars 3 forks source link

Improvement for OrbbecPipeline.cs #4

Open noemis84 opened 5 months ago

noemis84 commented 5 months ago

I had problems with the InitConfig() function in OrbbecPipeline.cs - it doesn't work with only one profile (because the -1 in the for loop) and also throws a lot of senseless warnings about "missing" profiles. So I fixed and simplified it. Could maybe adjusted:

private void InitConfig()
        {
            config = new Config();

            for (int i = 0; i < orbbecProfiles.Length; i++)
            {            
                var streamProfile = FindProfile(orbbecProfiles[i], StreamType.OB_STREAM_COLOR);
                if (streamProfile != null)
                {
                    config.EnableStream(streamProfile);
                    break;
                }

                streamProfile = FindProfile(orbbecProfiles[i], StreamType.OB_STREAM_DEPTH);
                if (streamProfile != null)
                {
                    config.EnableStream(streamProfile);
                    break;
                }            

                streamProfile = FindProfile(orbbecProfiles[i], StreamType.OB_STREAM_IR);
                if (streamProfile != null)
                {
                    config.EnableStream(streamProfile);
                    break;
                }

                streamProfile = FindProfile(orbbecProfiles[i], StreamType.OB_STREAM_IR_LEFT);
                if (streamProfile != null)
                {
                    config.EnableStream(streamProfile);
                    break;
                }

                streamProfile = FindProfile(orbbecProfiles[i], StreamType.OB_STREAM_IR_RIGHT);
                if (streamProfile != null)
                {
                    config.EnableStream(streamProfile);
                    break;
                }
            }
        }
noemis84 commented 4 months ago

In other examples it may not work, because multiple profiles shall be enabled. So maybe not the best way, but in my case it works.