System designExplainer

Record color video when your camera outputs Bayer images

Why a Bayer pixel format makes recordings black-and-white images, the bandwidth math behind RGB8, and two ways to record color: on the camera or on the host.

LumaSpec Vision10 min read Share on LinkedIn

On this page 9 sections
  1. 01Why a Bayer stream has no color yet
  2. 02What the recording tool does with mosaic frames
  3. 03Fix 1: switch the camera to RGB8
  4. 04The arithmetic that decides it
  5. 05Worked example: 12 MP USB3 camera at 30 fps
  6. 06Fix 2: record Bayer and debayer on the host
  7. 07Which fix fits your case
  8. 08Checks before you hit record
  9. 09Questions

You press record, the clip comes out gray, and the live view may even show color or a faint maze pattern. In nearly every case the cause is the pixel format: the camera is streaming a Bayer format such as BayerRG8 — raw mosaic data with no color decoded yet — and the recorder saved the frames without a debayering step. This page explains what a Bayer stream is, why recording tools trip on it, and the two reliable fixes: switch the camera to RGB8, or record Bayer and convert on the host. Anyone recording from GigE or USB3 machine-vision cameras in an SDK viewer or in their own code can apply both fixes today; the bandwidth arithmetic tells you which one your interface survives, and all you need is your camera's resolution, frame rate and pixel-format list.

Why a Bayer stream has no color yet

A color sensor places a microscopic filter over each pixel in a fixed 2 x 2 pattern — one red, one blue, two green sites (Bayer filter). Each pixel therefore measures a single color component; the two missing components are estimated afterwards by a demosaicing step. Someone must run that step, in the camera or in software. Until it runs, the frame is a gray-looking mosaic that encodes color by pixel position.

Pixel formats name this state directly. BayerRG8 means an 8-bit Bayer mosaic in RGGB order, one byte per pixel. RGB8 means three 8-bit channels per pixel — debayered color. If the camera's PixelFormat feature reads BayerRG8 (or BayerGR8, BayerGB8, BayerBG8, and their 10- and 12-bit variants) while you record, the recorder receives mosaic data, not color frames. Why a 10-bit sensor can still ship 8-bit images is its own topic in ADC bit depth versus pixel format.

What the recording tool does with mosaic frames

Live view and recording are separate paths. Many viewers debayer automatically for display; the record path often writes exactly what the SDK hands it. A Bayer frame pushed into an encoder that expects RGB or YUV produces one of three outcomes: a monochrome-looking file, a rejected format, or a playable clip full of maze texture.

Grab one frame and look at it before changing anything:

Fix 1: switch the camera to RGB8

Every GigE Vision and USB3 Vision camera exposes the GenICam PixelFormat feature in its feature browser. Setting it to RGB8 moves the debayering into the camera; the recorder receives true color frames and nothing in your recording workflow changes.

The cost is bandwidth: RGB8 triples the bytes per frame, and frame rate follows the link, as the BGR vs Bayer on GigE frame-rate drop case shows. The next section puts numbers on exactly how much you lose.

The arithmetic that decides it

Stream bandwidth is pixels per frame, times bytes per pixel, times frames per second:

stream [MB/s] = width x height x bytes per pixel x fps / 1,000,000

Bytes per pixel by format: Mono8 and BayerRG8 are 1, YUV422Packed is 2, RGB8 is 3. The link sets one ceiling and the sensor sets the other; the lower wins. Practical link ceilings: GigE is 1 Gbit/s = 125 MB/s theoretical, about 110 MB/s after protocol overhead; USB 3.0 is 5 Gbit/s = 625 MB/s theoretical, about 400 MB/s in practice. Dividing the link rate by MB per frame gives the fps ceiling:

Resolution BayerRG8 MB/frame RGB8 MB/frame RGB8 fps ceiling on GigE RGB8 fps ceiling on USB 3.0
2 MP 2 6 about 18 about 67
5 MP 5 15 about 7 about 27
12 MP 12 36 about 3 about 11
20 MP 20 60 about 2 about 7

