libcamera v0.0.0+3240-f2a18172-dirty (2022-05-13T20:32:10+00:00)
Supporting cameras in Linux since 2019
bayer_format.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
4 *
5 * bayer_format.h - Bayer Pixel Format
6 */
7#ifndef __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__
8#define __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__
9
10#include <stdint.h>
11#include <string>
12
14
16
17namespace libcamera {
18
19enum class Transform;
20
22{
23public:
24 enum Order : uint8_t {
25 BGGR = 0,
26 GBRG = 1,
27 GRBG = 2,
28 RGGB = 3,
29 MONO = 4
30 };
31
32 enum class Packing : uint16_t {
33 None = 0,
34 CSI2 = 1,
35 IPU3 = 2,
36 };
37
38 constexpr BayerFormat()
39 : order(Order::BGGR), bitDepth(0), packing(Packing::None)
40 {
41 }
42
43 constexpr BayerFormat(Order o, uint8_t b, Packing p)
44 : order(o), bitDepth(b), packing(p)
45 {
46 }
47
48 static const BayerFormat &fromMbusCode(unsigned int mbusCode);
49 bool isValid() const { return bitDepth != 0; }
50
51 std::string toString() const;
52
58
60 uint8_t bitDepth;
61
63};
64
65bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);
66static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)
67{
68 return !(lhs == rhs);
69}
70
71} /* namespace libcamera */
72
73#endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */
Class to represent a raw image Bayer format.
Definition: bayer_format.h:22
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)
Convert v4l2Format to the corresponding BayerFormat.
Definition: bayer_format.cpp:298
constexpr BayerFormat()
Construct an empty (and invalid) BayerFormat.
Definition: bayer_format.h:38
Packing
Different types of packing that can be applied to a BayerFormat.
Definition: bayer_format.h:32
uint8_t bitDepth
The bit depth of the samples in the Bayer pattern.
Definition: bayer_format.h:60
Order
The order of the colour channels in the Bayer pattern.
Definition: bayer_format.h:24
@ GBRG
G then B on the first row, R then G on the second row.
Definition: bayer_format.h:26
@ GRBG
G then R on the first row, B then G on the second row.
Definition: bayer_format.h:27
@ RGGB
R then G on the first row, G then B on the second row.
Definition: bayer_format.h:28
@ MONO
Monochrome image data, there is no colour filter array.
Definition: bayer_format.h:29
@ BGGR
B then G on the first row, G then R on the second row.
Definition: bayer_format.h:25
Packing packing
Any packing scheme applied to this BayerFormat.
Definition: bayer_format.h:62
V4L2PixelFormat toV4L2PixelFormat() const
Convert a BayerFormat into the corresponding V4L2PixelFormat.
Definition: bayer_format.cpp:284
static const BayerFormat & fromMbusCode(unsigned int mbusCode)
Retrieve the BayerFormat associated with a media bus code.
Definition: bayer_format.cpp:216
PixelFormat toPixelFormat() const
Convert a BayerFormat into the corresponding PixelFormat.
Definition: bayer_format.cpp:314
Order order
The order of the colour channels in the Bayer pattern.
Definition: bayer_format.h:59
std::string toString() const
Assemble and return a readable string representation of the BayerFormat.
Definition: bayer_format.cpp:237
BayerFormat transform(Transform t) const
Apply a transform to this BayerFormat.
Definition: bayer_format.cpp:353
static BayerFormat fromPixelFormat(PixelFormat format)
Convert a PixelFormat into the corresponding BayerFormat.
Definition: bayer_format.cpp:327
constexpr BayerFormat(Order o, uint8_t b, Packing p)
Construct a BayerFormat from explicit values.
Definition: bayer_format.h:43
bool isValid() const
Return whether a BayerFormat is valid.
Definition: bayer_format.h:49
libcamera image pixel format
Definition: pixel_format.h:17
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:21
Top-level libcamera namespace.
Definition: backtrace.h:17
Transform
Enum to represent a 2D plane transform.
Definition: transform.h:15
bool operator==(const Point &lhs, const Point &rhs)
Compare points for equality.
Definition: geometry.cpp:75
libcamera pixel format
V4L2 Pixel Format.