Documentation: guides: pipeline-handler: Simplify format collection
I believe a simple range based for loop is easier to understand here than `std::transform()`. Furthermore, using a for loop enables the easy filtering of invalid pixel formats. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
f83bab529c
commit
b03992e66f
1 changed files with 7 additions and 11 deletions
|
@ -827,9 +827,7 @@ To generate a ``StreamConfiguration``, you need a list of pixel formats and
|
||||||
frame sizes which are supported as outputs of the stream. You can fetch a map of
|
frame sizes which are supported as outputs of the stream. You can fetch a map of
|
||||||
the ``V4LPixelFormat`` and ``SizeRange`` supported by the underlying output
|
the ``V4LPixelFormat`` and ``SizeRange`` supported by the underlying output
|
||||||
device, but the pipeline handler needs to convert this to a
|
device, but the pipeline handler needs to convert this to a
|
||||||
``libcamera::PixelFormat`` type to pass to applications. We do this here using
|
``libcamera::PixelFormat`` type to pass to applications.
|
||||||
``std::transform`` to convert the formats and populate a new ``PixelFormat`` map
|
|
||||||
as shown below.
|
|
||||||
|
|
||||||
Continue adding the following code example to our ``generateConfiguration``
|
Continue adding the following code example to our ``generateConfiguration``
|
||||||
implementation.
|
implementation.
|
||||||
|
@ -839,14 +837,12 @@ implementation.
|
||||||
std::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats =
|
std::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats =
|
||||||
data->video_->formats();
|
data->video_->formats();
|
||||||
std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;
|
std::map<PixelFormat, std::vector<SizeRange>> deviceFormats;
|
||||||
std::transform(v4l2Formats.begin(), v4l2Formats.end(),
|
|
||||||
std::inserter(deviceFormats, deviceFormats.begin()),
|
for (auto &[v4l2PixelFormat, sizes] : v4l2Formats) {
|
||||||
[&](const decltype(v4l2Formats)::value_type &format) {
|
PixelFormat pixelFormat = v4l2PixelFormat.toPixelFormat();
|
||||||
return decltype(deviceFormats)::value_type{
|
if (pixelFormat.isValid())
|
||||||
format.first.toPixelFormat(),
|
deviceFormats.try_emplace(pixelFormat, std::move(sizes));
|
||||||
format.second
|
}
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
The `StreamFormats`_ class holds information about the pixel formats and frame
|
The `StreamFormats`_ class holds information about the pixel formats and frame
|
||||||
sizes that a stream can support. The class groups size information by the pixel
|
sizes that a stream can support. The class groups size information by the pixel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue