-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Description
rpicam-jpeg --metadata option does not create metadata file
Problem
rpicam-jpeg --metadata is documented but does not work. The option is parsed but no metadata file is created.
Reproduce
rpicam-jpeg -o test.jpg \
--metadata test_metadata.json \
--metadata-format json \
-t 2000 \
--qt-previewResult: Image created, metadata file NOT created.
rpicam-still with same parameters works correctly.
Root Cause
save_metadata() function is never called in apps/rpicam_jpeg.cpp.
Fix
--- a/apps/rpicam_jpeg.cpp
+++ b/apps/rpicam_jpeg.cpp
@@ -8,6 +8,8 @@
#include "core/rpicam_app.hpp"
#include "core/still_options.hpp"
+#include "output/output.hpp"
+
#include "image/image.hpp"
using namespace std::placeholders;
@@ -29,6 +31,22 @@ public:
}
};
+static void save_metadata(StillOptions const *options, libcamera::ControlList &metadata)
+{
+ std::streambuf *buf = std::cout.rdbuf();
+ std::ofstream of;
+ const std::string &filename = options->Get().metadata;
+
+ if (filename.compare("-"))
+ {
+ of.open(filename, std::ios::out);
+ buf = of.rdbuf();
+ }
+
+ write_metadata(buf, options->Get().metadata_format, metadata, true);
+}
+
// The main even loop for the application.
static void event_loop(RPiCamJpegApp &app)
@@ -84,6 +102,8 @@ static void event_loop(RPiCamJpegApp &app)
BufferReadSync r(&app, payload->buffers[stream]);
const std::vector<libcamera::Span<uint8_t>> mem = r.Get();
jpeg_save(mem, info, payload->metadata, options->Get().output, app.CameraModel(), options);
+ if (!options->Get().metadata.empty())
+ save_metadata(options, payload->metadata);
return;
}
}Test Results
Tested with JSON, TXT, and stdout formats - all working correctly.
Metadata
Metadata
Assignees
Labels
No labels