Functions for loading, adjusting, or reading from the Picamera2 tuning file.
The functions that edit the tuning files return a new dictionary that is updated.
| Class | |
A Pydantic model holding the lens shading tables. |
| Exception | |
Raised if the tuning file cannot be loaded for any reason. |
| Function | ce |
Whether the ce_enable flag is disabled. |
| Function | copy |
Return a copy of tuning_file with an algorithm copied from another file. |
| Function | find |
Return the parameters for the named algorithm in the given camera tuning dict. |
| Function | flatten |
Flaten the len shading table ro an array of ones. |
| Function | geq |
Whether the green equalisation is set to static. |
| Function | get |
Get a copy of the the rpi.ccm section of a camera tuning dict. |
| Function | get |
Get the colour gains that are needed from the lens shading tables. |
| Function | get |
Return the lens shading as a LenSading Base Model. |
| Function | load |
Load the default tuning file for the camera. |
| Function | lst |
Whether the lens shading table is calibrated. |
| Function | set |
Update the rpi.ccm section of a camera tuning dict set the colour correction matrix. |
| Function | set |
Set ce_enable in rpi.contrast to zero to disable adaptive contrast enhancement. |
| Function | set |
Update the rpi.alsc section of with new lens shading tables. |
| Function | set |
Update the rpi.geq section of a camera tuning dict. |
| Constant | CALIBRATED |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | THIS |
Undocumented |
| Function | _as |
Flatten array, round, and then convert to list. |
| Function | _index |
Find the index of an algorithm's section in the tuning file. |
str, *, base_tuning_file: dict, copy_from: dict) -> dict:
(source)
¶
Return a copy of tuning_file with an algorithm copied from another file.
Tuning dict arguments are keyword only for clarity.
| Parameters | |
algo:str | The algorithm to copy. Eg rpi.alsc for lens shading correction. |
basedict | The tuning file to copy. |
copydict | The tuning file to copy the algorithm from section from. |
| Returns | |
dict | A deep copy of base_tuning_file with the specified algorithm copied in from the other tuning file. |
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[ | The camera tuning dictionary |
name:str | The key for the algorithm in the tuning file |
| Returns | |
dict[ | The algorithm from the tuning dictionary. Editing this will edit the original dictionary. |
Flaten the len shading table ro an array of ones.
| Parameters | |
tuning:dict | The current tuning dictionary. |
keepbool | Set to True to only flatten the cr and cb tables. |
| Returns | |
dict | An updated tuning dict. |
Get the colour gains that are needed from the lens shading tables.
The lens shading tables are calculated to create a white balanced image, but the ISP normalises by the minimum Cr and Cb value. So these need to be set as colour gains.
Load the default tuning file for the camera.
This will load the tuning file based on the specified sensor model.
Whether the lens shading table is calibrated.
This checks whether the lens shading table is has a colour temperature of 5000. As this is what we set on calibration. Our tuning file sets a temperature of 1234.
Update the rpi.ccm section of a camera tuning dict set the colour correction matrix.
| Parameters | |
tuning:dict | The current tuning dict |
collist | The colour correction matrix to set |
| Returns | |
dict | an updated tuning dict with the new colour correction matrix. |
Set ce_enable in rpi.contrast to zero to disable adaptive contrast enhancement.
| Parameters | |
tuning:dict | The raspberry pi camera tuning file. |
| Returns | |
dict | A deepcopy of the input file with ce_enable set to 0. |
dict, *, luminance: np.ndarray | None, cr: np.ndarray | None, cb: np.ndarray | None, colour_temp: int) -> dict:
(source)
¶
Update the rpi.alsc section of with new lens shading tables.
Only one set of tables is set so that the camera pipeline does not adaptively switch between lens shading tables based on its estimation of colour temperature. Also n_iter is set to 0 so that the pipeline doesn't perform an iterative adaption of our table to try to "correct" if interprets the image as having different types of lighting.
| Parameters | |
tuning:dict | The current tuning file. |
luminance:np.ndarray | None | The table of luminance values, as (12, 16) numpy array. Or None to leave unchanged. |
cr:np.ndarray | None | The table of Cr values, as (12, 16) numpy array. Or None to leave unchanged. |
cb:np.ndarray | None | The table of Cb values, as (12, 16) numpy array. Or None to leave unchanged. |
colourint | The colour temperature to set. On calibration this should be set to 5000. Set a different value for the PiCamera Thing to report that the lens shading is not calibrated. |
| Returns | |
dict | an updated tuning dict with the new lens shading tables. |
Update the rpi.geq section of a camera tuning dict.
| Parameters | |
tuning:dict | the Raspberry Pi camera tuning dictionary |
offset:int | The 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 | |
dict | An updated tuning dictionary |