Merge pull request 'AR enhancements' (#113) from wip into master
Reviewed-on: https://git.madvoxel.net/OpenVulkano/OpenVulkano/pulls/113
This commit is contained in:
@@ -182,6 +182,7 @@ namespace OpenVulkano::AR
|
||||
platformInfoStream.close();
|
||||
}
|
||||
m_recording = true;
|
||||
OnRecordingStateChanged(this, m_recording);
|
||||
}
|
||||
|
||||
void ArRecorder::Stop()
|
||||
@@ -192,6 +193,7 @@ namespace OpenVulkano::AR
|
||||
{
|
||||
writer->Split();
|
||||
}
|
||||
OnRecordingStateChanged(this, m_recording);
|
||||
}
|
||||
|
||||
void ArRecorder::SetRecordingPath(const std::filesystem::path& path)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Math/ByteSize.hpp"
|
||||
#include "Base/Event.hpp"
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <filesystem>
|
||||
@@ -190,5 +191,7 @@ namespace OpenVulkano::AR
|
||||
const RecordingSettings& GetRecordingSettings() const { return m_settings; }
|
||||
|
||||
void SetRecordHighResImages(bool recHighRes = true) { m_settings.saveHighResFrames = recHighRes; }
|
||||
|
||||
Event<ArRecorder*, bool> OnRecordingStateChanged;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,13 +32,15 @@ namespace OpenVulkano::AR::Playback
|
||||
static constexpr std::string_view TAR_EXTENSIONS_REGEX = R"(\.(tar(\.gz|\.bz2)?|tgz|tbz|tb2|tbz2))";
|
||||
|
||||
ArchiveReader m_archiveMetadata, m_archiveColor, m_archiveDepth, m_archiveConfidence;
|
||||
size_t m_depthTotalSize = 0, m_depthReadSize = 0;
|
||||
|
||||
public:
|
||||
ArPlaybackReader(const std::string& recDir)
|
||||
{
|
||||
std::string extensions = R"((_\d+|\.part\d+)?)" + std::string(TAR_EXTENSIONS_REGEX);
|
||||
m_archiveMetadata.Open(recDir, ".*meta(data)?" + extensions);
|
||||
m_archiveColor.Open(recDir, ".*(color|image)" + extensions);
|
||||
m_archiveDepth.Open(recDir, ".*depth" + extensions);
|
||||
m_archiveDepth.Open(recDir, ".*depth" + extensions, &m_depthTotalSize);
|
||||
m_archiveConfidence.Open(recDir, ".*conf(idence)?" + extensions);
|
||||
}
|
||||
|
||||
@@ -58,10 +60,17 @@ namespace OpenVulkano::AR::Playback
|
||||
DepthImage ReadDepthImage()
|
||||
{
|
||||
DepthImage img;
|
||||
m_archiveDepth.GetNextFileAsStream([&img](const FileDescription&, std::istream& stream) { img.depth.Read(stream); });
|
||||
size_t& depthRead = m_depthReadSize;
|
||||
m_archiveDepth.GetNextFileAsStream([&img, &depthRead](const FileDescription& desc, std::istream& stream) { img.depth.Read(stream); depthRead += desc.size + 1000; });
|
||||
m_archiveConfidence.GetNextFileAsStream([&img](const FileDescription&, std::istream& stream) { img.confidence.Read(stream); });
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
[[nodiscard]] double GetProgress() const
|
||||
{
|
||||
return static_cast<double>(m_depthReadSize) / static_cast<double>(m_depthTotalSize);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool HasNext() const
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace OpenVulkano::AR::Playback
|
||||
|
||||
void ArSessionPlayback::ReadWorker()
|
||||
{
|
||||
Utils::SetThreadName("AR_Playback");
|
||||
std::this_thread::sleep_for(128ms); // Delay startup of playback
|
||||
while (playbackReader.HasNext() && IsRunning())
|
||||
{
|
||||
@@ -88,6 +89,7 @@ namespace OpenVulkano::AR::Playback
|
||||
auto view = frame->GetCameraViewForCurrentDeviceOrientation();
|
||||
OnNewCameraViewMatrix(view);
|
||||
}
|
||||
OnPlaybackProgress(playbackReader.GetProgress());
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,11 @@ class ArSessionPlayback final : public ArSession, public std::enable_shared_from
|
||||
|
||||
[[nodiscard]] ArType GetArType() override;
|
||||
|
||||
[[nodiscard]] const std::string& GetPlaybackPath() const { return recordingPath; }
|
||||
|
||||
void SetRenderer(IRenderer* renderer) override;
|
||||
|
||||
Event<double> OnPlaybackProgress;
|
||||
|
||||
protected:
|
||||
Scene::Texture * MakeTexture(OpenVulkano::AR::ArFrame *frame) override;
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
bool ArchiveReader::Open(const std::filesystem::path& dir, const std::string& fileNamePattern)
|
||||
bool ArchiveReader::Open(const std::filesystem::path& dir, const std::string& fileNamePattern, size_t* outSize)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
|
||||
@@ -109,9 +109,13 @@ namespace OpenVulkano
|
||||
for(const std::filesystem::directory_entry& dirEntry : std::filesystem::directory_iterator(dir))
|
||||
{
|
||||
std::string entryPath = dirEntry.path().string();
|
||||
if (std::regex_match(entryPath, fileRegex))
|
||||
if (!dirEntry.is_directory() && std::regex_match(entryPath, fileRegex))
|
||||
{
|
||||
files.push_back(std::move(entryPath));
|
||||
if (outSize)
|
||||
{
|
||||
*outSize += dirEntry.file_size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenVulkano
|
||||
|
||||
bool Open(const std::vector<std::string>& archiveFiles);
|
||||
|
||||
bool Open(const std::filesystem::path& dir, const std::string& fileNamePattern);
|
||||
bool Open(const std::filesystem::path& dir, const std::string& fileNamePattern, size_t* outSize = nullptr);
|
||||
|
||||
[[nodiscard]] bool IsOpen() const { return m_open; }
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenVulkano
|
||||
ArchiveWriter::~ArchiveWriter()
|
||||
{
|
||||
if (m_asBuffer) { m_asBuffer->Close(); m_asBuffer = nullptr; }
|
||||
archive_write_close(m_archive);
|
||||
ChkErr(archive_write_close(m_archive));
|
||||
archive_entry_free(m_archiveEntry);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user