If the ceiling is still above what you need, RGB8 is the easy answer. A middle ground helps when it exists: YUV422Packed costs a third less than RGB8 and trades some chroma resolution for it; availability varies per camera, and the YUV 4:4:4 packed greyed-out explainer covers the case where your camera does not list it.

Worked example: 12 MP USB3 camera at 30 fps

Inputs, each with its source:

  • Resolution and frame rate: 4000 x 3000 px and 30 fps, from the camera data sheet. The LS-CMR-0166 is a concrete example of the class: 12 MP on a 1/1.7-inch sensor, USB3.
  • Bytes per pixel: 1 for BayerRG8, 3 for RGB8, from the GenICam format definitions.
  • Link budget: about 400 MB/s practical on USB 3.0, from the 5 Gbit/s = 625 MB/s theoretical rate minus protocol overhead.

The rule in words: stream bandwidth equals pixels per frame, times bytes per pixel, times frames per second.

The arithmetic:

  • BayerRG8: 4000 x 3000 = 12,000,000 pixels = 12 MB per frame. 12 MB x 30 fps = 360 MB/s.
  • RGB8: 12,000,000 x 3 bytes = 36 MB per frame. 36 MB x 30 fps = 1080 MB/s.
  • Compare: 1080 MB/s exceeds even the 625 MB/s theoretical USB 3.0 ceiling, so 30 fps in RGB8 cannot fit. The practical ceiling is 400 / 36, about 11 fps; with zero overhead the link would still cap at 625 / 36, about 17 fps.

Result and decision: at this resolution, RGB8 caps the recording near 11 fps — a 63% cut against the sensor's 30 fps. Above roughly 400 MB/s of RGB8 demand, a USB 3.0 link cannot carry full-rate color, so record BayerRG8 at 360 MB/s and debayer on the host, or move the camera to 10GigE, whose practical rate of about 1.1 GB/s carries 1080 MB/s with thin margin. The 360 MB/s raw stream also needs storage that sustains it; the practicalities are in streaming camera images to disk at high frame rate.

Area scan cameras12 MP USB3 area scan camera, IMX226, 1/1.7" rolling shutter, 30 fps, 4000 × 3000 resolution (LS-CMR-0166)LS-CMR-0166
Sensor format
1/1.7"
Interface
USB3
Resolution
12 MP
Shutter
Rolling
$560.00View partBuild a system with it

Fix 2: record Bayer and debayer on the host

Keep PixelFormat on BayerRG8 and let the sensor run at full speed. Capture each mosaic frame, run it through the SDK's pixel-format conversion to RGB8, and hand the converted frame to the encoder. The recorder sees color; the sensor never slows down.

The conversion is one call in mainstream machine-vision SDKs: an image processor takes the captured Bayer frame plus the target format, RGB8, and returns the debayered image — the save-to-video examples that ship with SDKs show the pattern. Budget CPU for it, because the conversion triples the data rate through memory: give the stream its own core and measure per-frame latency before promising a write rate. A Python walk-through of capture plus encoding is in recording video from a machine vision camera in Python.

Recording raw also buys quality control: you choose the demosaicing algorithm — bilinear for speed, edge-aware for detail — and can re-process archived footage without re-shooting, at a third of the disk use of RGB8. If your camera runs 12-bit packed formats, packed Bayer 12-bit conversion to a 16-bit image covers decoding before display, and the sensor side of color is in the color filter array explainer.

Which fix fits your case

  • 2-5 MP camera on USB 3.0, target rates in the tens of fps: set RGB8 and record; the ceilings (about 67 fps at 2 MP, 27 fps at 5 MP) sit above most sensors' own limits, so nothing else changes.
  • 2-5 MP camera on GigE: RGB8 works up to the ceiling (about 18 fps at 2 MP, 7 fps at 5 MP); beyond that, record Bayer and convert on the host.
  • 12 MP and up on USB 3.0: record BayerRG8 and debayer on the host unless your rates sit at or below about 11 fps.
  • High resolution on GigE: the interface is the bottleneck for both formats at full rate, so plan for 10GigE or CoaXPress if you need color video at speed, or accept the reduced rates.

