Fix liveview/onionskin conflict, wrong frame being saved

This commit is contained in:
ABelliqueux 2025-03-21 06:53:09 +01:00
parent ae7e582d58
commit 04dcaadfba
1 changed files with 17 additions and 10 deletions

View File

@ -134,13 +134,13 @@ class webcam():
return False
# Resize preview to fit screen
overlay = cv2.resize(overlay, (project_settings['screen_w'], project_settings['screen_h']))
# Keep original pic in memory
self.og_frame = overlay.copy()
if self.liveview_only:
# Don't mix it
self.frame = overlay
return True
if self.onionskin:
# Keep original pic in memory
self.og_frame = overlay.copy()
# calculate and apply alpha
alpha = project_settings['onionskin_alpha_default']
beta = (1.0 - alpha)
@ -331,13 +331,13 @@ class picam():
overlay = self.cam.capture_array("main")
# Resize preview to fit screen
overlay = cv2.resize(overlay, (project_settings['screen_w'], project_settings['screen_h']))
# Keep original pic in memory
self.og_frame = overlay.copy()
if self.liveview_only:
# Don't mix it
self.frame = overlay
return True
if self.onionskin:
# Keep original pic in memory
self.og_frame = overlay.copy()
# calculate and apply alpha
alpha = project_settings['onionskin_alpha_default']
beta = (1.0 - alpha)
@ -922,7 +922,7 @@ def offset_dictvalues(from_index=0):
img_list[list(img_list.keys())[i]] = None
def remove_frame(img_list, img_index):
def remove_frame(img_list:list, img_index:int):
if len(img_list):
folder_path = os.path.realpath(savepath)
frame_name = img_list[img_index]
@ -933,7 +933,7 @@ def remove_frame(img_list, img_index):
print(_("Removing {}").format(frame_path))
# trash file
send2trash(frame_path)
# remove entry from dict
# remove entry from list
img_list.remove(frame_name)
# rename files and get new list
img_list = batch_rename(folder_path)
@ -1054,13 +1054,19 @@ def main(args):
print(_("Liveview only"))
# Toggle liveview
cam.liveview_only = not cam.liveview_only
cam.onionskin = not cam.onionskin
# set onionskin back on when liveview_only false
if cam.liveview_only == False:
cam.onionskin = True
else:
cam.onionskin = False
# Key o / kp slash
elif (k%256 == 111) or (k%256 == 47) or (k%256 == 175):
print(_("Onionskin toggle"))
# Toggle onionskin
cam.onionskin = not cam.onionskin
cam.liveview_only = False
# liveview_only is always off when onionskin is true
if cam.onionskin:
cam.liveview_only = False
# Key w / 7 - cycle wb
elif (k%256 == 119) or (k%256 == 55) or (k%256 == 183):
print(_("White balance mode"))
@ -1158,7 +1164,8 @@ def main(args):
if len(img_list) and (img_list[index] == '{letter}.-001.{ext}'.format(letter=project_letter, ext=project_settings['file_extension'])):
img_list[index] = img_name
else:
index += 1
# Move to last frame
index = len(img_list)
cam.frame = get_onionskin_frame(savepath)
cam.o_frame = cam.frame.copy()
else:
@ -1223,7 +1230,7 @@ next_letter = 'Z'
img_list = []
savepath = get_session_folder()
onionskin = project_settings['onion_skin_onstartup']
liveview_only = False
# ~ liveview_only = False
blank_image = generate_text_image(_("No images yet! Start shooting..."), project_settings['screen_w'], project_settings['screen_h'])
if len(savepath):