Taking Screenshots with Python Script

Hi I’m trying to take images using a python script to take a batch of screen shots at a certain position over multiple ticks (I’m changing some post process material instance properties and I want to eventually compare them to each other). I’ve set up break points around the take_high_res_screenshot() function and I tried breaking my script after only taking one screenshot. However, the engine still gets stuck compiling it’s shaders at 0% and never actually takes the screenshot (until it eventually crashes which is likely due to memory error).

image

class capture(object):
    def __init__(self):
        unreal.EditorLevelLibrary.editor_set_game_view(True)
        self.parameter_combinations = parameter_combinations
        self.count = 0
        self.on_pre_tick = unreal.register_slate_pre_tick_callback(self.__pretick__)
        
    
    def __pretick__(self, deltatime):
        try:
            self.count += 1

            # Will add functions later on that change the parameters in a post processing material instance I created

            filename = str(self.count) + ".png"
            unreal.AutomationLibrary.take_high_res_screenshot(1920, 1080, filename, camera = camera_actor)

           #Will add some pandas code for keeping a database with all the parameters

        except Exception as error:
            print(error)
            print(df.to_string())
            unreal.register_slate_pre_tick_callback(self.on_pre_tick)

instance = capture()

maybe this will help?