in src/spg_icvfxpatterns/PatternGenerators/colorPatch.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")
patch_counter = kwargs.get("patch_counter", None)
if patch_counter is None:
raise ValueError("patch_counter 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
)
pixel_width = cls.absolute_pixel_width
pixel_height = cls.absolute_pixel_width
if not pixel_width or not pixel_height:
if not cls.percentage_width or not cls.percentage_height:
raise ValueError("Please specify either absolute pixel widths or heights")
pixel_width = int(cls.percentage_width * led_wall.resolution_width)
pixel_height = int(cls.percentage_height * led_wall.resolution_height)
patch_color = cls.color_patch_values[patch_counter]
normalized_color = [
normalize(patch_color_channel, cls.color_range_min, cls.color_range_max)
for patch_color_channel in patch_color
]
patch_image = cls.create_solid_color_image(
pixel_width, pixel_height, color=normalized_color
)
centre_x = int((led_wall.resolution_width * 0.5) - (pixel_width * 0.5))
centre_y = int((led_wall.resolution_height * 0.5) - (pixel_height * 0.5))
oiio.ImageBufAlgo.paste(
led_wall_image, centre_x, centre_y, 0, 0, patch_image, 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
)