in src/spg_icvfxpatterns/PatternGenerators/exposureStops.py [0:0]
def generator(cls, frame, kwargs, results):
""" The method which creates the checkerboard images based on the kwargs provided
:param frame: the frame number we are generating
:param kwargs: a dictionary of the arguments for the generator
:param results: a dictionary to store the results
"""
led_wall = kwargs.get("led_wall", None)
if led_wall is None:
raise ValueError("led_wall not found in kwargs")
frame_num, full_file_path = cls.get_frame_num_and_file_path(frame, led_wall.name)
led_wall_image = cls.create_solid_color_image(
led_wall.resolution_width, led_wall.resolution_height
)
exposures = [section for section in range(-cls.number_of_stops, cls.number_of_stops + 1)]
number_of_grids = len(exposures)
section_width = int(led_wall.resolution_width / number_of_grids)
# If we fit to wall we find what the start point for the nit values must be in order to fit the number
# of exposure stops onto the ledwall based on its max brightness
if cls.fit_to_wall:
start_brightness_max = led_wall.panel.brightness / (2 ** ((len(exposures) - 1) * 0.5))
else:
# If fit to wall is false, we find the 18% grey as the start point for the exposure
start_brightness_max = (led_wall.panel.brightness * 0.01) * 18.0
start_brightness_max_code_values = start_brightness_max * 0.01
for section_count, exposure in enumerate(exposures):
# For now we do nits per section but this needs to become stops
# step_value = (10000 / number_of_grids) * section_count
power_of = exposure
step_value = start_brightness_max_code_values * (2 ** power_of)
# We can not go above 10,000 nits, so we clamp to the max that PQ can encode
if step_value > cls.MAX_PQ:
step_value = cls.MAX_PQ
step_image = cls.create_solid_color_image(
section_width, led_wall.resolution_height,
color=[step_value, step_value, step_value]
)
string_step_value = str(exposure)
if exposure > 0:
string_step_value = "+{0}".format(string_step_value)
_imageUtils.add_text_to_image_centre(
step_image, str(string_step_value), font_size=cls.font_size, text_color=cls.text_color,
y_pos_override=led_wall.resolution_height - (led_wall.resolution_height/100) * 10)
string_step_value = "{:.2f} NITS".format(step_value * 100)
_imageUtils.add_text_to_image_centre(
step_image, str(string_step_value), font_size=int(cls.font_size * 0.25), text_color=cls.text_color,
y_pos_override=led_wall.resolution_height - (led_wall.resolution_height / 100) * 20
)
oiio.ImageBufAlgo.paste(
led_wall_image, section_count * section_width, 0, 0, 0, step_image, roi=oiio.ROI.All)
# start_section +=1
section_count += 1
top_left = led_wall_image.copy()
top_left = oiio.ImageBufAlgo.resize(
top_left, roi=oiio.ROI(
0, int(led_wall.resolution_width * 0.5), 0,
int(led_wall.resolution_height * 0.5), 0, 1, 0, 3
)
)
bottom_left = top_left.copy()
top_right = top_left.copy()
bottom_right = top_left.copy()
top_left = oiio.ImageBufAlgo.flop(top_left)
top_right = oiio.ImageBufAlgo.flop(top_right)
top_left = oiio.ImageBufAlgo.flip(top_left)
top_right = oiio.ImageBufAlgo.flip(top_right)
oiio.ImageBufAlgo.paste(
led_wall_image, 0, 0, 0, 0, top_left, roi=oiio.ROI.All)
oiio.ImageBufAlgo.paste(
led_wall_image, 0, int(led_wall.resolution_height * 0.5), 0, 0, bottom_left, roi=oiio.ROI.All)
oiio.ImageBufAlgo.paste(
led_wall_image, int(led_wall.resolution_width * 0.5), 0, 0, 0, top_right, roi=oiio.ROI.All)
oiio.ImageBufAlgo.paste(
led_wall_image, int(led_wall.resolution_width * 0.5), int(led_wall.resolution_height * 0.5), 0, 0,
bottom_right, roi=oiio.ROI.All)
# Write the image to disk and store the result
cls.write_image_and_store_result(
frame_num, full_file_path, led_wall.name, led_wall_image, results
)