module documentation

Functions for loading, adjusting, or reading from the Picamera2 tuning file.

The functions that edit the tuning files edit them in place. This will change in the future.

Function ce_enable_is_static Whether the ce_enable flag is disabled.
Function copy_tuning_with_alsc_section_from_other Return a copy of tuning_file with the lens shading correction from another file.
Function find_tuning_algo Return the parameters for the named algorithm in the given camera tuning dict.
Function geq_is_static Whether the green equalisation is set to static.
Function get_static_ccm Get a copy of the the rpi.ccm section of a camera tuning dict.
Function load_default_tuning Load the default tuning file for the camera.
Function lst_is_static Whether the lens shading table is set to static.
Function set_ce_to_disabled Set ce_enable in rpi.contrast to zero to disable adaptive contrast enhancement.
Function set_static_ccm Update the rpi.alsc section of a camera tuning dict to use a static correction.
Function set_static_geq Update the rpi.geq section of a camera tuning dict.
Function set_static_lst Update the rpi.alsc section of a camera tuning dict to use a static correction.
Function _as_flat_rounded_list Flatten array, round, and then convert to list.
Function _index_of_algorithm Find the index of an algorithm's section in the tuning file.
def ce_enable_is_static(tuning: dict) -> bool: (source)

Whether the ce_enable flag is disabled.

def copy_tuning_with_alsc_section_from_other(*, base_tuning_file: dict, copy_alsc_from: dict) -> dict: (source)

Return a copy of tuning_file with the lens shading correction from another file.

All parameters are keyword only for clarity.

Parameters
base_tuning_file:dictThe tuning file to copy.
copy_alsc_from:dictThe tuning file to take the alsc section from.
Returns
dictA deep copy of base_tuning_file with the alsc section copied in from the other tuning file.
def find_tuning_algo(tuning: dict[str, dict], name: str) -> dict[str, Any]: (source)

Return the parameters for the named algorithm in the given camera tuning dict.

This is the same methodolgy used in the PiCamera2 library but is provided here so it can be tested independently of installing picamera2

Parameters
tuning:dict[str, dict]The camera tuning dictionary
name:strThe key for the algorithm in the tuning file
Returns
dict[str, Any]The algorithm from the tuning dictionary. Editing this will edit the original dictionary.
def geq_is_static(tuning: dict) -> bool: (source)

Whether the green equalisation is set to static.

def get_static_ccm(tuning: dict): (source)

Get a copy of the the rpi.ccm section of a camera tuning dict.

def load_default_tuning(sensor_model: str) -> dict: (source)

Load the default tuning file for the camera.

This will load the tuning file based on the specified sensor model.

def lst_is_static(tuning: dict) -> bool: (source)

Whether the lens shading table is set to static.

def set_ce_to_disabled(tuning: dict) -> dict: (source)

Set ce_enable in rpi.contrast to zero to disable adaptive contrast enhancement.

Parameters
tuning:dictThe raspberry pi camera tuning file.
Returns
dictA deepcopy of the input file with ce_enable set to 0.
def set_static_ccm(tuning: dict, col_corr_matrix: tuple[float, float, float, float, float, float, float, float, float]) -> dict: (source)

Update the rpi.alsc section of a camera tuning dict to use a static correction.

tuning will be updated in-place to set its shading to static, and disable any adaptive tweaking by the algorithm.

def set_static_geq(tuning: dict, offset: int = 65535) -> dict: (source)

Update the rpi.geq section of a camera tuning dict.

Parameters
tuning:dictthe raspberry pi tuning file. This will be updated in-place to set the geq offset to the given value.
offset:intThe desired green equalisation offset. Default 65535. The default is the maximum allowed value. This means the brightness will always be below the threshold where averaging is used. This is default as we always need the green equalisation to averages the green pixels in the red and blue rows due to the chief ray angle compensation issue when the the stock lens is replaced by an objective.
Returns
dictUndocumented
def set_static_lst(tuning: dict, luminance: np.ndarray, cr: np.ndarray, cb: np.ndarray) -> dict: (source)

Update the rpi.alsc section of a camera tuning dict to use a static correction.

tuning will be updated in-place to set its shading to static, and disable any adaptive tweaking by the algorithm.

def _as_flat_rounded_list(array: np.ndarray, round_to: int = 3) -> list[float]: (source)

Flatten array, round, and then convert to list.

def _index_of_algorithm(algorithms: list[dict], algorithm: str) -> int: (source)

Find the index of an algorithm's section in the tuning file.