Include device and os version in ArSessionMetadata

This commit is contained in:
Georg Hagen
2024-12-06 02:26:31 +01:00
parent 4dbe81e206
commit 1ae02db911
2 changed files with 55 additions and 27 deletions

View File

@@ -5,13 +5,23 @@
*/
#include "ArSessionMetadata.hpp"
#include "Extensions/YamlCppConverters.hpp"
#include "Host/SystemInfo.hpp"
#include <pugixml.hpp>
#include <yaml-cpp/yaml.h>
#include <sstream>
#include <fmt/format.h>
#include <filesystem>
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<uint8_t> 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<uint8_t>(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<uint8_t>(meta["MinConfidence"].as<uint8_t>(), meta["MaxConfidence"].as<uint8_t>()),
Math::Vector2ui(1), // TODO load
meta["FrameRate"].as<float>(60)
meta["Resolution"].as<Math::Vector2ui>(),
meta["FrameRate"].as<float>(60),
meta["Device"].as<std::string>("Unknown"), meta["OS"].as<std::string>("Unknown"),
meta["Vesion"].as<uint32_t>(2)
};
}
@@ -80,25 +94,34 @@ namespace OpenVulkano::AR
std::string ArSessionMetadata::ToXML() const
{
std::stringstream ss;
ss << "<arPlatformInfo>\n\t<type>" << type.GetHumanReadableName() << "</type>\n\t<minConfidence>";
ss << static_cast<int>(confidenceRange.min) << "</minConfidence>\n\t<maxConfidence>";
ss << static_cast<int>(confidenceRange.max) << "</maxConfidence>\n\t<depthType>";
ss << depthFormat.GetAltName() << "</depthType>";
ss << "\n\t<imageResolution><width>" << imageResolution.x << "</width><height>" << imageResolution.y << "</height></imageResolution>";
ss << "\n\t<frameRate>" << frameRate << "</frameRate>";
ss << "\n</arPlatformInfo>";
return ss.str();
return fmt::format(R"(<arPlatformInfo>
<type>{}</type>
<minConfidence>{}</minConfidence>
<maxConfidence>{}</maxConfidence>
<depthType>{}</depthType>
<imageResolution><width>{}</width><height>{}</height></imageResolution>
<frameRate>{}</frameRate>
<device>{}</device>
<os>{}</os>
<version>{}</version>
</arPlatformInfo>)",
type.GetHumanReadableName(), static_cast<int>(confidenceRange.min), static_cast<int>(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<int>(confidenceRange.min);
ss << "\nMaxConfidence: " << static_cast<int>(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<int>(confidenceRange.min), static_cast<int>(confidenceRange.max),
imageResolution.x, imageResolution.y, frameRate, device, os, version);
}
}