libcamera: libcamera::BayerFormat Class Reference

libcamera v0.0.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
libcamera::BayerFormat Class Reference

Class to represent a raw image Bayer format. More...

## Public Types
enum | Order : uint8_t { BGGR = 0 , GBRG = 1 , GRBG = 2 , RGGB = 3 , MONO = 4 }
| The order of the colour channels in the Bayer pattern. More...
enum class | Packing : uint16_t { None = 0 , CSI2 = 1 , IPU3 = 2 }
| Different types of packing that can be applied to a BayerFormat. More...

## Public Member Functions
constexpr | BayerFormat ()
| Construct an empty (and invalid) BayerFormat.
constexpr | BayerFormat (Order o, uint8_t b, Packing p)
| Construct a BayerFormat from explicit values. More...
bool | isValid () const
| Return whether a BayerFormat is valid.
std::string | toString () const
| Assemble and return a readable string representation of the BayerFormat. More...
V4L2PixelFormat | toV4L2PixelFormat () const
| Convert a BayerFormat into the corresponding V4L2PixelFormat. More...
PixelFormat | toPixelFormat () const
| Convert a BayerFormat into the corresponding PixelFormat. More...
BayerFormat | transform (Transform t) const
| Apply a transform to this BayerFormat. More...

## Static Public Member Functions
static const BayerFormat & | fromMbusCode (unsigned int mbusCode)
| Retrieve the BayerFormat associated with a media bus code. More...
static BayerFormat | fromV4L2PixelFormat (V4L2PixelFormat v4l2Format)
| Convert v4l2Format to the corresponding BayerFormat. More...
static BayerFormat | fromPixelFormat (PixelFormat format)
| Convert a PixelFormat into the corresponding BayerFormat. More...

## Public Attributes
Order | order
| The order of the colour channels in the Bayer pattern.
uint8_t | bitDepth
| The bit depth of the samples in the Bayer pattern.
Packing | packing
| Any packing scheme applied to this BayerFormat.

## Detailed Description

Class to represent a raw image Bayer format.

This class encodes the different Bayer formats in such a way that they can be easily manipulated. For example, the bit depth or Bayer order can be easily altered - the Bayer order can even be "transformed" in the same manner as happens in many sensors when their horizontal or vertical "flip" controls are set.

## Member Enumeration Documentation

## ◆ Order

enum libcamera::BayerFormat::Order : uint8_t

The order of the colour channels in the Bayer pattern.

Enumerator
BGGR | B then G on the first row, G then R on the second row.
GBRG | G then B on the first row, R then G on the second row.
GRBG | G then R on the first row, B then G on the second row.
RGGB | R then G on the first row, G then B on the second row.
MONO | Monochrome image data, there is no colour filter array.

## ◆ Packing

enum class libcamera::BayerFormat::Packing : uint16_t
| strong

Different types of packing that can be applied to a BayerFormat.

Enumerator
None | No packing.
CSI2 | Format uses MIPI CSI-2 style packing.
IPU3 | Format uses IPU3 style packing.

## Constructor & Destructor Documentation

## ◆ BayerFormat()

libcamera::BayerFormat::BayerFormat | ( | Order | o,
|  | uint8_t | b,
|  | Packing | p
| ) |  |
| inlineconstexpr

Construct a BayerFormat from explicit values.

Parameters

  [in] | o | The order of the Bayer pattern
  [in] | b | The bit depth of the Bayer samples
  [in] | p | The type of packing applied to the pixel values

## Member Function Documentation

## ◆ fromMbusCode()

const BayerFormat & libcamera::BayerFormat::fromMbusCode | ( | unsigned int | mbusCode | ) |
| static

Retrieve the BayerFormat associated with a media bus code.

Parameters

  [in] | mbusCode | The media bus code to convert into a BayerFormat

The media bus code numeric identifiers are defined by the V4L2 specification.

## ◆ fromPixelFormat()

BayerFormat libcamera::BayerFormat::fromPixelFormat | ( | PixelFormat | format | ) |
| static

Convert a PixelFormat into the corresponding BayerFormat.

Returns
  The BayerFormat corresponding to this PixelFormat

## ◆ fromV4L2PixelFormat()

BayerFormat libcamera::BayerFormat::fromV4L2PixelFormat | ( | V4L2PixelFormat | v4l2Format | ) |
| static

Convert v4l2Format to the corresponding BayerFormat.

Parameters

  [in] | v4l2Format | The raw format to convert into a BayerFormat

Returns
  The BayerFormat corresponding to v4l2Format

## ◆ toPixelFormat()

PixelFormat libcamera::BayerFormat::toPixelFormat | ( |  | ) | const

Convert a BayerFormat into the corresponding PixelFormat.

Returns
  The PixelFormat corresponding to this BayerFormat

## ◆ toString()

std::string libcamera::BayerFormat::toString | ( |  | ) | const

Assemble and return a readable string representation of the BayerFormat.

Returns
  A string describing the BayerFormat

## ◆ toV4L2PixelFormat()

V4L2PixelFormat libcamera::BayerFormat::toV4L2PixelFormat | ( |  | ) | const

Convert a BayerFormat into the corresponding V4L2PixelFormat.

Returns
  The V4L2PixelFormat corresponding to this BayerFormat

## ◆ transform()

BayerFormat libcamera::BayerFormat::transform | ( | Transform | t | ) | const

Apply a transform to this BayerFormat.

Parameters

  [in] | t | The transform to apply

Appplying a transform to an image stored in a Bayer format affects the Bayer order. For example, performing a horizontal flip on the Bayer pattern RGGB causes the RG rows of pixels to become GR, and the GB rows to become BG. The transformed image would have a GRBG order. The bit depth and modifiers are not affected.

Horizontal and vertical flips are applied before transpose.

Returns
  The transformed Bayer format

The documentation for this class was generated from the following files:

- include/libcamera/internal/bayer_format.h
- src/libcamera/bayer_format.cpp