7 #ifndef K4A_PLAYBACK_HPP 8 #define K4A_PLAYBACK_HPP 10 #include <k4a/k4a.hpp> 11 #include <k4arecord/playback.h> 43 m_handle = other.m_handle;
44 other.m_handle =
nullptr;
59 m_handle = other.m_handle;
60 other.m_handle =
nullptr;
67 explicit operator bool() const noexcept
76 return m_handle !=
nullptr;
85 k4a_playback_data_block_release(m_handle);
96 return std::chrono::microseconds(k4a_playback_data_block_get_device_timestamp_usec(m_handle));
105 return k4a_playback_data_block_get_buffer_size(m_handle);
114 return k4a_playback_data_block_get_buffer(m_handle);
142 other.m_handle =
nullptr;
161 m_handle = other.m_handle;
162 other.m_handle =
nullptr;
170 explicit operator bool() const noexcept
179 return m_handle !=
nullptr;
188 if (m_handle !=
nullptr)
190 k4a_playback_close(m_handle);
208 calibration.resize(buffer);
209 result = k4a_playback_get_raw_calibration(m_handle, &calibration[0], &buffer);
214 throw error(
"Failed to read raw device calibration from recording!");
228 k4a_result_t result = k4a_playback_get_calibration(m_handle, &calib);
232 throw error(
"Failed to read device calibration from recording!");
245 k4a_result_t result = k4a_playback_get_record_configuration(m_handle, &config);
249 throw error(
"Failed to read record configuration!");
268 *cap =
capture(capture_handle);
276 throw error(
"Failed to get next capture!");
292 *cap =
capture(capture_handle);
300 throw error(
"Failed to get previous capture!");
308 bool get_tag(
const char *name, std::string *out)
const 317 result = k4a_playback_get_tag(m_handle, name, &tag[0], &buffer);
323 tag.resize(buffer - 1);
332 *out = std::move(tag);
356 throw error(
"Failed to get next IMU sample!");
378 throw error(
"Failed to get previous IMU sample!");
388 k4a_result_t result = k4a_playback_seek_timestamp(m_handle, offset.count(), origin);
392 throw error(
"Failed to seek recording!");
402 return std::chrono::microseconds(k4a_playback_get_recording_length_usec(m_handle));
414 k4a_result_t result = k4a_playback_set_color_conversion(m_handle, format);
418 throw error(
"Failed to set color conversion!");
431 k4a_stream_result_t result = k4a_playback_get_next_data_block(m_handle, track, &block_handle);
443 throw error(
"Failed to get next data block!");
455 k4a_stream_result_t result = k4a_playback_get_previous_data_block(m_handle, track, &block_handle);
467 throw error(
"Failed to get previous data block!");
478 size_t data_size = 0;
482 data->resize(data_size);
486 throw error(
"Failed to read attachment!");
505 throw error(
"Failed to open recording!");
The result was successful.
Definition: k4atypes.h:233
The result was successful.
Definition: types.h:130
playback(k4a_playback_t handle=nullptr) noexcept
Creates a k4a::playback from a k4a_playback_t Takes ownership of the handle, i.e. ...
Definition: playback.hpp:136
bool get_previous_data_block(const char *track, data_block *block)
Get the previous data block from the recording.
Definition: playback.hpp:452
k4a_result_t
Result code returned by Azure Kinect APIs.
Definition: k4atypes.h:217
Exception type thrown when a K4A API call fails.
Definition: k4a.hpp:33
playback & operator=(playback &&other) noexcept
Moves another k4a::playback into this k4a::playback; other is set to invalid.
Definition: playback.hpp:156
bool get_next_data_block(const char *track, data_block *block)
Get the next data block in the recording.
Definition: playback.hpp:428
std::chrono::microseconds get_device_timestamp_usec() const noexcept
Get the time stamp in micro seconds for the given data_block.
Definition: playback.hpp:94
Handle to an Azure Kinect capture.
Definition: k4atypes.h:122
k4a_buffer_result_t
Result code returned by Azure Kinect APIs.
Definition: k4atypes.h:231
data_block(k4a_playback_data_block_t handle=nullptr) noexcept
Creates a data_block from a k4a_playback_data_block_t Takes ownership of the handle, you should not call k4a_playback_data_block_release on the handle after giving it to the data_block; the data_block will take care of that.
Definition: playback.hpp:33
void seek_timestamp(std::chrono::microseconds offset, k4a_playback_seek_origin_t origin)
Seeks to a specific time point in the recording Throws error on failure.
Definition: playback.hpp:386
k4a_stream_result_t
Return codes returned by Azure Kinect playback API.
Definition: types.h:128
void reset() noexcept
Releases the underlying k4a_playback_data_block_t; the data_block is set to invalid.
Definition: playback.hpp:81
data_block(data_block &&other) noexcept
Moves another data_block into a new data_block.
Definition: playback.hpp:41
bool get_next_imu_sample(k4a_imu_sample_t *sample)
Get the next IMU sample in the recording.
Definition: playback.hpp:343
IMU sample.
Definition: k4atypes.h:1199
static playback open(const char *path)
Opens a K4A recording for playback.
Definition: playback.hpp:498
data_block & operator=(data_block &&other) noexcept
Moves another data_block into this data_block; other is set to invalid.
Definition: playback.hpp:54
calibration get_calibration() const
Get the camera calibration for the K4A device that made the recording, which is used for all transfor...
Definition: playback.hpp:225
std::vector< uint8_t > get_raw_calibration() const
Get the raw calibration blob for the K4A device that made the recording.
Definition: playback.hpp:200
k4a_record_configuration_t get_record_configuration() const
Gets the configuration of the recording.
Definition: playback.hpp:242
void close() noexcept
Closes a K4A recording.
Definition: playback.hpp:186
playback(playback &&other) noexcept
Moves another k4a::playback into a new k4a::playback.
Definition: playback.hpp:140
bool get_next_capture(capture *cap)
Get the next capture in the recording.
Definition: playback.hpp:261
std::chrono::microseconds get_recording_length() const noexcept
Get the last valid timestamp in the recording.
Definition: playback.hpp:400
Wrapper for k4a_capture_t.
Definition: k4a.hpp:414
k4a_buffer_result_t k4a_playback_get_attachment(k4a_playback_t playback_handle, const char *file_name, uint8_t *data, size_t *data_size)
Reads an attachment file from a recording.
Wrapper for k4a_playback_data_block_t.
Definition: playback.hpp:26
bool get_previous_imu_sample(k4a_imu_sample_t *sample)
Get the previous IMU sample in the recording.
Definition: playback.hpp:365
Handle to a block of data read from a k4a_playback_t custom track.
Definition: types.h:64
k4a_playback_seek_origin_t
Playback seeking positions.
Definition: types.h:143
bool get_attachment(const char *attachment, std::vector< uint8_t > *data)
Get the attachment block from the recording.
Definition: playback.hpp:476
Structure containing the device configuration used to record.
Definition: types.h:168
const uint8_t * get_buffer() const noexcept
Get the data_block buffer.
Definition: playback.hpp:112
The result was successful.
Definition: k4atypes.h:219
Handle to a k4a recording opened for playback.
Definition: types.h:49
void set_color_conversion(k4a_image_format_t format)
Set the image format that color captures will be converted to.
Definition: playback.hpp:412
bool is_valid() const noexcept
Returns true if the k4a::playback is valid, false otherwise.
Definition: playback.hpp:177
bool is_valid() const noexcept
Returns true if the data_block is valid, false otherwise.
Definition: playback.hpp:74
The input buffer was too small.
Definition: k4atypes.h:235
size_t get_buffer_size() const noexcept
Get the size of the data_block buffer.
Definition: playback.hpp:103
bool get_previous_capture(capture *cap)
Get the previous capture in the recording.
Definition: playback.hpp:285
Wrapper for k4a_playback_t.
Definition: playback.hpp:128
Wrapper for k4a_calibration_t.
Definition: k4a.hpp:645
bool get_tag(const char *name, std::string *out) const
Reads the value of a tag from the recording Returns false if the tag does not exist.
Definition: playback.hpp:308
The end of the data stream was reached.
Definition: types.h:132
k4a_image_format_t
Image format type.
Definition: k4atypes.h:332