Skip to content

Commit 519598a

Browse files
committed
updated pyptv_gui to work with mask_centers.tiffs
1 parent d995a5e commit 519598a

File tree

1 file changed

+55
-49
lines changed

1 file changed

+55
-49
lines changed

pyptv/pyptv_gui.py

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,55 @@ def exit_action(self, info):
478478
def saveas_action(self, info):
479479
print("not implemented")
480480

481+
def init_action(self, info):
482+
"""init_action - clears existing plots from the camera windows,
483+
initializes C image arrays with mainGui.orig_image and
484+
calls appropriate start_proc_c
485+
by using ptv.py_start_proc_c()
486+
"""
487+
mainGui = info.object
488+
# synchronize the active run params dir with the temp params dir
489+
mainGui.exp1.syncActiveDir()
481490

491+
for i in range(len(mainGui.camera_list)):
492+
try:
493+
im = imread(
494+
getattr(
495+
mainGui.exp1.active_params.m_params,
496+
f"Name_{i+1}_Image",
497+
)
498+
)
499+
if im.ndim > 2:
500+
im = rgb2gray(im)
501+
502+
mainGui.orig_image[i] = img_as_ubyte(im)
503+
except IOError:
504+
print("Error reading image, setting zero image")
505+
h_img = mainGui.exp1.active_params.m_params.imx
506+
v_img = mainGui.exp1.active_params.m_params.imy
507+
temp_img = img_as_ubyte(np.zeros((v_img, h_img)))
508+
# print(f"setting images of size {temp_img.shape}")
509+
exec(f"mainGui.orig_image[{i}] = temp_img")
510+
511+
if hasattr(mainGui.camera_list[i], "img_plot"):
512+
del mainGui.camera_list[i].img_plot
513+
mainGui.clear_plots()
514+
print("\n Init action \n")
515+
# mainGui.update_plots(mainGui.orig_image, is_float=False)
516+
mainGui.create_plots(mainGui.orig_image, is_float=False)
517+
# mainGui.set_images(mainGui.orig_image)
518+
519+
(
520+
info.object.cpar,
521+
info.object.spar,
522+
info.object.vpar,
523+
info.object.track_par,
524+
info.object.tpar,
525+
info.object.cals,
526+
info.object.epar,
527+
) = ptv.py_start_proc_c(info.object.n_cams)
528+
mainGui.pass_init = True
529+
print("Read all the parameters and calibrations successfully ")
482530

483531
def draw_mask_action(self, info):
484532
""" drawing masks GUI """
@@ -608,55 +656,7 @@ def corresp_action(self, info):
608656
# info.object.drawcross("pair_x", "pair_y", x, y, "yellow", 3)
609657
# info.object.drawcross("unused_x","unused_y",unused[:,0],unused[:,1],"blue",3)
610658

611-
def init_action(self, info):
612-
"""init_action - clears existing plots from the camera windows,
613-
initializes C image arrays with mainGui.orig_image and
614-
calls appropriate start_proc_c
615-
by using ptv.py_start_proc_c()
616-
"""
617-
mainGui = info.object
618-
# synchronize the active run params dir with the temp params dir
619-
mainGui.exp1.syncActiveDir()
620-
621-
for i in range(len(mainGui.camera_list)):
622-
try:
623-
im = imread(
624-
getattr(
625-
mainGui.exp1.active_params.m_params,
626-
f"Name_{i+1}_Image",
627-
)
628-
)
629-
if im.ndim > 2:
630-
im = rgb2gray(im)
631-
632-
mainGui.orig_image[i] = img_as_ubyte(im)
633-
except IOError:
634-
print("Error reading image, setting zero image")
635-
h_img = mainGui.exp1.active_params.m_params.imx
636-
v_img = mainGui.exp1.active_params.m_params.imy
637-
temp_img = img_as_ubyte(np.zeros((v_img, h_img)))
638-
# print(f"setting images of size {temp_img.shape}")
639-
exec(f"mainGui.orig_image[{i}] = temp_img")
640-
641-
if hasattr(mainGui.camera_list[i], "img_plot"):
642-
del mainGui.camera_list[i].img_plot
643-
mainGui.clear_plots()
644-
print("\n Init action \n")
645-
# mainGui.update_plots(mainGui.orig_image, is_float=False)
646-
mainGui.create_plots(mainGui.orig_image, is_float=False)
647-
# mainGui.set_images(mainGui.orig_image)
648659

649-
(
650-
info.object.cpar,
651-
info.object.spar,
652-
info.object.vpar,
653-
info.object.track_par,
654-
info.object.tpar,
655-
info.object.cals,
656-
info.object.epar,
657-
) = ptv.py_start_proc_c(info.object.n_cams)
658-
mainGui.pass_init = True
659-
print("Read all the parameters and calibrations successfully ")
660660

661661
def calib_action(self, info):
662662
"""calib_action - initializes calib class with appropriate number of
@@ -1466,6 +1466,8 @@ def overlay_set_images(self, seq_first: int, seq_last:int):
14661466
temp_img = []
14671467
for seq in range(seq_first, seq_last):
14681468
_ = imread(self.base_name[cam_id] % seq)
1469+
if _.ndim > 2:
1470+
_ = rgb2gray(_)
14691471
temp_img.append(img_as_ubyte(_))
14701472

14711473
temp_img = np.array(temp_img)
@@ -1489,7 +1491,11 @@ def load_disp_image(self, img_name: str, j: int, display_only: bool = False):
14891491
"""
14901492
# print(f"Setting image: {img_name}")
14911493
try:
1492-
temp_img = img_as_ubyte(imread(img_name))
1494+
temp_img = imread(img_name)
1495+
if temp_img.ndim > 2:
1496+
temp_img = rgb2gray(temp_img)
1497+
1498+
temp_img = img_as_ubyte(temp_img)
14931499
except IOError:
14941500
print("Error reading file, setting zero image")
14951501
h_img = self.exp1.active_params.m_params.imx

0 commit comments

Comments
 (0)