-
Notifications
You must be signed in to change notification settings - Fork 33
Configuration
- Debugging
- Logging
- Resolution
- Sharpness
- Contrast
- Brightness
- Saturation
- ISO
- Exposure compensation
- Exposure mode
- Exposure metering mode
- Automatic white balance mode
- Image effects
- Colour effects
- Rotation
- Flip image
- Zoom (Region of interest)
- Shutter speed
- Automatic white balance
- Dynamic range compression
- Statistics pass
- Annotation
- Encoding
- Camera mode
- Preview renderer configuration
- Static overlay configuration
- Video specific configuration
When in debug mode, MMALSharp will write additional information to the logs; the additional logging will not be necessary under normal operation as it will cause the output file to grow in size quite quickly depending on what operation you're carrying out with the camera. The messages are helpful to indicate any potential issues during capture.
MMALCameraConfig.Debug = true;
If further debugging is required, you can enable the native MMAL debugging logs as seen below:
-
Raspberry Pi 3: In the /boot/config.txt file, add the following:
start_debug=1
. Raspberry Pi 4: You must specify "start_file" and "fixup_file" manually in /boot/config.txt - addstart_file=start4db.elf
andfixup_file=fixup4db.dat
. - Prior to running MMALSharp, run
export VC_LOGLEVEL=mmal:trace
- Capture image using MMALSharp
- Run
sudo vcdbg log msg
andsudo vcdbg log assert
As of v0.6, MMALSharp now uses Microsoft.Extensions.Logging.Abstractions to provide package agnostic logging. If you want to enable logging, you must provide the ILoggerFactory instance your client application is using. For .NET Core applications, this will typically be done during dependency injection configuration. For more information, please see here. The ILoggerFactory instance should be set before carrying out any MMALSharp specific operations.
MMALLog.LoggerFactory = myLoggerFactory;
// Take picture/video etc...
Note: `LoggerFactory.Create` is a helper method exposed in .NET Core 3.0.
<a name="resolution" />
## Resolution
Changes the resolution of outputted images. The camera module has a pre-defined set of sensor modes which it will use when capturing images. Don't worry if the resolution you choose does not match any of the sensor modes - the GPU ISP will scale the image on your behalf.
<a name="image-resolution" />
### Image Resolution
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.StillResolution</tt></td></tr>
<tr><th>Default Value</th><td><tt>Resolution.As5MPixel</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>Resolution.As8MPixel</tt>, <tt>Resolution.As7MPixel</tt>,
<tt>Resolution.As6MPixel</tt>, <tt>Resolution.As5MPixel</tt>,
<tt>Resolution.As4MPixel</tt>, <tt>Resolution.As3MPixel</tt>,
<tt>Resolution.As2MPixel</tt>, <tt>Resolution.As1MPixel</tt>,
<tt>Resolution.As03MPixel</tt>, <tt>Resolution.As720p</tt>,
<tt>Resolution.As1080p</tt>, <tt>Resolution.As1440p</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.StillResolution = new Resolution(640, 480);</pre>
<pre>MMALCameraConfig.StillResolution = Resolution.As5MPixel;</pre>
</td></tr>
</tbody></table>
<a name="video-resolution" />
### Video Resolution
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.VideoResolution</tt></td></tr>
<tr><th>Default Value</th><td><tt>Resolution.As1080p</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>Resolution.As8MPixel</tt>, <tt>Resolution.As7MPixel</tt>,
<tt>Resolution.As6MPixel</tt>, <tt>Resolution.As5MPixel</tt>,
<tt>Resolution.As4MPixel</tt>, <tt>Resolution.As3MPixel</tt>,
<tt>Resolution.As2MPixel</tt>, <tt>Resolution.As1MPixel</tt>,
<tt>Resolution.As03MPixel</tt>, <tt>Resolution.As720p</tt>,
<tt>Resolution.As1080p</tt>, <tt>Resolution.As1440p</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.VideoResolution = new Resolution(640, 480);</pre>
<pre>MMALCameraConfig.VideoResolution = Resolution.As1080p;</pre>
</td></tr>
</tbody></table>
<a name="sharpness" />
## Sharpness
Changes the Sharpness of an image.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.Sharpness</tt></td></tr>
<tr><th>Default Value</th><td><tt>0 (auto)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>0 - 100</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.Sharpness = 50;</pre>
</td></tr>
</tbody></table>
<a name="contrast" />
## Contrast
Changes the Contrast of an image.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.Contrast</tt></td></tr>
<tr><th>Default Value</th><td><tt>0 (auto)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>0 - 100</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.Contrast = 50;</pre>
</td></tr>
</tbody></table>
<a name="brightness" />
## Brightness
Changes the Brightness of an image.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.Brightness</tt></td></tr>
<tr><th>Default Value</th><td><tt>50</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>0 - 100</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.Brightness = 70;</pre>
</td></tr>
</tbody></table>
<a name="saturation" />
## Saturation
Changes the Saturation of an image.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.Saturation</tt></td></tr>
<tr><th>Default Value</th><td><tt>0 (auto)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>0 - 100</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.Saturation = 50;</pre>
</td></tr>
</tbody></table>
<a name="iso" />
## ISO
Changes the ISO setting used by the sensor. Relates to the amount of time the sensor is exposed to light. A lower value means
the sensor will be exposed for longer. The Shutter Speed will automatically adjust based on the ISO value committed.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ISO</tt></td></tr>
<tr><th>Default Value</th><td><tt>0 (auto)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>0 (auto) or 100 - 800</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.ISO = 100;</pre>
</td></tr>
</tbody></table>
<a name="exposure-compensation" />
## Exposure Compensation
Change the Exposure Compensation of the sensor - doing so will produce a lighter/darker image beyond the recommended exposure.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ExposureCompensation</tt></td></tr>
<tr><th>Default Value</th><td><tt>0</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>-10 - 10</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.ExposureCompensation = 10;</pre>
</td></tr>
</tbody></table>
<a name="exposure-mode" />
## Exposure Mode
Configure the Exposure Mode used by the sensor.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ExposureCompensation</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_PARAM_EXPOSUREMODE_T.MMAL_PARAM_EXPOSUREMODE_AUTO</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<pre>
MMAL_PARAM_EXPOSUREMODE_AUTO, // auto: use automatic exposure mode
MMAL_PARAM_EXPOSUREMODE_NIGHT, // night: select setting for night shooting
MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
MMAL_PARAM_EXPOSUREMODE_BACKLIGHT, // backlight: select setting for backlit subject
MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
MMAL_PARAM_EXPOSUREMODE_SPORTS, // sports: select setting for sports(fast shutter etc.)
MMAL_PARAM_EXPOSUREMODE_SNOW, // snow: select setting optimised for snowy scenery
MMAL_PARAM_EXPOSUREMODE_BEACH, // beach: select setting optimised for beach
MMAL_PARAM_EXPOSUREMODE_VERYLONG, // verylong: select setting for long exposures
MMAL_PARAM_EXPOSUREMODE_FIXEDFPS, // fixedfps: constrain fps to a fixed value
MMAL_PARAM_EXPOSUREMODE_ANTISHAKE, // antishake: antishake mode
MMAL_PARAM_EXPOSUREMODE_FIREWORKS // fireworks: select setting optimised for fireworks
</pre>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.ExposureCompensation = MMAL_PARAM_EXPOSUREMODE_T.MMAL_PARAM_EXPOSUREMODE_AUTO;</pre>
</td></tr>
</tbody></table>
<a name="exposure-metering-mode" />
## Exposure Metering Mode
Configure the exposure metering mode to be used by the camera. The metering mode determines how the camera measures exposure.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ExposureMeterMode</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<pre>
MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT
MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE
MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX
</pre>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.ExposureMeterMode = MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE;</pre>
</td></tr>
</tbody></table>
Spot metering `MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT`:
With spot metering, the camera will only measure a very small area of the scene and ignores everything else.
On the Raspberry Pi camera, this will be the very centre of the image.
Average metering `MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE`:
Using this metering mode, the camera will use the light information coming from the entire scene. It does not focus on any particular
area of the scene.
Matrix metering `MMAL_PARAM_EXPOSUREMETERINGMODE_T.MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX`:
Matrix metering works by dividing the entire frame into multiple "zones" which are then analysed on an individual basis for light and dark tones.
Sources:
[https://photographylife.com/understanding-metering-modes](https://photographylife.com/understanding-metering-modes)
[https://en.wikipedia.org/wiki/Metering_mode#Spot_metering](https://en.wikipedia.org/wiki/Metering_mode#Spot_metering)
<a name="automatic-white-balance-mode" />
## Automatic white balance mode
Configure the Auto White Balance to be used by the camera
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.AwbMode</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_PARAM_AWBMODE_T.MMAL_PARAM_AWBMODE_OFF</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<pre>
MMAL_PARAM_AWBMODE_OFF, // off: turn off white balance calculation
MMAL_PARAM_AWBMODE_AUTO, // auto: automatic mode(default)
MMAL_PARAM_AWBMODE_SUNLIGHT, // sun: sunny mode(between 5000K and 6500K)
MMAL_PARAM_AWBMODE_CLOUDY, // cloud: cloudy mode(between 6500K and 12000K)
MMAL_PARAM_AWBMODE_SHADE, // shade: shade mode
MMAL_PARAM_AWBMODE_TUNGSTEN, // tungsten: tungsten lighting mode(between 2500K and 3500K)
MMAL_PARAM_AWBMODE_FLUORESCENT, // fluorescent: fluorescent lighting mode(between 2500K and 4500K)
MMAL_PARAM_AWBMODE_INCANDESCENT, // incandescent: incandescent lighting mode
MMAL_PARAM_AWBMODE_FLASH, // flash: flash mode
MMAL_PARAM_AWBMODE_HORIZON // horizon: horizon mode
</pre>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.AwbMode = MMAL_PARAM_AWBMODE_T.MMAL_PARAM_AWBMODE_AUTO;</pre>
</td></tr>
</tbody></table>
<a name="image-effects" />
## Image effects
Apply effects to the resulting image. Some effects may not be applicable depending on the firmware version.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ImageFx</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_PARAM_IMAGEFX_T.MMAL_PARAM_IMAGEFX_NONE</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<pre>
MMAL_PARAM_IMAGEFX_NONE, // none: no effect (default)
MMAL_PARAM_IMAGEFX_NEGATIVE, // negative: invert the image colours
MMAL_PARAM_IMAGEFX_SOLARIZE, // solarise: solarise the image
MMAL_PARAM_IMAGEFX_POSTERIZE, // posterise: posterise the image
MMAL_PARAM_IMAGEFX_WHITEBOARD, // whiteboard: whiteboard effect
MMAL_PARAM_IMAGEFX_BLACKBOARD, // blackboard: blackboard effect
MMAL_PARAM_IMAGEFX_SKETCH, // sketch: sketch effect
MMAL_PARAM_IMAGEFX_DENOISE, // denoise: denoise the image
MMAL_PARAM_IMAGEFX_EMBOSS, // emboss: emboss the image
MMAL_PARAM_IMAGEFX_OILPAINT, // oilpaint: oil paint effect
MMAL_PARAM_IMAGEFX_HATCH, // hatch: hatch sketch effect
MMAL_PARAM_IMAGEFX_GPEN, // gpen: graphite sketch effect
MMAL_PARAM_IMAGEFX_PASTEL, // pastel: pastel effect
MMAL_PARAM_IMAGEFX_WATERCOLOUR, // watercolour: watercolour effect
MMAL_PARAM_IMAGEFX_FILM, // film: film grain effect
MMAL_PARAM_IMAGEFX_BLUR, // blur: blur the image
MMAL_PARAM_IMAGEFX_SATURATION, // saturation: colour saturate the image
MMAL_PARAM_IMAGEFX_COLOURSWAP, // colourswap: not fully implemented
MMAL_PARAM_IMAGEFX_WASHEDOUT, // washedout: not fully implemented
MMAL_PARAM_IMAGEFX_COLOURPOINT, // colourpoint: not fully implemented
MMAL_PARAM_IMAGEFX_COLOURBALANCE, // colourbalance: not fully implemented
MMAL_PARAM_IMAGEFX_CARTOON // cartoon: not fully implemented
</pre>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.ImageFx = MMAL_PARAM_IMAGEFX_T.MMAL_PARAM_IMAGEFX_PASTEL;</pre>
</td></tr>
</tbody></table>
<a name="colour-effects" />
## Colour effects
Allows a user to change the colour of an image. Firmware expects U and V components of YUV colour space i.e. U = 128, V = 128 will result in a greyscale (monochrome) image. MMALSharp converts a `System.Drawing.Color` struct on your behalf.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ColourFx</tt></td></tr>
<tr><th>Default Value</th><td><tt>Disabled</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>A `System.Drawing.Color` structure.</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>
MMALCameraConfig.ColourFx = new ColourEffects
{
Color = Color.Blue,
Enable = true
}; </pre>
</td></tr>
</tbody></table>
<a name="rotation" />
## Rotation
Rotate the resulting image.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.Rotation</tt></td></tr>
<tr><th>Default Value</th><td><tt>0</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>0, 90, 180, 270</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.Rotation = 90;</pre>
</td></tr>
</tbody></table>
<a name="flip-image" />
## Flip image
Flip the resulting image.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.Flips</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_PARAM_MIRROR_T.MMAL_PARAM_MIRROR_NONE</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<pre>
MMAL_PARAM_MIRROR_NONE,
MMAL_PARAM_MIRROR_VERTICAL,
MMAL_PARAM_MIRROR_HORIZONTAL,
MMAL_PARAM_MIRROR_BOTH
</pre>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.Flips = MMAL_PARAM_MIRROR_T.MMAL_PARAM_MIRROR_VERTICAL;</pre>
</td></tr>
</tbody></table>
<a name="zoom" />
## Zoom (Region of interest)
Zoom in on the resulting image to produce a Region of Interest.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ROI</tt></td></tr>
<tr><th>Default Value</th><td><tt>Disabled</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>
X, Y, Height and Width parameters must be less than 1.0.
</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>
MMALCameraConfig.ROI = new Zoom
{
X = 0.5,
Y = 0.5,
Height = 0.1,
Width = 0.1
};</pre>
</td></tr>
</tbody></table>
<a name="shutter-speed" />
## Shutter speed
Adjust the shutter speed, this setting adjusts the length of time that the sensor is exposed to light. A fast shutter speed will reduce the length of time
it is exposed to light.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.ShutterSpeed</tt></td></tr>
<tr><th>Default Value</th><td><tt>0 (auto)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>
0 - 6000000 (8000000 on v2 module)
</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.ShutterSpeed = 1000000;</pre>
</td></tr>
</tbody></table>
There is an upper limit of 6000000us (6000ms, 6s), past which operation is undefined.
<a name="automatic-white-balance-red" />
## Automatic white balance - Red gains
Sets red AWB gains to be applied. Only applies when AwbMode is disabled.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.AwbGainsR</tt></td></tr>
<tr><th>Default Value</th><td><tt>0 (auto)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>
TODO
</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.AwbGainsR = 2;</pre>
</td></tr>
</tbody></table>
<a name="automatic-white-balance-blue" />
## Automatic white balance - Blue gains
Sets blue AWB gains to be applied. Only applies when AwbMode is disabled.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.AwbGainsB</tt></td></tr>
<tr><th>Default Value</th><td><tt>0 (auto)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>
TODO
</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.AwbGainsB = 2;</pre>
</td></tr>
</tbody></table>
<a name="dynamic-range-compression" />
## Dynamic range compression
Dynamic range compression increases the range of dark areas and decreases brighter areas, which helps improve the resulting image in low light areas.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.DrcLevel</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_PARAMETER_DRC_STRENGTH_T.MMAL_PARAMETER_DRC_STRENGTH_OFF</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<pre>
MMAL_PARAMETER_DRC_STRENGTH_OFF
MMAL_PARAMETER_DRC_STRENGTH_LOW
MMAL_PARAMETER_DRC_STRENGTH_MEDIUM
MMAL_PARAMETER_DRC_STRENGTH_HIGH
</pre>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.DrcLevel = MMAL_PARAMETER_DRC_STRENGTH_T.MMAL_PARAMETER_DRC_STRENGTH_MEDIUM;</pre>
</td></tr>
</tbody></table>
<a name="statistics-pass" />
## Statistics pass
Displays the exposure, analogue and digital gains, and AWB settings used.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.StatsPass</tt></td></tr>
<tr><th>Default Value</th><td><tt>false</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>true</tt>, <tt>false</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.StatsPass = true;</pre>
</td></tr>
</tbody></table>
<a name="annotation" />
## Annotation
Allows annotation to be applied to the resulting image.
**Enable annotation**
There are public API methods to enable and disable the annotation functionality. To enable, call `MMALCamera.EnableAnnotation`. To disable, call `MMALCamera.DisableAnnotation`.
**Customise annotation options**
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.Annotate</tt></td></tr>
<tr><th>Default Value</th><td><tt></tt></td></tr>
<tr><th>Properties</th>
<td>
<tt>CustomText</tt>, <tt>TextSize</tt>, <tt>TextColour</tt>, <tt>BgColour</tt>,
<tt>ShowShutterSettings</tt>, <tt>ShowGainSettings</tt>,
<tt>ShowLensSettings</tt>, <tt>ShowCafSettings</tt>,
<tt>ShowMotionSettings</tt>, <tt>ShowFrameNumber</tt>,
<tt>ShowBlackBackground</tt>, <tt>ShowDateText</tt>,
<tt>ShowTimeText</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>
MMALCameraConfig.Annotate = new AnnotateImage
{
ShowDateText = true,
ShowTimeText = true
}; </pre>
</td></tr>
</tbody></table>
<a name="encoding" />
## Encoding
In MMALSharp, certain Components provide the ability to have their encoding type and pixel format changed, namely the Camera, Encoder/Decoder, Splitter and Resizer components.
A user is able to change the encoding type and pixel format used by a Component by using one of the Encoding formats available in the `MMALSharp.Native.MMALEncoding` class.
To change the encoding of the Camera component, there are specific `MMALCameraConfig` properties that you can adjust prior to initialising the Camera component, i.e prior to calling `MMALCamera.Instance`. The encoding type set against these properties will dictate which raw encoding type is used when sending data from the camera sensor.
MMALCameraConfig.StillEncoding MMALCameraConfig.StillSubFormat
MMALCameraConfig.VideoEncoding MMALCameraConfig.VideoSubformat
MMALCameraConfig.PreviewEncoding MMALCameraConfig.PreviewSubformat
For all other components, the encoding type is specified when configuring the output port of your respective downstream component, i.e when calling `ConfigureOutputPort`.
<a name="camera-mode" />
# Camera mode
Both camera modules feature different modes which affects their output resolution, framerate, and field of view. Details of the various modes available can be found [here](https://github.com/techyian/MMALSharp/wiki/OmniVision-OV5647-Camera-Module) for the OV5647 module, and [here](https://github.com/techyian/MMALSharp/wiki/Sony-IMX219-Camera-Module) for the IMX219.
Selecting a video mode which is as close as possible to your desired resolution is favourable, and MMALSharp selects Mode 0 (automatic) by default; in automatic mode the sensor will select the optimal settings based on your specified resolution and framerate.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.SensorMode</tt></td></tr>
<tr><th>Default Value</th><td><tt>Mode0</tt></td></tr>
<tr><th>Properties</th>
<td>
<tt>Mode0</tt>, <tt>Mode1</tt>, <tt>Mode2</tt>, <tt>Mode3</tt>,
<tt>Mode4</tt>, <tt>Mode5</tt>,
<tt>Mode6</tt>, <tt>Mode7</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>
MMALCameraConfig.SensorMode = MMALSensorMode.Mode0;
</pre>
</td></tr>
</tbody></table>
# Preview renderer configuration
<a name="preview-fullscreen" />
Indicates whether to use full screen or windowed mode.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewConfiguration.FullScreen</tt></td></tr>
<tr><th>Default Value</th><td><tt>true</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>true</tt>, <tt>false</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewConfiguration
{
FullScreen = false
}; </pre>
</td></tr>
</tbody></table>
<a name="preview-noaspect" />
If set to true, indicates that any display scaling should disregard the aspect ratio of the frame region being displayed.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewConfiguration.NoAspect</tt></td></tr>
<tr><th>Default Value</th><td><tt>false</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>true</tt>, <tt>false</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewConfiguration
{
NoAspect = true
}; </pre>
</td></tr>
</tbody></table>
<a name="preview-window" />
Specifies where the preview overlay should be drawn on the screen.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewConfiguration.PreviewWindow</tt></td></tr>
<tr><th>Default Value</th><td><tt>new Rectangle(0, 0, 1024, 768);</tt></td></tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewConfiguration
{
PreviewWindow = new Rectangle(200, 50, 640, 480);
}; </pre>
</td></tr>
</tbody></table>
<a name="preview-opacity" />
Opacity of the preview windows. Value between 1 (fully invisible) - 255 (fully opaque). Note: If RGBA encoding is used with the preview component then the alpha channel will be ignored.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewConfiguration.Opacity</tt></td></tr>
<tr><th>Default Value</th><td><tt>255</tt></td></tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewConfiguration
{
Opacity = 100
}; </pre>
</td></tr>
</tbody></table>
<a name="preview-layer" />
Sets the relative depth of the images, with greater values being in front of smaller values.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewConfiguration.Layer</tt></td></tr>
<tr><th>Default Value</th><td><tt>2</tt></td></tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewConfiguration
{
Layer = 1
}; </pre>
</td></tr>
</tbody></table>
<a name="preview-display-transform" />
Indicates whether any flipping or rotation should be used on the overlay.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewConfiguration.DisplayTransform</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_DISPLAY_ROT0</tt></td></tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewConfiguration
{
DisplayTransform = MMALParametersVideo.MMAL_DISPLAYTRANSFORM_T.MMAL_DISPLAY_ROT90
}; </pre>
</td></tr>
</tbody></table>
<a name="preview-display-mode" />
Indicates how the image should be scaled to fit the display.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewConfiguration.DisplayMode</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_DISPLAY_MODE_FILL</tt></td></tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewConfiguration
{
DisplayTransform = MMALParametersVideo.MMAL_DISPLAYMODE_T.MMAL_DISPLAY_MODE_LETTERBOX
}; </pre>
</td></tr>
</tbody></table>
# Static overlay configuration
The `PreviewOverlayConfiguration` class inherits from `PreviewConfiguration`, meaning the info above regarding Preview renderer configuration applies here also.
<a name="preview-resolution" />
Specifies the resolution of the static resource to be used with this Preview Overlay. If this is null then the parent renderer's resolution will be used instead.
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewOverlayConfiguration.Resolution</tt></td></tr>
<tr><th>Default Value</th><td><tt></tt></td></tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewOverlayConfiguration
{
Resolution = new Resolution(640, 480);
}; </pre>
</td></tr>
</tbody></table>
<a name="preview-encoding" />
The encoding of the static resource. Can be one of the following: YUV, RGB, RGBA, BGR, BGRA. If left null, we will try to work out the encoding based on the size of the image (3 bytes for RGB, 4 bytes for RGBA).
<table><tbody>
<tr><th>Instance property</th><td><tt>PreviewOverlayConfiguration.Encoding</tt></td></tr>
<tr><th>Default Value</th><td><tt></tt></td></tr>
<tr><th>How to Set:</th><td>
<pre>
var config = new PreviewOverlayConfiguration
{
Encoding = MMALEncoding.I420;
}; </pre>
</td></tr>
</tbody></table>
# Video specific configuration
<a name="video-stabilisation" />
## Video stabilisation
Enables video stabilisation support when recording video
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.VideoStabilisation</tt></td></tr>
<tr><th>Default Value</th><td><tt>true</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>true</tt>, <tt>false</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.VideoStabilisation = true;</pre>
</td></tr>
</tbody></table>
<a name="rate-control" />
## Rate control
Not supported by firmware however code present.
<a name="intra-refresh-period" />
## Intra refresh period (GoP)
**H.264 encoding only**
Every intra refresh period, H.264 video uses a complete frame (I-frame) which subsequent frames are then based upon. This setting specifies the number of frames between each I-frame. A higher value will reduce the size of the resulting video, and
a smaller value will result in a less error prone stream.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.IntraPeriod</tt></td></tr>
<tr><th>Default Value</th><td><tt>-1 (disabled)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.IntraPeriod = 1;</pre>
</td></tr>
</tbody></table>
<a name="video-profile" />
## Video profile
Sets the encoding profile.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.VideoProfile</tt></td></tr>
<tr><th>Default Value</th><td><tt>-1 (disabled)</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>MMAL_VIDEO_PROFILE_T.MMAL_VIDEO_PROFILE_H264_HIGH</tt>, <tt>MMAL_VIDEO_PROFILE_T.MMAL_VIDEO_PROFILE_H264_MAIN</tt>,
<tt>MMAL_VIDEO_PROFILE_T.MMAL_VIDEO_PROFILE_H264_EXTENDED</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.VideoProfile = MMAL_VIDEO_PROFILE_T.MMAL_VIDEO_PROFILE_H264_HIGH;</pre>
</td></tr>
</tbody></table>
<a name="video-level" />
## Video level
Sets the encoding level.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.VideoLevel</tt></td></tr>
<tr><th>Default Value</th><td><tt>MMAL_VIDEO_LEVEL_T.MMAL_VIDEO_LEVEL_H264_4</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<pre>
MMAL_VIDEO_LEVEL_H264_1
MMAL_VIDEO_LEVEL_H264_1b
MMAL_VIDEO_LEVEL_H264_11
MMAL_VIDEO_LEVEL_H264_12
MMAL_VIDEO_LEVEL_H264_13
MMAL_VIDEO_LEVEL_H264_2
MMAL_VIDEO_LEVEL_H264_21
MMAL_VIDEO_LEVEL_H264_22
MMAL_VIDEO_LEVEL_H264_3
MMAL_VIDEO_LEVEL_H264_31
MMAL_VIDEO_LEVEL_H264_32
MMAL_VIDEO_LEVEL_H264_4
MMAL_VIDEO_LEVEL_H264_41
MMAL_VIDEO_LEVEL_H264_42
</pre>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.VideoLevel = MMAL_VIDEO_LEVEL_T.MMAL_VIDEO_LEVEL_H264_42;</pre>
</td></tr>
</tbody></table>
Valid values: See `MMALSharp.Native.MMALParametersVideo.MMAL_VIDEO_LEVEL_T`
<a name="inline-headers" />
## Inline headers
When enabled, the stream will include PPS and SPS headers on every I-frame. Certain
streaming methods require this to be enabled e.g. Apple HLS.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.InlineHeaders</tt></td></tr>
<tr><th>Default Value</th><td><tt>false</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>true</tt>, <tt>false</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.InlineHeaders = true;</pre>
</td></tr>
</tbody></table>
<a name="inline-motion-vectors" />
## Inline Motion Vectors
When enabled, Inline Motion Vector headers will be produced. These Vectors display
motion occurred between frames.
<table><tbody>
<tr><th>Instance property</th><td><tt>MMALCameraConfig.InlineMotionVectors</tt></td></tr>
<tr><th>Default Value</th><td><tt>false</tt></td></tr>
<tr><th>Possible Values</th>
<td>
<tt>true</tt>, <tt>false</tt>
</td>
</tr>
<tr><th>How to Set:</th><td>
<pre>MMALCameraConfig.InlineMotionVectors = true;</pre>
</td></tr>
</tbody></table>