Expand ArFrame API with additional getters

This commit is contained in:
Georg Hagen
2024-07-29 14:57:23 +02:00
parent be47451ad2
commit 631d108be4
2 changed files with 22 additions and 2 deletions

View File

@@ -7,6 +7,8 @@
#include "ArFrame.hpp"
#include "ArSession.hpp"
#include "ArRecorder.hpp"
#include <iostream>
#include <fstream>
namespace OpenVulkano::AR
{
@@ -26,6 +28,11 @@ namespace OpenVulkano::AR
void ArFrame::SaveToFile(const std::filesystem::path& path, bool downsample)
{
m_session->GetRecorder().SaveToFile(shared_from_this(), path, downsample);
std::string metaContent = GetFrameMetadata().ToXML();
std::string metaPath = path.string() + std::string(".meta");
std::ofstream file (metaPath, std::ios::out);
file << metaContent;
file.close();
}
const Scene::Texture* ArFrame::GetImageTexture()

View File

@@ -122,7 +122,20 @@ namespace OpenVulkano::AR
[[nodiscard]] ArTrackingState GetTrackingState() const { return frameMetadata.trackingState; };
[[nodiscard]] virtual Math::PoseF GetPose() const { return Math::PoseF(); }; //TODO
[[nodiscard]] virtual Math::PoseF GetPose() const { return Math::PoseF(frameMetadata.transformation); };
[[nodiscard]] virtual Math::Vector3f GetEulerAngle() const {
return {
asin(-frameMetadata.transformation[2][1]),
atan2(frameMetadata.transformation[2][0], frameMetadata.transformation[2][2]),
atan2(frameMetadata.transformation[0][1], frameMetadata.transformation[1][1])
};
}
[[nodiscard]] virtual const Math::Vector3f_SIMD& GetPosition() const
{
return reinterpret_cast<const Math::Vector3f_SIMD&>(frameMetadata.transformation[3]);
}
[[nodiscard]] Math::Timestamp GetTimestamp() const { return frameMetadata.timestamp; };