Fix flip_image() method
This commit is contained in:
parent
b21a8d669c
commit
e12fe81ed3
|
@ -53,6 +53,7 @@ project_settings_defaults = {
|
||||||
'export_options' : 'scale=1920:-1,crop=1920:1080:0:102',
|
'export_options' : 'scale=1920:-1,crop=1920:1080:0:102',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: replace hflip+vflip with flip option
|
||||||
camera_current_settings_defaults = {
|
camera_current_settings_defaults = {
|
||||||
'cam_w' : 800,
|
'cam_w' : 800,
|
||||||
'cam_h' : 600,
|
'cam_h' : 600,
|
||||||
|
@ -104,6 +105,7 @@ class webcam():
|
||||||
self.overlay = None
|
self.overlay = None
|
||||||
# Original frame for saving
|
# Original frame for saving
|
||||||
self.og_frame = None
|
self.og_frame = None
|
||||||
|
self.flip_img = bool(camera_settings['vflip'] or camera_settings['hflip'] )
|
||||||
self.onionskin = project_settings['onion_skin_onstartup']
|
self.onionskin = project_settings['onion_skin_onstartup']
|
||||||
self.onionskin_was_on = self.onionskin
|
self.onionskin_was_on = self.onionskin
|
||||||
self.liveview_only = False
|
self.liveview_only = False
|
||||||
|
@ -132,6 +134,8 @@ class webcam():
|
||||||
if not ret:
|
if not ret:
|
||||||
print(_("Failed to grab frame."))
|
print(_("Failed to grab frame."))
|
||||||
return False
|
return False
|
||||||
|
if self.flip_img:
|
||||||
|
overlay = cv2.flip(overlay, -1)
|
||||||
# Keep original pic in memory
|
# Keep original pic in memory
|
||||||
self.og_frame = overlay.copy()
|
self.og_frame = overlay.copy()
|
||||||
# Resize preview to fit screen
|
# Resize preview to fit screen
|
||||||
|
@ -212,9 +216,7 @@ class webcam():
|
||||||
return self.camera_current_settings
|
return self.camera_current_settings
|
||||||
|
|
||||||
def flip_image(self):
|
def flip_image(self):
|
||||||
self.frame = cv2.flip(self.frame, -1)
|
self.flip_img = not self.flip_img
|
||||||
# Also flip original file
|
|
||||||
self.og_frame = cv2.flip(self.og_frame, -1)
|
|
||||||
|
|
||||||
def focus(self, direction:str='-'):
|
def focus(self, direction:str='-'):
|
||||||
self.apply_setting(['lenspos'], 1)
|
self.apply_setting(['lenspos'], 1)
|
||||||
|
@ -449,7 +451,7 @@ class dslr():
|
||||||
self.onionskin_was_on = self.onionskin
|
self.onionskin_was_on = self.onionskin
|
||||||
self.liveview_only = False
|
self.liveview_only = False
|
||||||
self.lenspos = None
|
self.lenspos = None
|
||||||
self.flip_img = False
|
self.flip_img = bool(camera_settings['vflip'] or camera_settings['hflip'] )
|
||||||
self.cam_busy = False
|
self.cam_busy = False
|
||||||
self.camera_current_config = None
|
self.camera_current_config = None
|
||||||
self.cam = self.init_camera()
|
self.cam = self.init_camera()
|
||||||
|
@ -474,7 +476,6 @@ class dslr():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def find_file_ext(self, gp_name:str, full_path:str):
|
def find_file_ext(self, gp_name:str, full_path:str):
|
||||||
# TODO: use re to sub png with jpg ?
|
|
||||||
# extract dir path
|
# extract dir path
|
||||||
dirname = os.path.dirname(full_path)
|
dirname = os.path.dirname(full_path)
|
||||||
# extract filename from path
|
# extract filename from path
|
||||||
|
@ -500,7 +501,6 @@ class dslr():
|
||||||
if self.cam is None:
|
if self.cam is None:
|
||||||
self.cam = self.init_camera()
|
self.cam = self.init_camera()
|
||||||
if not self.cam_busy:
|
if not self.cam_busy:
|
||||||
# CHECK: Should we init and close dslr for each frame ?
|
|
||||||
# Check battery level
|
# Check battery level
|
||||||
battery_level = int(self.check_status_value(self.camera_current_config, 'batterylevel')[:-1])
|
battery_level = int(self.check_status_value(self.camera_current_config, 'batterylevel')[:-1])
|
||||||
if battery_level < 10:
|
if battery_level < 10:
|
||||||
|
@ -533,6 +533,7 @@ class dslr():
|
||||||
return False
|
return False
|
||||||
# Flip image if needed
|
# Flip image if needed
|
||||||
if self.flip_img:
|
if self.flip_img:
|
||||||
|
# Re-open filen flip and save
|
||||||
frm = cv2.imread(img_path)
|
frm = cv2.imread(img_path)
|
||||||
frm = cv2.flip(frm, -1)
|
frm = cv2.flip(frm, -1)
|
||||||
cv2.imwrite(img_path, frm)
|
cv2.imwrite(img_path, frm)
|
||||||
|
@ -603,7 +604,7 @@ class dslr():
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def flip_image(self):
|
def flip_image(self):
|
||||||
self.flip_img = True
|
self.flip_img = not self.flip_img
|
||||||
|
|
||||||
def focus(self, direction:str='-'):
|
def focus(self, direction:str='-'):
|
||||||
if direction == '-':
|
if direction == '-':
|
||||||
|
@ -617,7 +618,6 @@ class dslr():
|
||||||
self.camera_current_config = self.gp.check_result(self.gp.gp_camera_get_config(self.cam))
|
self.camera_current_config = self.gp.check_result(self.gp.gp_camera_get_config(self.cam))
|
||||||
for setting in self.camera_current_settings:
|
for setting in self.camera_current_settings:
|
||||||
self.camera_current_settings[setting]['value'] = self.camera_current_settings[setting]['default']
|
self.camera_current_settings[setting]['value'] = self.camera_current_settings[setting]['default']
|
||||||
# TODO: use self.apply_setting() instead
|
|
||||||
self.apply_gphoto_setting(setting)
|
self.apply_gphoto_setting(setting)
|
||||||
status = self.gp.check_result(self.gp.gp_camera_set_config(self.cam, self.camera_current_config))
|
status = self.gp.check_result(self.gp.gp_camera_set_config(self.cam, self.camera_current_config))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue