Add option to run ar playback without loading images
This commit is contained in:
@@ -57,11 +57,11 @@ namespace OpenVulkano::AR
|
||||
return { nullptr, ArCreateResult::FAILED_UNKNOWN, "Unknown exception while initializing AR system." };
|
||||
}
|
||||
|
||||
ArCreateResult ArSession::CreatePlayback(const std::string& recordingPath, bool autoAdvance)
|
||||
ArCreateResult ArSession::CreatePlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth)
|
||||
{
|
||||
try
|
||||
{
|
||||
const auto session = std::make_shared<Playback::ArSessionPlayback>(recordingPath, autoAdvance);
|
||||
const auto session = std::make_shared<Playback::ArSessionPlayback>(recordingPath, autoAdvance, loadImages, loadDepth);
|
||||
sessions.push_back(session);
|
||||
return { session, ArCreateResult::SUCCESS, "" };
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace OpenVulkano::AR
|
||||
* @param autoAdvance If set to true the playback will advance based on the stored timestamps. If set to false it will only advance if a new frame is requested.
|
||||
* @return ArCreateResult about the status of the AR session creation. The session pointer will always be nullptr unless the status is SUCCESS.
|
||||
*/
|
||||
[[nodiscard]] static ArCreateResult CreatePlayback(const std::string& recordingPath, bool autoAdvance = true);
|
||||
[[nodiscard]] static ArCreateResult CreatePlayback(const std::string& recordingPath, bool autoAdvance = true, bool loadImages = true, bool loadDepth = true);
|
||||
|
||||
/**
|
||||
* Creates a network streamed AR session. nullptr if failed to create session for given address. This will block till the connection with the remote host has been established.
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace OpenVulkano::AR::Playback
|
||||
//BlockProfiler profile("Read_AR_Frame");
|
||||
const auto data = frameReader.ReadMetadata();
|
||||
frameMetadata = ArFrameMetadata::FromXML(data.Data(), data.Size());
|
||||
colorImgData = frameReader.ReadColorImage();
|
||||
if (session->GetCapabilities().IsDepthSupported())
|
||||
{
|
||||
auto depth = frameReader.ReadDepthImage();
|
||||
confImgData = std::move(depth.confidence.image);
|
||||
depthImgData = std::move(depth.depth.image);
|
||||
@@ -26,11 +27,15 @@ namespace OpenVulkano::AR::Playback
|
||||
depthImage.depth.resolution = {depth.depth.header.width, depth.depth.header.height};
|
||||
depthImage.confidence.data = confImgData.get();
|
||||
depthImage.depth.resolution = {depth.confidence.header.width, depth.confidence.header.height};
|
||||
|
||||
}
|
||||
if (session->IsLoadColorEnabled())
|
||||
{
|
||||
colorImgData = frameReader.ReadColorImage();
|
||||
colorImage.intrinsic = frameMetadata.intrinsic.GetForResolution({colorImgData.cols, colorImgData.rows});
|
||||
colorImage.format = ArImagePlanar::Format::RGB;
|
||||
colorImage.luminescenceOrColor = {colorImgData.data, {colorImgData.cols, colorImgData.rows}};
|
||||
colorImage.luminescenceOrColor.numChannels = colorImgData.channels;
|
||||
}
|
||||
SetSaved();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,11 @@ using namespace std::chrono_literals;
|
||||
|
||||
namespace OpenVulkano::AR::Playback
|
||||
{
|
||||
ArSessionPlayback::ArSessionPlayback(const std::string& recordingPath, bool autoAdvance)
|
||||
: ArSession(ArSessionMetadata(recordingPath)), recordingPath(recordingPath), autoAdvance(autoAdvance), playbackReader(recordingPath)
|
||||
ArSessionPlayback::ArSessionPlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth)
|
||||
: ArSession(ArSessionMetadata(recordingPath)), recordingPath(recordingPath), autoAdvance(autoAdvance)
|
||||
, loadImages(loadImages), loadDepth(loadDepth), playbackReader(recordingPath)
|
||||
{
|
||||
capabilities = ArSessionCapabilities(metadata.type, ArSessionType::PLAYBACK, false, metadata.depthFormat != ArDepthFormat::UNAVAILABLE, false, false, false);
|
||||
capabilities = ArSessionCapabilities(metadata.type, ArSessionType::PLAYBACK, false, metadata.depthFormat != ArDepthFormat::UNAVAILABLE && loadDepth, false, false, false);
|
||||
constants = { Math::Matrix4f(1), metadata.confidenceRange };
|
||||
|
||||
m_playbackReaderThread = std::thread([this](){ReadWorker();});
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace OpenVulkano::AR::Playback
|
||||
class ArSessionPlayback final : public ArSession, public std::enable_shared_from_this<ArSessionPlayback>
|
||||
{
|
||||
public:
|
||||
ArSessionPlayback(const std::string& recordingPath, bool autoAdvance);
|
||||
ArSessionPlayback(const std::string& recordingPath, bool autoAdvance, bool loadImages, bool loadDepth);
|
||||
|
||||
~ArSessionPlayback() override;
|
||||
|
||||
@@ -33,6 +33,9 @@ class ArSessionPlayback final : public ArSession, public std::enable_shared_from
|
||||
|
||||
[[nodiscard]] const std::string& GetPlaybackPath() const { return recordingPath; }
|
||||
|
||||
[[nodiscard]] bool IsLoadColorEnabled() const { return loadImages; }
|
||||
[[nodiscard]] bool IsLoadDepthEnabled() const { return loadDepth; }
|
||||
|
||||
void SetRenderer(IRenderer* renderer) override;
|
||||
|
||||
Event<double> OnPlaybackProgress;
|
||||
@@ -48,7 +51,7 @@ class ArSessionPlayback final : public ArSession, public std::enable_shared_from
|
||||
|
||||
Math::Timestamp lastTimestamp;
|
||||
const std::string recordingPath;
|
||||
const bool autoAdvance;
|
||||
const bool autoAdvance, loadImages, loadDepth;
|
||||
ArPlaybackReader playbackReader;
|
||||
ArTrackingState m_lastTrackingState = ArTrackingState::UNKNOWN;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user