From 29a5fd9ed70c57b4f0d321f9737170dc71bd544a Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 17 Jun 2024 13:36:04 +0200 Subject: [PATCH] Allow filesystem path directly in ar recorder --- openVulkanoCpp/AR/ArRecorder.cpp | 9 ++++----- openVulkanoCpp/AR/ArRecorder.hpp | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/openVulkanoCpp/AR/ArRecorder.cpp b/openVulkanoCpp/AR/ArRecorder.cpp index a3064a0..c5a1ebe 100644 --- a/openVulkanoCpp/AR/ArRecorder.cpp +++ b/openVulkanoCpp/AR/ArRecorder.cpp @@ -26,7 +26,7 @@ namespace OpenVulkano::AR namespace { constexpr std::string_view RECORDING_METADATA_FILENAME = "ArRecording.xml"; - + std::filesystem::path GeneratePath(const std::filesystem::path& baseDir, std::string_view name) { std::stringstream ss; @@ -185,18 +185,17 @@ namespace OpenVulkano::AR } } - void ArRecorder::SetRecordingPath(const std::string& path) + void ArRecorder::SetRecordingPath(const std::filesystem::path& path) { if (!m_session) return; if (!m_colorWriter) { - std::filesystem::path p(path); for (MultiPartArchiveWriter* writer: { m_colorWriter.get(), m_depthWriter.get(), m_confidenceWriter.get(), m_metadataWriter.get(), m_highResWriter.get() }) { - if (writer) writer->Move(p); + if (writer) writer->Move(path); } if (std::filesystem::exists(m_settings.path / RECORDING_METADATA_FILENAME)) - std::filesystem::rename(m_settings.path / RECORDING_METADATA_FILENAME, p / RECORDING_METADATA_FILENAME); + std::filesystem::rename(m_settings.path / RECORDING_METADATA_FILENAME, path / RECORDING_METADATA_FILENAME); } m_persistent = true; diff --git a/openVulkanoCpp/AR/ArRecorder.hpp b/openVulkanoCpp/AR/ArRecorder.hpp index 68bd15b..1033ddb 100644 --- a/openVulkanoCpp/AR/ArRecorder.hpp +++ b/openVulkanoCpp/AR/ArRecorder.hpp @@ -109,7 +109,19 @@ namespace OpenVulkano::AR * If path is changed after starting the recording, the already running recording will be moved to the new path. * @param path The path to be used to store the recording */ - void SetRecordingPath(const std::string& path); + void SetRecordingPath(const std::string& path) + { + std::filesystem::path p(path); + SetRecordingPath(p); + } + + /** + * Sets the directory into which the AR recording should be stored. + * The path needs to be set to make the recording persistent. + * If path is changed after starting the recording, the already running recording will be moved to the new path. + * @param path The path to be used to store the recording + */ + void SetRecordingPath(const std::filesystem::path& path); /** * Gets the current recording path @@ -145,11 +157,11 @@ namespace OpenVulkano::AR /** * If enabled color images will be reduced to 1/4 of the original resolution (both axes will have half the resolution). * This option can be used to reduce the used storage space and storage bandwidth during recording. - * - * @param downsample true = downsample images; false = no downsampling + * + * @param downsample true = downsample images; false = no downsampling */ void SetDownsampleColorImages(bool downsample = true) { m_settings.downsampleColor = downsample; } - + /** * Checks if color image downsampling is enabled. * @return true = downsample images; false = no downsampling @@ -161,7 +173,7 @@ namespace OpenVulkano::AR * @param separateArchive true = using the separate archive file; false = using the normal archive files */ void SetHighResFramesInSeparateArchive(bool separateArchive = true) { m_settings.highResFramesInSeparateArchive = separateArchive; } - + /** * Checks if a separate archive is used for the high res frames. * @return true = using the separate archive file; false = using the normal archive files