private static Microseconds64?GetDeviceTimestamp(Sensor.Capture capture) { using (var image = capture.DepthImage) { return(image?.DeviceTimestamp); } }
public void WriteCapture(Sensor.Capture capture) { if (capture == null) { throw new ArgumentNullException(nameof(capture)); } CheckResult(NativeApi.RecordWriteCapture(handle.ValueNotDisposed, Sensor.Capture.ToHandle(capture))); }
protected bool IsCaptureInInterval(Sensor.Capture capture) { if (capture == null) { return(false); } if (!processingParameters.EndTime.HasValue) { return(true); } var timestamp = GetTimestamp(capture); return(timestamp.HasValue && processingParameters.IsTimeInStartEndInterval(timestamp.Value)); }
/// <summary>Reads the previous capture in the recording sequence.</summary> /// <param name="capture">If successful this contains capture data read from playback. Don't forget to dispose this object after usage.</param> /// <returns> /// <see langword="true"/> - if a capture is returned, /// <see langword="false"/> - if the start of the recording is reached. /// All other failures will throw <see cref="PlaybackException"/> exception. /// </returns> /// <remarks><para> /// This method always returns the previous capture in sequence before the most recently returned capture. /// </para><para> /// The first call to this method after <see cref="SeekTimestamp"/> will return the capture /// in the recording closest to the seek time with all image time stamps less than the seek time. /// </para><para> /// If a call was made to <see cref="TryGetNextCapture(out Sensor.Capture)"/> that returned <see langword="false"/> (which means EOF), the playback /// position is at the end of the stream and this method will return the last capture in the recording. /// </para><para> /// Capture objects returned by the playback API will always contain at least one image, but may have images missing if /// frames were dropped in the original recording. When calling <see cref="Sensor.Capture.ColorImage"/>, /// <see cref="Sensor.Capture.DepthImage"/>, or <see cref="Sensor.Capture.IRImage"/>, /// the image should be checked for <see langword="null"/>. /// </para></remarks> /// <exception cref="ObjectDisposedException">This method cannot be called for disposed object.</exception> /// <exception cref="PlaybackException">Error during reading from recording. See logs for details.</exception> public bool TryGetPreviousCapture(out Sensor.Capture capture) { var res = NativeApi.PlaybackGetPreviousCapture(handle.ValueNotDisposed, out var captureHandle); if (res == NativeCallResults.StreamResult.Eof) { capture = null; return(false); } if (res == NativeCallResults.StreamResult.Succeeded) { capture = Sensor.Capture.Create(captureHandle); return(capture != null); } throw new PlaybackException(FilePath); }
protected bool IsCaptureInInterval(Sensor.Capture capture) { if (capture == null) { return(false); } if (!processingParameters.EndTime.HasValue) { return(true); } var deviceTimestamp = GetDeviceTimestamp(capture); if (deviceTimestamp.HasValue) { deviceTimestamp = deviceTimestamp.Value - RecordConfig.StartTimeOffset; } return(deviceTimestamp.HasValue && processingParameters.IsTimeInStartEndInterval(deviceTimestamp.Value)); }
public bool TryEnqueueCapture(Sensor.Capture capture, Timeout timeout = default(Timeout)) { if (capture == null) throw new ArgumentNullException(nameof(capture)); var res = NativeApi.TrackerEnqueueCapture(handle.ValueNotDisposed, Sensor.Capture.ToHandle(capture), timeout); if (res == NativeCallResults.WaitResult.Timeout) return false; if (res == NativeCallResults.WaitResult.Failed) { handle.CheckNotDisposed(); // to throw ObjectDisposedException() if failure is a result of disposing throw new BodyTrackingException("Cannot add new capture to body tracking pipeline"); } Interlocked.Increment(ref queueSize); QueueSizeIncreased?.Invoke(this, EventArgs.Empty); return true; }
public void EnqueueCapture(Sensor.Capture capture) { var res = TryEnqueueCapture(capture, Timeout.Infinite); System.Diagnostics.Debug.Assert(res); }