From 1ae02db91123776c3607e5c9b3c0cf67752292c3 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Fri, 6 Dec 2024 02:26:31 +0100 Subject: [PATCH] Include device and os version in ArSessionMetadata --- openVulkanoCpp/AR/ArSessionMetadata.cpp | 67 +++++++++++++++++-------- openVulkanoCpp/AR/ArSessionMetadata.hpp | 15 ++++-- 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/openVulkanoCpp/AR/ArSessionMetadata.cpp b/openVulkanoCpp/AR/ArSessionMetadata.cpp index 548de0a..2e60f43 100644 --- a/openVulkanoCpp/AR/ArSessionMetadata.cpp +++ b/openVulkanoCpp/AR/ArSessionMetadata.cpp @@ -5,13 +5,23 @@ */ #include "ArSessionMetadata.hpp" +#include "Extensions/YamlCppConverters.hpp" +#include "Host/SystemInfo.hpp" #include -#include -#include +#include #include namespace OpenVulkano::AR { + ArSessionMetadata::ArSessionMetadata() + : ArSessionMetadata(ArType::UNKNOWN, ArDepthFormat::UNAVAILABLE, {0,0}, { 1920, 1440 }, 60, + SystemInfo::GetDeviceModelName(), SystemInfo::GetOsNameHumanReadable()) + {} + + ArSessionMetadata::ArSessionMetadata(ArType type, ArDepthFormat format, Math::Range confRange, Math::Vector2ui resolution, float frameRate) + : ArSessionMetadata(type, format, confRange, resolution, frameRate, SystemInfo::GetDeviceModelName(), SystemInfo::GetOsNameHumanReadable()) + {} + ArSessionMetadata ArSessionMetadata::FromXML(const std::string& filePath) { pugi::xml_document doc; @@ -30,11 +40,13 @@ namespace OpenVulkano::AR resY = resNode.child("height").text().as_uint(); } float frameRate = metaNode.child("frameRate").text().as_float(60); + uint32_t version = metaNode.child("version").text().as_uint(1); + std::string device = metaNode.child("device").text().as_string("Unknown"); + std::string os = metaNode.child("os").text().as_string("iOS"); return { ArType::GetFromHumanReadableName(type), ArDepthFormat::GetFromAltName(depthType).value_or(ArDepthFormat::UNAVAILABLE), Math::Range(minRange, maxRange), - Math::Vector2ui(resX, resY), - frameRate + Math::Vector2ui(resX, resY), frameRate, device, os, version }; } @@ -46,8 +58,10 @@ namespace OpenVulkano::AR ArType::GetFromName(meta["Type"].Scalar()), ArDepthFormat::GetFromName(meta["DepthType"].Scalar()).value_or(ArDepthFormat::UNAVAILABLE), Math::Range(meta["MinConfidence"].as(), meta["MaxConfidence"].as()), - Math::Vector2ui(1), // TODO load - meta["FrameRate"].as(60) + meta["Resolution"].as(), + meta["FrameRate"].as(60), + meta["Device"].as("Unknown"), meta["OS"].as("Unknown"), + meta["Vesion"].as(2) }; } @@ -80,25 +94,34 @@ namespace OpenVulkano::AR std::string ArSessionMetadata::ToXML() const { - std::stringstream ss; - ss << "\n\t" << type.GetHumanReadableName() << "\n\t"; - ss << static_cast(confidenceRange.min) << "\n\t"; - ss << static_cast(confidenceRange.max) << "\n\t"; - ss << depthFormat.GetAltName() << ""; - ss << "\n\t" << imageResolution.x << "" << imageResolution.y << ""; - ss << "\n\t" << frameRate << ""; - ss << "\n"; - return ss.str(); + return fmt::format(R"( + {} + {} + {} + {} + {}{} + {} + {} + {} + {} +)", + type.GetHumanReadableName(), static_cast(confidenceRange.min), static_cast(confidenceRange.max), + depthFormat.GetAltName(), imageResolution.x, imageResolution.y, frameRate, device, os, version); } std::string ArSessionMetadata::ToYaml() const { - std::stringstream ss; - ss << "Type: " << type.GetName() << "\nDepthType: " << depthFormat.GetName(); - ss << "\nMinConfidence: " << static_cast(confidenceRange.min); - ss << "\nMaxConfidence: " << static_cast(confidenceRange.max); - ss << "\nResolution: \"(" << imageResolution.x << "," << imageResolution.y << ")\""; - ss << "\nFrameRate: " << frameRate; - return ss.str(); + return fmt::format(R"(Type: {} +DepthType: {} +MinConfidence: {} +MaxConfidence: {} +Resolution: ({},{}) +FrameRate: {} +Device: {} +OS: {} +Version: {} +)", + type.GetName(), depthFormat.GetName(), static_cast(confidenceRange.min), static_cast(confidenceRange.max), + imageResolution.x, imageResolution.y, frameRate, device, os, version); } } \ No newline at end of file diff --git a/openVulkanoCpp/AR/ArSessionMetadata.hpp b/openVulkanoCpp/AR/ArSessionMetadata.hpp index 9a28136..1332a71 100644 --- a/openVulkanoCpp/AR/ArSessionMetadata.hpp +++ b/openVulkanoCpp/AR/ArSessionMetadata.hpp @@ -20,14 +20,19 @@ namespace OpenVulkano::AR Math::Range confidenceRange; Math::Vector2ui imageResolution; float frameRate; + uint32_t version; + std::string device, os; + bool playback = false; - ArSessionMetadata() noexcept - : ArSessionMetadata(ArType::UNKNOWN, ArDepthFormat::UNAVAILABLE, {0,0}, { 1920, 1440 }, 60) - {} + ArSessionMetadata(); - ArSessionMetadata(ArType type, ArDepthFormat format, Math::Range confRange, Math::Vector2ui resolution, float frameRate) noexcept - : type(type), depthFormat(format), confidenceRange(confRange), imageResolution(resolution), frameRate(frameRate) + ArSessionMetadata(ArType type, ArDepthFormat format, Math::Range confRange, Math::Vector2ui resolution, float frameRate); + + ArSessionMetadata(ArType type, ArDepthFormat format, Math::Range confRange, Math::Vector2ui resolution, + float frameRate, const std::string& device, const std::string& os, uint32_t version = 2) + : type(type), depthFormat(format), confidenceRange(confRange), imageResolution(resolution) + , frameRate(frameRate), version(version), device(device), os(os) {} ArSessionMetadata(const std::string& dirPath);