Merge branch 'master' into features/string-wrapper
This commit is contained in:
@@ -26,6 +26,7 @@ namespace OpenVulkano::AR
|
||||
namespace
|
||||
{
|
||||
constexpr std::string_view RECORDING_METADATA_FILENAME = "ArRecording.xml";
|
||||
constexpr int JPEG_QUALITY = 85;
|
||||
|
||||
std::filesystem::path GeneratePath(const std::filesystem::path& baseDir, std::string_view name)
|
||||
{
|
||||
@@ -56,7 +57,7 @@ namespace OpenVulkano::AR
|
||||
|
||||
void ArRecorder::WriteColorImage(ArFrame* arFrame, MultiPartArchiveWriter* colorWriter, const std::filesystem::path* path, bool highRes) const
|
||||
{
|
||||
BlockProfiler profile("Save AR Frame - Image");
|
||||
//BlockProfiler profile("Save AR Frame - Image");
|
||||
std::string fileName = GetFileName(arFrame->GetFrameId(), "jpg");
|
||||
#ifndef TURBO_JPEG
|
||||
if (arFrame->GetCameraImageAsJpeg([&fileName, this](const char* data, size_t len){ m_colorWriter->AddFile(fileName.c_str(), data, len); }))
|
||||
@@ -95,7 +96,7 @@ namespace OpenVulkano::AR
|
||||
|
||||
uint8_t* outBuffer = nullptr;
|
||||
unsigned long size = 0;
|
||||
if (tjCompressFromYUVPlanes(handle, buffers, resX, nullptr, resY, TJSAMP_420, &outBuffer, &size, 95, TJFLAG_FASTDCT)) [[unlikely]]
|
||||
if (tjCompressFromYUVPlanes(handle, buffers, resX, nullptr, resY, TJSAMP_420, &outBuffer, &size, JPEG_QUALITY, TJFLAG_FASTDCT)) [[unlikely]]
|
||||
Logger::AR->error("Failed to create JPEG! {}", tjGetErrorStr());
|
||||
else [[likely]]
|
||||
{
|
||||
@@ -120,7 +121,7 @@ namespace OpenVulkano::AR
|
||||
auto depthImg = arFrame->GetDepthImage();
|
||||
std::vector<std::pair<const void*, size_t>> buffers(2);
|
||||
{ // TODO handle alternative depth formats!!!!
|
||||
BlockProfiler profile("Save AR Frame - Depth");
|
||||
//BlockProfiler profile("Save AR Frame - Depth");
|
||||
PfmHeader depthHeader(static_cast<uint32_t>(depthImg.depth.resolution.x), static_cast<uint32_t>(depthImg.depth.resolution.y), 5.0f, false);
|
||||
std::string header = depthHeader.ToString();
|
||||
buffers[0].first = header.c_str();
|
||||
@@ -133,7 +134,7 @@ namespace OpenVulkano::AR
|
||||
}
|
||||
|
||||
{
|
||||
BlockProfiler profile("Save AR Frame - Confi");
|
||||
//BlockProfiler profile("Save AR Frame - Confi");
|
||||
PnmHeader confidenceHeader(static_cast<uint32_t>(depthImg.confidence.resolution.x), static_cast<uint32_t>(depthImg.confidence.resolution.y), false, 2);
|
||||
std::string header = confidenceHeader.ToString();
|
||||
buffers[0].first = header.c_str();
|
||||
@@ -148,7 +149,7 @@ namespace OpenVulkano::AR
|
||||
|
||||
void ArRecorder::WriteMetadata(ArFrame* frame, MultiPartArchiveWriter* metaWriter)
|
||||
{
|
||||
BlockProfiler profileMeta("Save AR Frame - Meta");
|
||||
//BlockProfiler profileMeta("Save AR Frame - Meta");
|
||||
std::string metaContent = frame->GetFrameMetadata().ToXML();
|
||||
std::string fileName = GetFileName(frame->GetFrameId(), "meta");
|
||||
metaWriter->AddFile(fileName.c_str(), metaContent.c_str(), metaContent.size());
|
||||
@@ -159,7 +160,7 @@ namespace OpenVulkano::AR
|
||||
if (frame->IsSaved()) return;
|
||||
frame->SetSaved();
|
||||
bool useHighResWriter = highRes && m_settings.highResFramesInSeparateArchive;
|
||||
BlockProfiler profile("Save AR Frame");
|
||||
//BlockProfiler profile("Save AR Frame");
|
||||
WriteMetadata(frame, useHighResWriter ? m_highResWriter.get() : m_metadataWriter.get());
|
||||
WriteColorImage(frame, useHighResWriter ? m_highResWriter.get() : m_colorWriter.get(), nullptr, highRes);
|
||||
WriteDepthImage(frame,
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace OpenVulkano::AR::Playback
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
Logger::AR->error("Failed to read AR frame: {}", e.what());
|
||||
break;
|
||||
}
|
||||
}
|
||||
Stop();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Math/Math.hpp"
|
||||
#include "Math/AABB.hpp"
|
||||
#include <ryml.hpp>
|
||||
#include <ryml_std.hpp>
|
||||
#include <c4/format.hpp>
|
||||
@@ -49,6 +50,10 @@ namespace c4
|
||||
m[1][3], m[2][3], m[3][3]);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
size_t to_chars(ryml::substr buf, const OpenVulkano::Math::AABB& bbox)
|
||||
{ return ryml::format(buf, "({},{},{}),({},{},{})", bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z); }
|
||||
|
||||
template<class T>
|
||||
bool from_chars(ryml::csubstr buf, OpenVulkano::Math::Vector2<T>* v)
|
||||
{
|
||||
@@ -108,4 +113,11 @@ namespace c4
|
||||
m[1][3], m[2][3], m[3][3]);
|
||||
return ret != ryml::yml::npos;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool from_chars(ryml::csubstr buf, OpenVulkano::Math::AABB* bbox)
|
||||
{
|
||||
size_t ret = ryml::unformat(buf, "({},{},{}),({},{},{})", bbox->min.x, bbox->min.y, bbox->min.z, bbox->max.x, bbox->max.y, bbox->max.z);
|
||||
return ret != ryml::yml::npos;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Base/UUID.hpp"
|
||||
#include "Math/AABB.hpp"
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include <fmt/format.h>
|
||||
#include <c4/format.hpp>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
@@ -29,4 +32,23 @@ namespace YAML
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template<>
|
||||
struct convert<OpenVulkano::Math::AABB>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::AABB& bbox)
|
||||
{
|
||||
return Node(fmt::format("({},{},{}),({},{},{})", bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::AABB& bbox)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{}),({},{},{})", bbox.min.x, bbox.min.y, bbox.min.z, bbox.max.x, bbox.max.y, bbox.max.z);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
#ifdef HAS_CURL
|
||||
namespace
|
||||
{
|
||||
size_t CurlDownloader(void* contents, size_t size, size_t memBlockCount, void* userData)
|
||||
@@ -31,10 +32,11 @@ namespace OpenVulkano
|
||||
return totalSize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool WebResourceLoader::IsUrl(const std::string& str)
|
||||
{
|
||||
return str.find("http://") == 0 || str.find("https://") == 0 || str.find("ftp://") == 0;
|
||||
return Utils::StartsWith(str, "http://") || Utils::StartsWith(str, "https://") || Utils::StartsWith(str, "ftp://");
|
||||
}
|
||||
|
||||
WebResourceLoader::WebResourceLoader()
|
||||
|
||||
@@ -57,6 +57,14 @@ namespace OpenVulkano
|
||||
|
||||
bool ArchiveReader::Open(const char* archiveFile)
|
||||
{
|
||||
if (archiveFile[0] == '\0')
|
||||
{
|
||||
if (m_logger)
|
||||
{
|
||||
m_logger->error("Unable to open archive file with an empty name!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
PrepOpen();
|
||||
ChkErr(archive_read_open_filename(m_archive, archiveFile, BUFFER_SIZE));
|
||||
ReadNextHeader();
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenVulkano
|
||||
else if (archiveResult <= ARCHIVE_FAILED) lvl = spdlog::level::level_enum::err;
|
||||
const char* errorString = archive_error_string(arch);
|
||||
if (logger) logger->log(lvl, errorString ? errorString : "Unknown error while handling archive");
|
||||
if (archiveResult == ARCHIVE_FAILED) throw std::runtime_error(errorString);
|
||||
if (archiveResult == ARCHIVE_FAILED || archiveResult == ARCHIVE_FATAL) throw std::runtime_error(errorString);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenVulkano
|
||||
std::string path;
|
||||
size_t size;
|
||||
std::filesystem::perms permissions;
|
||||
time_t createTime, modTime;
|
||||
time_t createTime = {}, modTime = {};
|
||||
|
||||
static FileDescription MakeDescriptionForFile(const char* path, size_t size)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace OpenVulkano
|
||||
READ_WRITE
|
||||
};
|
||||
|
||||
MemMappedFile() : m_data(nullptr), m_size(0) {}
|
||||
|
||||
MemMappedFile(const std::filesystem::path& path, FileMode fileMode = READ_ONLY);
|
||||
|
||||
[[nodiscard]] bool IsOpen() const { return m_data; }
|
||||
|
||||
Reference in New Issue
Block a user