libcamera v0.4.0
Supporting cameras in Linux since 2019
 
Loading...
Searching...
No Matches
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 Ltd
4 *
5 * Bayer Pixel Format
6 */
7
8#pragma once
9
10#include <ostream>
11#include <stdint.h>
12#include <string>
13
15
17
18namespace libcamera {
19
20enum class Transform;
21
23{
24public:
25 enum Order : uint8_t {
26 BGGR = 0,
27 GBRG = 1,
28 GRBG = 2,
29 RGGB = 3,
30 MONO = 4
31 };
32
33 enum class Packing : uint16_t {
34 None = 0,
35 CSI2 = 1,
36 IPU3 = 2,
37 PISP1 = 3,
38 PISP2 = 4,
39 };
40
41 constexpr BayerFormat()
43 {
44 }
45
46 constexpr BayerFormat(Order o, uint8_t b, Packing p)
47 : order(o), bitDepth(b), packing(p)
48 {
49 }
50
51 static const BayerFormat &fromMbusCode(unsigned int mbusCode);
52 bool isValid() const { return bitDepth != 0; }
53
54 std::string toString() const;
55
61
63 uint8_t bitDepth;
64
66};
67
68bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);
69static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)
70{
71 return !(lhs == rhs);
72}
73
74std::ostream &operator<<(std::ostream &out, const BayerFormat &f);
75
76} /* namespace libcamera */
Class to represent a raw image Bayer format.
Definition bayer_format.h:23
static BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)
Convert v4l2Format to the corresponding BayerFormat.
Definition bayer_format.cpp:359
Packing
Different types of packing that can be applied to a BayerFormat.
Definition bayer_format.h:33
@ PISP1
Format uses PISP mode 1 compression.
Definition bayer_format.h:37
@ PISP2
Format uses PISP mode 2 compression.
Definition bayer_format.h:38
@ CSI2
Format uses MIPI CSI-2 style packing.
Definition bayer_format.h:35
@ None
No packing.
Definition bayer_format.h:34
@ IPU3
Format uses IPU3 style packing.
Definition bayer_format.h:36
uint8_t bitDepth
The bit depth of the samples in the Bayer pattern.
Definition bayer_format.h:63
Packing packing
Any packing scheme applied to this BayerFormat.
Definition bayer_format.h:65
Order order
The order of the colour channels in the Bayer pattern.
Definition bayer_format.h:62
bool isValid() const
Return whether a BayerFormat is valid.
Definition bayer_format.h:52
Order
The order of the colour channels in the Bayer pattern.
Definition bayer_format.h:25
@ BGGR
B then G on the first row, G then R 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:28
@ GBRG
G then B on the first row, R 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:29
@ MONO
Monochrome image data, there is no colour filter array.
Definition bayer_format.h:30
V4L2PixelFormat toV4L2PixelFormat() const
Convert a BayerFormat into the corresponding V4L2PixelFormat.
Definition bayer_format.cpp:345
static const BayerFormat & fromMbusCode(unsigned int mbusCode)
Retrieve the BayerFormat associated with a media bus code.
Definition bayer_format.cpp:259
PixelFormat toPixelFormat() const
Convert a BayerFormat into the corresponding PixelFormat.
Definition bayer_format.cpp:375
constexpr BayerFormat(Order o, uint8_t b, Packing p)
Construct a BayerFormat from explicit values.
Definition bayer_format.h:46
std::string toString() const
Assemble and return a readable string representation of the BayerFormat.
Definition bayer_format.cpp:280
BayerFormat transform(Transform t) const
Apply a transform to this BayerFormat.
Definition bayer_format.cpp:417
static BayerFormat fromPixelFormat(PixelFormat format)
Convert a PixelFormat into the corresponding BayerFormat.
Definition bayer_format.cpp:388
constexpr BayerFormat()
Construct an empty (and invalid) BayerFormat.
Definition bayer_format.h:41
libcamera image pixel format
Definition pixel_format.h:17
V4L2 pixel format FourCC wrapper.
Definition v4l2_pixelformat.h:24
Top-level libcamera namespace.
Definition backtrace.h:17
Transform
Enum to represent a 2D plane transform.
Definition transform.h:14
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition geometry.cpp:91
libcamera pixel format
V4L2 Pixel Format.