@@ -478,7 +478,55 @@ def exit_action(self, info):
478
478
def saveas_action (self , info ):
479
479
print ("not implemented" )
480
480
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 ()
481
490
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 " )
482
530
483
531
def draw_mask_action (self , info ):
484
532
""" drawing masks GUI """
@@ -608,55 +656,7 @@ def corresp_action(self, info):
608
656
# info.object.drawcross("pair_x", "pair_y", x, y, "yellow", 3)
609
657
# info.object.drawcross("unused_x","unused_y",unused[:,0],unused[:,1],"blue",3)
610
658
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)
648
659
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 " )
660
660
661
661
def calib_action (self , info ):
662
662
"""calib_action - initializes calib class with appropriate number of
@@ -1466,6 +1466,8 @@ def overlay_set_images(self, seq_first: int, seq_last:int):
1466
1466
temp_img = []
1467
1467
for seq in range (seq_first , seq_last ):
1468
1468
_ = imread (self .base_name [cam_id ] % seq )
1469
+ if _ .ndim > 2 :
1470
+ _ = rgb2gray (_ )
1469
1471
temp_img .append (img_as_ubyte (_ ))
1470
1472
1471
1473
temp_img = np .array (temp_img )
@@ -1489,7 +1491,11 @@ def load_disp_image(self, img_name: str, j: int, display_only: bool = False):
1489
1491
"""
1490
1492
# print(f"Setting image: {img_name}")
1491
1493
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 )
1493
1499
except IOError :
1494
1500
print ("Error reading file, setting zero image" )
1495
1501
h_img = self .exp1 .active_params .m_params .imx
0 commit comments