Пример #1
0
 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
        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;

                if (Type != SensorType.NetworkClient)
                {
                    _mediaCapture?.Dispose();
                    _mediaCapture = null;
                }
                else
                {
                    _sensorConnection.Dispose();
                    _sensorConnection = null;
                }
            }).AsAsyncAction());
        }
 internal BodyIndexFrameArrivedEventArgs(BodyIndexFrameReader source, SoftwareBitmap bitmap, CameraIntrinsics intrinsics)
 {
     Source           = source;
     Bitmap           = bitmap;
     CameraIntrinsics = intrinsics;
 }