in src/open_vp_cal/framework/processing.py [0:0]
def _export_calibration(
output_folder: str, led_walls: List[LedWallSettings],
base_ocio_config: str, export_filter: bool = True,
export_lut_for_aces_cct: bool = False,
export_lut_for_aces_cct_in_target_out: bool = False) -> List[LedWallSettings]:
""" Runs the export process to generate the OCIO configuration files, CLF and luts
Args:
output_folder: The folder to export into
led_walls: The LED walls to export
base_ocio_config: The base OCIO config to use for the ocio config export
Returns: The LED walls with the export results stored in the wall processing results
"""
if not os.path.exists(output_folder):
os.makedirs(output_folder)
results_folder = os.path.join(output_folder, constants.ProjectFolders.RESULTS)
if not os.path.exists(results_folder):
os.makedirs(results_folder)
calibration_folder = os.path.join(output_folder, constants.ProjectFolders.CALIBRATION)
if not os.path.exists(calibration_folder):
os.makedirs(calibration_folder)
ocio_config_output_file = os.path.join(
calibration_folder, ocio_config.OcioConfigWriter.post_calibration_config_name
)
ocio_config_writer = ocio_config.OcioConfigWriter(calibration_folder)
for led_wall in led_walls:
samples_output_folder = os.path.join(
results_folder, f"{led_wall.name}_samples.json"
)
with open(samples_output_folder, "w", encoding="utf-8") as handle:
json.dump(led_wall.processing_results.samples, handle, indent=4)
reference_samples_output_folder = os.path.join(
results_folder, f"{led_wall.name}_reference_samples.json"
)
with open(reference_samples_output_folder, "w", encoding="utf-8") as handle:
json.dump(led_wall.processing_results.reference_samples, handle, indent=4)
calibration_results_file = os.path.join(
results_folder,
led_wall.name + "_calibration_results.json"
)
with open(calibration_results_file, "w", encoding="utf-8") as handle:
json.dump(led_wall.processing_results.calibration_results, handle, indent=4)
led_wall.processing_results.calibration_results_file = calibration_results_file
do_aces_cct_ocio_export = export_lut_for_aces_cct or export_lut_for_aces_cct_in_target_out
ocio_config_writer.generate_post_calibration_ocio_config(
led_walls, output_file=ocio_config_output_file, base_ocio_config=base_ocio_config,
preview_export_filter=export_filter, export_lut_for_aces_cct=do_aces_cct_ocio_export
)
for led_wall in led_walls:
if led_wall.is_verification_wall:
continue
led_wall.processing_results.ocio_config_output_file = ocio_config_output_file
if led_wall.calculation_order == constants.CalculationOrder.CO_CS_EOTF:
calc_order_string = constants.CalculationOrder.CO_CS_EOTF_STRING
else:
calc_order_string = constants.CalculationOrder.CO_EOTF_CS_STRING
if not led_wall.enable_eotf_correction:
calc_order_string = constants.CalculationOrder.CS_ONLY_STRING
aces_cct_desc = ""
if do_aces_cct_ocio_export:
aces_cct_desc = "_ACES_CCT_IN_OUT"
if export_lut_for_aces_cct_in_target_out:
aces_cct_desc = "_ACES_CCT_IN_TARGET_OUT"
lut_name = (f"{led_wall.name}_{led_wall.native_camera_gamut}_"
f"{led_wall.target_gamut}_{led_wall.target_eotf}_"
f"{calc_order_string}{aces_cct_desc}.cube")
lut_output_file = os.path.join(
calibration_folder, lut_name
)
if not do_aces_cct_ocio_export:
ocio_utils.bake_3d_lut(
led_wall.processing_results.led_wall_colour_spaces.target_with_inv_eotf_cs.getName(),
led_wall.processing_results.led_wall_colour_spaces.display_colour_space_cs.getName(),
ocio_config_writer.get_calibrated_output_name(led_wall.processing_results.led_wall_colour_spaces),
ocio_config_output_file, lut_output_file
)
if do_aces_cct_ocio_export and export_lut_for_aces_cct_in_target_out:
ocio_utils.bake_3d_lut(
constants.CameraColourSpace.CS_ACES_CCT,
led_wall.processing_results.led_wall_colour_spaces.display_colour_space_cs.getName(),
ocio_config_writer.get_calibrated_output_name(led_wall.processing_results.led_wall_colour_spaces),
ocio_config_output_file, lut_output_file
)
if do_aces_cct_ocio_export and not export_lut_for_aces_cct_in_target_out:
ocio_utils.bake_3d_lut(
constants.CameraColourSpace.CS_ACES_CCT,
led_wall.processing_results.led_wall_colour_spaces.aces_cct_display_colour_space_cs.getName(),
led_wall.processing_results.led_wall_colour_spaces.aces_cct_calibration_view_transform.getName(),
ocio_config_output_file, lut_output_file
)
led_wall.processing_results.lut_output_file = lut_output_file
return led_walls