Update ArRecorder to append metadata and depth image to jpg
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "ArSession.hpp"
|
||||
#include "ArFrame.hpp"
|
||||
#include "IO/Archive/MultiPartArchiveWriter.hpp"
|
||||
#include "IO/Archive/ArchiveConfiguration.hpp"
|
||||
#include "IO/Files/Pfm.hpp"
|
||||
#include "IO/Files/Pnm.hpp"
|
||||
#include "IO/AppFolders.hpp"
|
||||
@@ -85,7 +86,7 @@ namespace OpenVulkano::AR
|
||||
else m_asyncProcessor.Close();
|
||||
}
|
||||
|
||||
void ArRecorder::WriteColorImage(ArFrame* arFrame, IArchiveWriter* colorWriter, const std::filesystem::path* path, bool highRes) const
|
||||
void ArRecorder::WriteColorImage(ArFrame* arFrame, IArchiveWriter* colorWriter, JpegWithTagsWriter* jpgWriter, bool highRes) const
|
||||
{
|
||||
//BlockProfiler profile("Save AR Frame - Image");
|
||||
std::string fileName = GetFileName(arFrame->GetFrameId(), "jpg");
|
||||
@@ -134,13 +135,9 @@ namespace OpenVulkano::AR
|
||||
{
|
||||
if (colorWriter) [[likely]]
|
||||
colorWriter->AddFile(fileName.c_str(), outBuffer, size);
|
||||
if (path) [[unlikely]]
|
||||
if (jpgWriter) [[unlikely]]
|
||||
{
|
||||
auto exif = MakeExifTag(arFrame);
|
||||
JpegWithTagsWriter writer(*path);
|
||||
writer.WriteExifTag(exif);
|
||||
writer.WriteXmpTag(MakeXmpTag(arFrame));
|
||||
writer.WriteImageData({ outBuffer, size });
|
||||
jpgWriter->WriteImageData({ outBuffer, size }, false); // Keep open, livetime is managed outside
|
||||
}
|
||||
}
|
||||
tjFree(outBuffer);
|
||||
@@ -302,14 +299,18 @@ namespace OpenVulkano::AR
|
||||
|
||||
void ArRecorder::WriteToFile(const std::shared_ptr<ArFrame>& frame, const std::filesystem::path& path, bool downsample, bool includeAux)
|
||||
{
|
||||
WriteColorImage(frame.get(), nullptr, &path, !downsample);
|
||||
JpegWithTagsWriter jpgWriter(path);
|
||||
jpgWriter.WriteExifTag(MakeExifTag(frame.get()));
|
||||
jpgWriter.WriteXmpTag(MakeXmpTag(frame.get()));
|
||||
WriteColorImage(frame.get(), nullptr, &jpgWriter, !downsample);
|
||||
if (includeAux)
|
||||
{
|
||||
auto fName = path.string();
|
||||
fName.replace(fName.size() - 3, 3, "aux");
|
||||
ArchiveWriter writer(fName);
|
||||
WriteMetadata(frame.get(), &writer);
|
||||
WriteDepthImage(frame.get(), &writer, &writer);
|
||||
FILE* file = jpgWriter.GetFilePtr();
|
||||
{
|
||||
ArchiveWriter writer(file, ArchiveConfiguration(ArchiveType::ZIP));
|
||||
WriteMetadata(frame.get(), &writer);
|
||||
WriteDepthImage(frame.get(), &writer, &writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace OpenVulkano
|
||||
class IEventHandler;
|
||||
class IArchiveWriter;
|
||||
class MultiPartArchiveWriter;
|
||||
class JpegWithTagsWriter;
|
||||
}
|
||||
|
||||
namespace OpenVulkano::AR
|
||||
@@ -100,7 +101,7 @@ namespace OpenVulkano::AR
|
||||
|
||||
void Write(ArFrame* frame, bool highRes = false);
|
||||
void WriteMetadata(ArFrame* frame, IArchiveWriter* metaWriter);
|
||||
void WriteColorImage(ArFrame* arFrame, IArchiveWriter* colorWriter, const std::filesystem::path* path, bool highRes) const;
|
||||
void WriteColorImage(ArFrame* arFrame, IArchiveWriter* colorWriter, JpegWithTagsWriter* jpgWriter, bool highRes) const;
|
||||
void WriteDepthImage(ArFrame *arFrame, IArchiveWriter* depthWriter, IArchiveWriter* confWriter);
|
||||
void WriteToFile(const std::shared_ptr<ArFrame>& frame, const std::filesystem::path& path, bool downsample, bool saveAux);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user