[libcamera-devel] [SimpleCam PATCH 2/2] simple-cam: processRequest: Report Request metadata

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Feb 16 13:35:44 CET 2022


The completed Request can contain extra data associated with the
completed capture to report IPA state or properties of the capture to
the application.

Process and report any metadata that is associated with the request
when it completes, to demonstrate the extra metadata available to be
processed.

Now that there is substantially more information than one line per
completed request, start each completed Request with a blank line to
separate from previous completions and report the state of the Request
itself with its .toString() helper.

Suggested-by: Nejc Galof <galof.nejc at gmail.com>
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 simple-cam.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/simple-cam.cpp b/simple-cam.cpp
index e282463c3976..4de1b7de9ced 100644
--- a/simple-cam.cpp
+++ b/simple-cam.cpp
@@ -46,6 +46,29 @@ static void requestComplete(Request *request)
 
 static void processRequest(Request *request)
 {
+	std::cout << std::endl
+		  << "Request completed: " << request->toString() << std::endl;
+
+	/*
+	 * When a request has completed, it is populated with a metadata control
+	 * list that allows an application to determine various properties of
+	 * the completed request. This can include the timestamp of the Sensor
+	 * capture, or its gain and exposure values, or properties from the IPA
+	 * such as the state of the 3A algorithms.
+	 *
+	 * ControlValue types have a toString, so to examine each request, print
+	 * all the metadata for inspection. A custom application can parse each
+	 * of these items and process them according to its needs.
+	 */
+	const ControlList &requestMetadata = request->metadata();
+	for (const auto &ctrl : requestMetadata) {
+		const ControlId *id = controls::controls.at(ctrl.first);
+		const ControlValue &value = ctrl.second;
+
+		std::cout << "\t" << id->name() << " = " << value.toString()
+			  << std::endl;
+	}
+
 	/*
 	 * Each buffer has its own FrameMetadata to describe its state, or the
 	 * usage of each buffer. While in our simple capture we only provide one
-- 
2.32.0



More information about the libcamera-devel mailing list