libcamera: Add support for monochrome sensors

This commit adds support for monochrome (greyscale) raw sensors. These
are sensors that have no colour filter array, so all pixels are the
same and there are no distinct colour channels.

These sensors still require many of an ISP's processing stages, such
as denoise, tone mapping, but not those that involve colours (such as
demosaic, or colour matrices).

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
David Plowman 2021-06-28 13:23:22 +01:00 committed by Laurent Pinchart
parent 8738d539f4
commit bdf04cca08
4 changed files with 21 additions and 3 deletions

View file

@ -23,7 +23,8 @@ public:
BGGR = 0, BGGR = 0,
GBRG = 1, GBRG = 1,
GRBG = 2, GRBG = 2,
RGGB = 3 RGGB = 3,
MONO = 4
}; };
enum Packing : uint16_t { enum Packing : uint16_t {

View file

@ -45,6 +45,8 @@ namespace libcamera {
* \brief G then R on the first row, B then G on the second row. * \brief G then R on the first row, B then G on the second row.
* \var BayerFormat::RGGB * \var BayerFormat::RGGB
* \brief R then G on the first row, G then B on the second row. * \brief R then G on the first row, G then B on the second row.
* \var BayerFormat::MONO
* \brief Monochrome image data, there is no colour filter array.
*/ */
/** /**
@ -111,6 +113,8 @@ const std::map<BayerFormat, V4L2PixelFormat, BayerFormatComparator> bayerToV4l2{
{ { BayerFormat::GBRG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) }, { { BayerFormat::GBRG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },
{ { BayerFormat::GRBG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) }, { { BayerFormat::GRBG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },
{ { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) }, { { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },
{ { BayerFormat::MONO, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) },
{ { BayerFormat::MONO, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) },
}; };
const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{ const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
@ -146,6 +150,8 @@ const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{
{ MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::None } }, { MEDIA_BUS_FMT_SGBRG16_1X16, { BayerFormat::GBRG, 16, BayerFormat::None } },
{ MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::None } }, { MEDIA_BUS_FMT_SGRBG16_1X16, { BayerFormat::GRBG, 16, BayerFormat::None } },
{ MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::None } }, { MEDIA_BUS_FMT_SRGGB16_1X16, { BayerFormat::RGGB, 16, BayerFormat::None } },
{ MEDIA_BUS_FMT_Y8_1X8, { BayerFormat::MONO, 8, BayerFormat::None } },
{ MEDIA_BUS_FMT_Y10_1X10, { BayerFormat::MONO, 10, BayerFormat::None } },
}; };
} /* namespace */ } /* namespace */
@ -198,9 +204,10 @@ std::string BayerFormat::toString() const
"BGGR", "BGGR",
"GBRG", "GBRG",
"GRBG", "GRBG",
"RGGB" "RGGB",
"MONO"
}; };
if (isValid() && order <= RGGB) if (isValid() && order <= MONO)
result = orderStrings[order]; result = orderStrings[order];
else else
return "INVALID"; return "INVALID";
@ -280,6 +287,9 @@ BayerFormat BayerFormat::transform(Transform t) const
{ {
BayerFormat result = *this; BayerFormat result = *this;
if (order == MONO)
return result;
/* /*
* Observe that flipping bit 0 of the Order enum performs a horizontal * Observe that flipping bit 0 of the Order enum performs a horizontal
* mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly, * mirror on the Bayer pattern (e.g. RGGB goes to GRBG). Similarly,

View file

@ -428,6 +428,9 @@ int CameraSensor::initProperties()
case BayerFormat::RGGB: case BayerFormat::RGGB:
cfa = properties::draft::RGGB; cfa = properties::draft::RGGB;
break; break;
case BayerFormat::MONO:
cfa = properties::draft::MONO;
break;
} }
properties_.set(properties::draft::ColorFilterArrangement, cfa); properties_.set(properties::draft::ColorFilterArrangement, cfa);

View file

@ -706,5 +706,9 @@ controls:
description: | description: |
Sensor is not Bayer; output has 3 16-bit values for each pixel, Sensor is not Bayer; output has 3 16-bit values for each pixel,
instead of just 1 16-bit value per pixel. instead of just 1 16-bit value per pixel.
- name: MONO
value: 5
description: |
Sensor is not Bayer; output consists of a single colour channel.
... ...