Add cache_images option
This commit is contained in:
parent
cd30da3426
commit
420754ed32
|
@ -14,6 +14,7 @@ framerate = 16
|
||||||
vflip = false
|
vflip = false
|
||||||
hflip = false
|
hflip = false
|
||||||
export_options = 'scale=1920:-1,crop=1920:1080:0:102'
|
export_options = 'scale=1920:-1,crop=1920:1080:0:102'
|
||||||
|
cache_images = false
|
||||||
[CAMERA]
|
[CAMERA]
|
||||||
# Nikon D40x
|
# Nikon D40x
|
||||||
capturemode = 3 # use IR remote
|
capturemode = 3 # use IR remote
|
||||||
|
|
30
main_c.py
30
main_c.py
|
@ -90,6 +90,7 @@ project_settings_defaults = {
|
||||||
'vflip' : False,
|
'vflip' : False,
|
||||||
'hflip' : False,
|
'hflip' : False,
|
||||||
'export_options' : 'scale=1920:-1,crop=1920:1080:0:102',
|
'export_options' : 'scale=1920:-1,crop=1920:1080:0:102',
|
||||||
|
'cache_images' : False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Camera Settings (Nikon D40x)
|
# Camera Settings (Nikon D40x)
|
||||||
|
@ -128,6 +129,7 @@ class KISStopmo(tk.Tk):
|
||||||
self.fullscreen_bool = project_settings['fullscreen_bool']
|
self.fullscreen_bool = project_settings['fullscreen_bool']
|
||||||
self.screen_w, self.screen_h = project_settings['screen_w'], project_settings['screen_h']
|
self.screen_w, self.screen_h = project_settings['screen_w'], project_settings['screen_h']
|
||||||
self.framerate = project_settings['framerate']
|
self.framerate = project_settings['framerate']
|
||||||
|
self.playback = False
|
||||||
|
|
||||||
# ~ self.photo = None
|
# ~ self.photo = None
|
||||||
self.end_thread = False
|
self.end_thread = False
|
||||||
|
@ -195,20 +197,19 @@ class KISStopmo(tk.Tk):
|
||||||
|
|
||||||
self.splashscreen = self.generate_splashscreen()
|
self.splashscreen = self.generate_splashscreen()
|
||||||
|
|
||||||
image = self.update_image()
|
self.image = None
|
||||||
if image:
|
self.update_image()
|
||||||
|
if self.image:
|
||||||
if self.onion_skin:
|
if self.onion_skin:
|
||||||
if self.img_index:
|
if self.img_index:
|
||||||
photo = self.apply_onionskin(image, self.onionskin_alpha_default, self.onionskin_fx)
|
photo = self.apply_onionskin(self.image, self.onionskin_alpha_default, self.onionskin_fx)
|
||||||
else:
|
else:
|
||||||
photo = ImageTk.PhotoImage(image)
|
photo = ImageTk.PhotoImage(self.image)
|
||||||
|
|
||||||
self.label.configure(image=photo)
|
self.label.configure(image=photo)
|
||||||
self.label.image = photo
|
self.label.image = photo
|
||||||
|
|
||||||
if project_settings['trigger_mode'] == 'event':
|
if project_settings['trigger_mode'] == 'event':
|
||||||
root.after(1000, self.trigger_bg_loop)
|
root.after(1000, self.trigger_bg_loop)
|
||||||
# ~ root.after(1000, self.wait_for_capture)
|
|
||||||
|
|
||||||
# Key binding
|
# Key binding
|
||||||
root.bind("<Escape>", lambda event: root.attributes("-fullscreen", False))
|
root.bind("<Escape>", lambda event: root.attributes("-fullscreen", False))
|
||||||
|
@ -219,7 +220,7 @@ class KISStopmo(tk.Tk):
|
||||||
root.bind("<N>", self.preview_animation)
|
root.bind("<N>", self.preview_animation)
|
||||||
root.bind("<E>", self.trigger_export_animation)
|
root.bind("<E>", self.trigger_export_animation)
|
||||||
root.bind("<d>", self.remove_frame)
|
root.bind("<d>", self.remove_frame)
|
||||||
# ~ root.bind("<a>", self.print_imglist)
|
root.bind("<a>", self.print_imglist)
|
||||||
|
|
||||||
if project_settings['trigger_mode'] != 'event':
|
if project_settings['trigger_mode'] != 'event':
|
||||||
root.bind("<n>", self.capture_image)
|
root.bind("<n>", self.capture_image)
|
||||||
|
@ -432,10 +433,13 @@ class KISStopmo(tk.Tk):
|
||||||
image = image.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
|
image = image.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
|
||||||
if hflip:
|
if hflip:
|
||||||
image = image.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
|
image = image.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
|
||||||
|
if project_settings['cache_images']:
|
||||||
|
# TODO : Do not cache image to preserve memory
|
||||||
self.img_list[filetuple[0]] = image
|
self.img_list[filetuple[0]] = image
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
if project_settings['cache_images']:
|
||||||
image = filetuple[-1]
|
image = filetuple[-1]
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
@ -471,7 +475,7 @@ class KISStopmo(tk.Tk):
|
||||||
|
|
||||||
|
|
||||||
def update_image(self, event=None, index=None):
|
def update_image(self, event=None, index=None):
|
||||||
# TODO : check event mode stille works
|
# TODO : check event mode still works
|
||||||
if event is not None:
|
if event is not None:
|
||||||
self.img_index = self.check_range(self.img_index+1)
|
self.img_index = self.check_range(self.img_index+1)
|
||||||
if index is None:
|
if index is None:
|
||||||
|
@ -493,7 +497,10 @@ class KISStopmo(tk.Tk):
|
||||||
photo = self.apply_onionskin(new_image, project_settings['onionskin_alpha_default'], project_settings['onionskin_fx'])
|
photo = self.apply_onionskin(new_image, project_settings['onionskin_alpha_default'], project_settings['onionskin_fx'])
|
||||||
self.label.configure(image=photo)
|
self.label.configure(image=photo)
|
||||||
self.label.image = photo
|
self.label.image = photo
|
||||||
return new_image
|
# ~ return new_image
|
||||||
|
self.image = new_image
|
||||||
|
# ~ new_image.close()
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -514,11 +521,16 @@ class KISStopmo(tk.Tk):
|
||||||
self.onion_skin = False
|
self.onion_skin = False
|
||||||
onion_skin_was_on = True
|
onion_skin_was_on = True
|
||||||
# playback
|
# playback
|
||||||
|
# TODO : Use async function for playback
|
||||||
|
# ~ self.playback = not self.playback
|
||||||
for img in self.img_list:
|
for img in self.img_list:
|
||||||
# ~ self.update_image(None, self.img_list.index(img))
|
# ~ self.update_image(None, self.img_list.index(img))
|
||||||
|
# ~ if self.playback:
|
||||||
self.update_image(None, list(self.img_list.keys()).index(img))
|
self.update_image(None, list(self.img_list.keys()).index(img))
|
||||||
root.update_idletasks()
|
root.update_idletasks()
|
||||||
time.sleep(1/self.framerate)
|
time.sleep(1/self.framerate)
|
||||||
|
# ~ else:
|
||||||
|
# ~ break
|
||||||
# ~ self.update_image(None, self.img_index)
|
# ~ self.update_image(None, self.img_index)
|
||||||
self.display_last_frame()
|
self.display_last_frame()
|
||||||
# restore OS state
|
# restore OS state
|
||||||
|
|
Loading…
Reference in New Issue