Improve error handling for ar playbacks
This commit is contained in:
@@ -83,8 +83,8 @@ namespace OpenVulkano::AR::Playback
|
||||
DepthImage ReadDepthImage()
|
||||
{
|
||||
DepthImage img;
|
||||
m_archiveDepth.GetNextFileAsStream([&img](const FileDescription& desc, std::istream& stream) { img.depth.Read(stream); });
|
||||
if (!m_archiveConfidence.GetNextFileAsStream([&img](const FileDescription&, std::istream& stream) { img.confidence.Read(stream); }))
|
||||
m_archiveDepth.GetNextFileAsStream([&img](const FileDescription& desc, std::istream& stream) { img.depth.TryRead(stream); });
|
||||
if (!m_archiveConfidence.GetNextFileAsStream([&img](const FileDescription&, std::istream& stream) { img.confidence.TryRead(stream); }))
|
||||
{ // No confidence image available
|
||||
img.confidence.header.width = img.confidence.header.height = 1;
|
||||
img.confidence.image = std::make_unique<char[]>(m_imgTotalSize);
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
|
||||
#include "../../../../cmake-build/release/_deps/ryml-src/ext/c4core/src/c4/format.hpp"
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
//TODO handle comments
|
||||
@@ -119,7 +121,17 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
operator bool() const { return image; }
|
||||
void TryRead(std::istream& inStream)
|
||||
{
|
||||
try { Read(inStream); }
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
header.height = header.width = 0;
|
||||
image = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
operator bool() const { return static_cast<bool>(image); }
|
||||
|
||||
static PfmImage ReadImage(std::istream& inStream)
|
||||
{
|
||||
@@ -131,15 +143,7 @@ namespace OpenVulkano
|
||||
static PfmImage TryReadImage(std::istream& inStream)
|
||||
{
|
||||
PfmImage image;
|
||||
try
|
||||
{
|
||||
image.Read(inStream);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
image.header.height = image.header.width = 0;
|
||||
image.image = nullptr;
|
||||
}
|
||||
image.TryRead(inStream);
|
||||
return image;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -151,7 +151,17 @@ namespace OpenVulkano
|
||||
inStream.read(image.get(), size);
|
||||
}
|
||||
|
||||
operator bool() const { return image; }
|
||||
void TryRead(std::istream& inStream)
|
||||
{
|
||||
try { Read(inStream); }
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
header.height = header.width = 0;
|
||||
image = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
operator bool() const { return static_cast<bool>(image); }
|
||||
|
||||
static PnmImage ReadImage(std::istream& inStream)
|
||||
{
|
||||
@@ -163,15 +173,7 @@ namespace OpenVulkano
|
||||
static PfmImage TryReadImage(std::istream& inStream)
|
||||
{
|
||||
PfmImage image;
|
||||
try
|
||||
{
|
||||
image.Read(inStream);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
image.header.height = image.header.width = 0;
|
||||
image.image = nullptr;
|
||||
}
|
||||
image.TryRead(inStream);
|
||||
return image;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user