Fix playback reader progress being wrong

This commit is contained in:
Georg Hagen
2024-12-02 16:38:18 +01:00
parent 536805e629
commit 8671bf3887
2 changed files with 8 additions and 6 deletions

View File

@@ -35,6 +35,8 @@ namespace OpenVulkano::AR::Playback
//YuvUtils::NV12FromChromaPlanes(buff, img.data + (img.cols * img.rows), img.cols * img.rows / 4);
m_imgReadSize += 1000 + file.value().first.size;
return img;
}
}
@@ -53,6 +55,7 @@ namespace OpenVulkano::AR::Playback
stbi_load_from_memory(reinterpret_cast<stbi_uc*>(file->second.Data()), file->second.Size(), &img.cols, &img.rows, &img.channels, 3),
&stbi_image_free);
img.data = img.dataPtr.get();
m_imgReadSize += 1000 + file.value().first.size;
return img;
}
}

View File

@@ -32,15 +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;
size_t m_imgTotalSize = 0, m_imgReadSize = 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_depthTotalSize);
m_archiveColor.Open(recDir, ".*(color|image)" + extensions, &m_imgTotalSize);
m_archiveDepth.Open(recDir, ".*depth" + extensions);
m_archiveConfidence.Open(recDir, ".*conf(idence)?" + extensions);
}
@@ -60,8 +60,7 @@ namespace OpenVulkano::AR::Playback
DepthImage ReadDepthImage()
{
DepthImage img;
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_archiveDepth.GetNextFileAsStream([&img](const FileDescription& desc, std::istream& stream) { img.depth.Read(stream); });
m_archiveConfidence.GetNextFileAsStream([&img](const FileDescription&, std::istream& stream) { img.confidence.Read(stream); });
return img;
@@ -69,7 +68,7 @@ namespace OpenVulkano::AR::Playback
[[nodiscard]] double GetProgress() const
{
return static_cast<double>(m_depthReadSize) / static_cast<double>(m_depthTotalSize);
return static_cast<double>(m_imgReadSize) / static_cast<double>(m_imgTotalSize);
}
[[nodiscard]] bool HasNext() const