コード例 #1
0
ファイル: Sensor.cs プロジェクト: jmarcincin/MultiK2
 public IAsyncOperation <BodyIndexFrameReader> OpenBodyIndexFrameReaderAsync()
 {
     return(Task.Run(async() =>
     {
         if (BodyIndexReader == null)
         {
             if (Type == SensorType.NetworkClient)
             {
                 BodyIndexReader = new BodyIndexFrameReader(this, _networkClient);
             }
             else
             {
                 var bodyIndexSourceInfo = _sourceGroup.SourceInfos.Where(si => si.SourceKind == MediaFrameSourceKind.Custom);
                 foreach (var sourceInfo in bodyIndexSourceInfo)
                 {
                     MediaFrameSource customSource;
                     if (_mediaCapture.FrameSources.TryGetValue(sourceInfo.Id, out customSource) &&
                         customSource.CurrentFormat.MajorType == "Video" &&
                         customSource.CurrentFormat.Subtype == "L8")
                     {
                         var bodyIndexMediaReader = await _mediaCapture.CreateFrameReaderAsync(customSource);
                         BodyIndexReader = new BodyIndexFrameReader(this, bodyIndexMediaReader);
                         break;
                     }
                 }
             }
         }
         await BodyIndexReader?.OpenAsync();
         return BodyIndexReader;
     }).AsAsyncOperation());
 }
コード例 #2
0
ファイル: Sensor.cs プロジェクト: jmarcincin/MultiK2
        public IAsyncAction CloseAsync()
        {
            return(Task.Run(async() =>
            {
                await BodyIndexReader?.CloseAsync();
                BodyIndexReader?.Dispose();
                BodyIndexReader = null;

                await BodyReader?.CloseAsync();
                BodyReader?.Dispose();
                BodyReader = null;

                await ColorReader?.CloseAsync();
                ColorReader?.Dispose();
                ColorReader = null;

                await DepthReader?.CloseAsync();
                DepthReader?.Dispose();
                DepthReader = null;

                AudioReader?.Close();
                AudioReader?.Dispose();
                AudioReader = null;

                _mediaCapture?.Dispose();
                _mediaCapture = null;

                _networkClient?.CloseConnection();
                _networkClient = null;

                _networkServer?.CloseConnection();
                _networkServer = null;
            }).AsAsyncAction());
        }