Skip to content

Colorspace Manipulation for VideoCapture Gears

Colorspace

Source ColorSpace manipulation

All VidGear's Videocapture Gears (namely CamGear, ScreenGear, VideoGear) and some Streaming Gears (namely WebGear, WebGear_RTC) and Network Gears (Client's end) - provides exclusive internal support for Source Color Space manipulation.

There are two ways to alter source colorspace:

Using colorspace parameter

Primarily, the safest way is by colorspace (string) parameter of the respective VideoCapture API, that can be used to easily alter the colorspace of the input source, during initialization. But on the downside, colorspace parameter value CANNOT be changed/altered at runtime.

All possible values for this parameter are discussed below ➶

Using color_space global variable

Alternatively, a more direct approach is by using color_space (integer) global variable the respective VideoCapture API, can be used for directly changing the source colorspace at runtime. It can be used in conjunction with colorspace parameter easily.

 

Supported Colorspace Conversions

Any conversion from default Source colorspace (i.e. BGR in case of OpenCV), to any other colorspace and vice-versa (use None to revert), is supported.

Important Information

  • Using color_space global variable is NOT Supported in VideoGear API, calling it will result in AttribueError.

  • Any incorrect or None-type value, will immediately revert the colorspace to default (i.e. BGR).

  • Using color_space global variable with Threaded Queue Mode may have minor lag, User discretion is advised.

Tip

It is advised to enable logging(logging = True) on the first run for easily identifying any runtime errors.

 

Supported colorspace parameter values

All supported string values for colorspace parameter are as follows:

You can check all OpenCV Colorspace Conversion Codes here ➶.

Supported Conversion Values Description
COLOR_BGR2BGRA BGR to BGRA
COLOR_BGR2RGBA BGR to RGBA
COLOR_BGR2RGB BGR to RGB backward conversions to RGB/BGR
COLOR_BGR2GRAY BGR to GRAY
COLOR_BGR2BGR565 BGR to BGR565
COLOR_BGR2BGR555 BGR to BGR555
COLOR_BGR2XYZ BGR to CIE XYZ
COLOR_BGR2YCrCb BGR to luma-chroma (aka YCC)
COLOR_BGR2HSV BGR to HSV (hue saturation value)
COLOR_BGR2Lab BGR to CIE Lab
COLOR_BGR2Luv BGR to CIE Luv
COLOR_BGR2HLS BGR to HLS (hue lightness saturation)
COLOR_BGR2HSV_FULL BGR to HSV_FULL
COLOR_BGR2HLS_FULL BGR to HLS_FULL
COLOR_BGR2YUV BGR to YUV
COLOR_BGR2YUV_I420 BGR to YUV 4:2:0 family
COLOR_BGR2YUV_IYUV BGR to IYUV
COLOR_BGR2YUV_YV12 BGR to YUV_YV12
None Back to default colorspace (i.e. BGR)

 

Usage examples

Using CamGear with Direct Colorspace Manipulation

The complete usage example can be found here ➶

 

Using PiGear with Direct Colorspace Manipulation

The complete usage example can be found here ➶

 

Using VideoGear with Colorspace Manipulation

The complete usage example can be found here ➶

 

Using ScreenGear with Direct Colorspace Manipulation

The complete usage example can be found here ➶