libcamera  v0.2.0+110-fb74bb7d
Supporting cameras in Linux since 2019
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  Packing : uint16_t { None = 0, CSI2 = 1, IPU3 = 2 }
 Different types of packing that can be applied to a BayerFormat.
 

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 BayerFormatfromMbusCode (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

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.

Constructor & Destructor Documentation

◆ BayerFormat()

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

Construct a BayerFormat from explicit values.

Parameters
[in]oThe order of the Bayer pattern
[in]bThe bit depth of the Bayer samples
[in]pThe 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]mbusCodeThe 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]v4l2FormatThe 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]tThe transform to apply

Applying 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. Performing a vertical flip on the Bayer pattern RGGB causes the GB rows to come before the RG ones and the transformed image would have GBRG order. Applying both vertical and horizontal flips on the Bayer patter RGGB results in transformed images with BGGR 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: