Start design of AR abstraction layer

This commit is contained in:
2021-05-28 22:22:22 +02:00
parent cb9f33b6f0
commit d80249cd1c
14 changed files with 1013 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "ArSessionArCore.h"
namespace openVulkanoCpp::AR::ArCore
{
std::shared_ptr<ArSession> ArSessionArCore::Create(const ArSessionConfig& config)
{
return nullptr; // TODO
}
bool ArSessionArCore::IsAvailable()
{
return false;
}
const ArSessionCapabilities& ArSessionArCore::GetCapabilities()
{
static ArSessionCapabilities capabilities; // TODO setup
return capabilities;
}
}

View File

@@ -0,0 +1,32 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "AR/ArSession.h"
// Define the class of the native AR session to be used
#define NATIVE_AR_SESSION_CLASS ArCore::ArSessionArCore
namespace openVulkanoCpp::AR::ArCore
{
class ArSessionArCore : public ArSession
{
public:
[[nodiscard]] static std::shared_ptr<ArSession> Create(const ArSessionConfig& config);
[[nodiscard]] static bool IsAvailable();
[[nodiscard]] static const ArSessionCapabilities& GetCapabilities();
[[nodiscard]] ArSessionType GetSessionType() final { return ArSessionType::NATIVE; }
[[nodiscard]] ArType GetArType() final { return ArType::AR_CORE; }
protected:
~ArSessionArCore() override = default;
};
}

View File

@@ -0,0 +1,35 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "AR/ArSession.h"
// Define the class of the native AR session to be used
#define NATIVE_AR_SESSION_CLASS ArSessionNull
namespace openVulkanoCpp::AR
{
struct ArSessionNull final
{
inline static const ArSessionCapabilities AR_CAPS_UNAVAILABLE;
static std::shared_ptr<ArSession> Create(const ArSessionConfig& config)
{
return nullptr;
}
static bool IsAvailable()
{
return false;
}
static const ArSessionCapabilities& GetCapabilities()
{
return AR_CAPS_UNAVAILABLE;
}
};
}

View File

@@ -0,0 +1,40 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include "ArSessionStream.h"
namespace openVulkanoCpp::AR::Network
{
ArSessionStream::ArSessionStream(const std::string& serverAddress, std::optional<ArSessionConfig> requestConfig)
{
// TODO
}
void ArSessionStream::Start()
{
}
void ArSessionStream::Stop()
{
}
void ArSessionStream::Pause()
{
ArSession::Pause();
}
std::shared_ptr<ArFrame> ArSessionStream::GetFrame()
{
return nullptr;
}
ArType ArSessionStream::GetArType()
{
return GetCapabilities().GetArType();
}
}

View File

@@ -0,0 +1,35 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "AR/ArSession.h"
namespace openVulkanoCpp::AR::Network
{
class ArSessionStream final : public ArSession
{
public:
ArSessionStream(const std::string& serverAddress, std::optional<ArSessionConfig> requestConfig = std::nullopt);
~ArSessionStream() override = default;
void Start() override;
void Stop() override;
void Pause() override;
[[nodiscard]] std::shared_ptr<ArFrame> GetFrame() override;
[[nodiscard]] ArRecorder* GetRecorder() override { return nullptr; }
[[nodiscard]] ArSessionType GetSessionType() override { return ArSessionType::NETWORK_STREAM; }
[[nodiscard]] ArType GetArType() override;
};
}

View File

@@ -0,0 +1,52 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "AR/ArFrame.h"
#include "ArPlaybackReader.hpp"
#include "ArPlaybackData.hpp"
namespace openVulkanoCpp::AR::Playback
{
class ArSessionPlayback;
class ArFramePlayback final : public ArFrame
{
public:
ArFramePlayback(const std::shared_ptr<ArSessionPlayback>& session, ArPlaybackReader& frameReader);
ArTrackingState GetTrackingState() override;
Math::PoseF GetPose() override;
Math::Timestamp GetTimestamp() override;
ArImagePlanar GetCameraImage() override;
ArDepthImage GetDepthImage() override;
const Math::Matrix4f& GetCameraTransformation() override;
Math::Matrix4f GetCameraViewForCurrentDeviceOrientation() override;
Math::Matrix4f GetCameraProjection(Math::Vector2f viewportSize, float near, float far) override;
float GetConfidenceNormalisationFactor() override;
[[nodiscard]] float GetColorTemperature() const override;
private:
ArPlaybackFrameData frameData;
ArImagePlanar colorImage;
ArDepthImage depthImage;
std::unique_ptr<char[]> confImgData;
std::unique_ptr<float[]> depthImgData;
ColorImg colorImgData;
//cv::Mat colorImgData;
};
}