Add exif and xmp to full resolution images saved to disk
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
#include "Base/BlockProfiler.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include "Image/YuvUtils.hpp"
|
||||
#include "Image/ExifBuilder.hpp"
|
||||
#include "Image/XmpBuilder.hpp"
|
||||
#include "Image/JpegWithTagsWriter.hpp"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#if __has_include("turbojpeg.h")
|
||||
@@ -25,10 +28,10 @@ namespace OpenVulkano::AR
|
||||
{
|
||||
namespace
|
||||
{
|
||||
constexpr int JPEG_QUALITY_DS = 85;
|
||||
constexpr int JPEG_QUALITY_DS = 90;
|
||||
constexpr int JPEG_QUALITY_FS = 100;
|
||||
|
||||
std::filesystem::path GeneratePath(const std::filesystem::path& baseDir, std::string_view name)
|
||||
std::filesystem::path GeneratePath(const std::filesystem::path& baseDir, const std::string_view name)
|
||||
{
|
||||
std::stringstream ss;
|
||||
auto t = std::time(nullptr);
|
||||
@@ -108,9 +111,29 @@ namespace OpenVulkano::AR
|
||||
colorWriter->AddFile(fileName.c_str(), outBuffer, size);
|
||||
if (path) [[unlikely]]
|
||||
{
|
||||
std::ofstream outFile(*path, std::ios::binary);
|
||||
/*std::ofstream outFile(*path, std::ios::binary);
|
||||
outFile.write(reinterpret_cast<const char*>(outBuffer), size);
|
||||
outFile.close();
|
||||
outFile.close();*/
|
||||
Image::ExifBuilder exifBuilder;
|
||||
exifBuilder.model = arFrame->GetLensModel();
|
||||
exifBuilder.exposureTime = Image::RationalValue(1, 1.0f / arFrame->GetExposureTime());
|
||||
exifBuilder.SetOrientation(atan2f(arFrame->GetCameraTransformation()[0][1], arFrame->GetCameraTransformation()[1][1]));
|
||||
exifBuilder.dateTaken = exifBuilder.GetCurrentTimestamp();
|
||||
exifBuilder.make = arFrame->GetArSession()->GetArType().GetVendorName();
|
||||
exifBuilder.SetResolution();
|
||||
exifBuilder.fNumber = arFrame->GetFNumber();
|
||||
exifBuilder.focalLength = arFrame->GetFocalLength();
|
||||
auto exif = exifBuilder.Build();
|
||||
Image::XmpBuilder xmpBuilder;
|
||||
xmpBuilder.SetPose(arFrame->GetPose());
|
||||
xmpBuilder.SetCreateDate(exifBuilder.dateTaken); //TODO
|
||||
xmpBuilder.SetExposureTime(arFrame->GetExposureTime());
|
||||
xmpBuilder.SetFocalLength(arFrame->GetFocalLength());
|
||||
xmpBuilder.SetCameraIntrinsic(arFrame->GetCameraIntrinsic());
|
||||
JpegWithTagsWriter writer(*path);
|
||||
writer.WriteExifTag(exif);
|
||||
writer.WriteXmpTag(xmpBuilder.Finalize());
|
||||
writer.WriteImageData({ outBuffer, size });
|
||||
}
|
||||
}
|
||||
tjFree(outBuffer);
|
||||
|
||||
Reference in New Issue
Block a user