If the camera itself is still an open choice, the split shows up directly in current hardware. The MV-CU020-90GC is a 2.5 MP color GigE camera with a global shutter, at the easy end of the table. The MV-CS200-10GC is a 20 MP color GigE camera on a 1-inch sensor. At that resolution RGB8 is 60 MB per frame, about 2 fps on the link, so record Bayer and convert on the host, or move to a faster interface.

Area scan camerasHikrobot MV-CU020-90GC 2.5 MP Area Scan Camera, GigE, GMAX4002, ColorMV-CU020-90GC
Sensor format
1/1.7"
Lens mount
C-mount
$309.00View part
Area scan camerasHikrobot MV-CS200-10GC 20 MP Area Scan Camera, GigE, IMX183, Color, BasicMV-CS200-10GC
Sensor format
1"
Lens mount
C-mount
$739.00View part

Checks before you hit record

  1. Read the PixelFormat feature from the camera itself, not from the software's assumption: any BayerRG8, GR8, GB8 or BG8 value means raw mosaic is arriving.
  2. Grab one frame and view it at 1:1: smooth gray means mono output, maze texture means undecoded Bayer, true color means RGB or YUV is flowing.
  3. Compute the stream with the formula above and compare it with the practical ceiling for your interface.
  4. After any pixel-format change, re-read frame rate and exposure from the camera; if saved stills look brighter than the clip afterward, the exposure path differs, as video exposure and frame rate explains.
  5. Check the storage side against the rate you computed: a raw stream of that size wants an NVMe drive or a compressed encoder.
  6. Run a 10-second test recording and step through individual frames before the real take.

If you are choosing hardware for the recording task rather than fixing an existing one, the area scan cameras category and the camera finder filter by interface, resolution and shutter, and the camera configurator walks the whole chain from sensor to cable. More acquisition and streaming guides sit on the systems topic page, and contact us when a specific rig needs a second opinion.

Questions

Is recording Bayer better for image quality than RGB8?

Often yes. In-camera conversion locks in one demosaicing algorithm; a raw Bayer recording keeps the untouched mosaic, so you can pick the interpolation afterwards — bilinear for speed, edge-aware for detail — and re-process the same footage without re-shooting. On textured scenes the difference is small; near fine repeating patterns such as grids and fences a crude algorithm can smear color edges. If you archive at all, archive the Bayer frames.

Why does RGB8 drop the frame rate more than the data sheet suggests?

Frame-rate specs are quoted in the camera's native format, usually BayerRG8 or Mono8, not RGB8. RGB8 triples the bytes per frame, so the interface becomes the limit before the sensor does: a 5 MP RGB8 frame is 15 MB, and a GigE link's roughly 110 MB/s ceiling allows about 7 fps even when the sensor can do 50. Some cameras list YUV422Packed, at 2 bytes per pixel, as a middle ground costing a third less than RGB8.

Can I get color out of a monochrome camera by debayering?

No. Demosaicing only works when a Bayer color filter array sits on the sensor. A monochrome camera has no filter array: every pixel measures one gray value at full resolution, and there is no color to interpolate. Smooth black-and-white output from a mono camera is correct behavior, not a setting problem — for color video you need the color variant of the sensor. The exception is the maze-pattern gray of an undecoded Bayer stream, which does hide recoverable color.

How much disk space does raw Bayer recording use?

Multiply width x height x bytes per pixel x frame rate and divide by a million for MB/s. At 4000 x 3000 and 30 fps, BayerRG8 needs 360 MB/s — about 21.6 GB per minute — and RGB8 needs 1080 MB/s, about 64.8 GB per minute, before compression. If your recording tool offers MJPEG or H.264 encoding after the conversion, sizes drop to a fraction of those figures at some quality cost; raw recording buys full control and re-processing.

How do I tell undecoded Bayer from a true monochrome recording?

A raw Bayer frame displayed as grayscale shows a faint checkerboard or maze texture, because neighboring pixels carry different color filters. If your black-and-white video shows that pattern on uniform surfaces, the file holds undecoded Bayer data and the color is recoverable. Genuine monochrome footage is smoothly gray with no texture. Bright, even light on a plain target makes the pattern easiest to spot; view at 1:1 pixels, since scaling can hide it.