From b3d7998c159c779ff3ca2876c7653f7f58f80c13 Mon Sep 17 00:00:00 2001 From: Chengzhi Gao Date: Tue, 25 Apr 2023 14:43:49 +0800 Subject: [PATCH] Fix deprecated module and attribute errors in visualization and plot utils Replace the deprecated scipy.ndimage.imread module with matplotlib.pyplot.imread in ```visualization/visualize_frame.py` to fix the AttributeError Also, update the utils/plot_utils.py file by replacing the attribute error caused by the DiscreteSlider object with self._observers.process('changed', discrete_val). These changes have been tested on macOS 12.6 with matplotlib version 3.6.2. --- Python/src/main.py | 2 +- Python/src/utils/plot_utils.py | 3 +-- Python/src/visualization/visualize_frame.py | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/src/main.py b/Python/src/main.py index 9fa48ce..f7eabde 100644 --- a/Python/src/main.py +++ b/Python/src/main.py @@ -92,4 +92,4 @@ def create_args(): print("Please specify the path to the video meta csv file.") sys.exit(1) visualization_plot = VisualizationPlot(created_arguments, tracks, static_info, meta_dictionary) - visualization_plot.show() \ No newline at end of file + visualization_plot.show() diff --git a/Python/src/utils/plot_utils.py b/Python/src/utils/plot_utils.py index a61f564..72f87f7 100644 --- a/Python/src/utils/plot_utils.py +++ b/Python/src/utils/plot_utils.py @@ -20,8 +20,7 @@ def set_val(self, val): self.val = val if not self.eventson: return - for cid, func in self.observers.items(): - func(discrete_val) + self._observers.process('changed',discrete_val) def update_val_external(self, val): self.set_val(val) diff --git a/Python/src/visualization/visualize_frame.py b/Python/src/visualization/visualize_frame.py index 3687683..7e83f67 100644 --- a/Python/src/visualization/visualize_frame.py +++ b/Python/src/visualization/visualize_frame.py @@ -1,6 +1,7 @@ import os import scipy.ndimage import matplotlib as mpl +from matplotlib.pyplot import imread from data_management.read_csv import * @@ -36,7 +37,7 @@ def __init__(self, arguments, read_tracks, static_info, meta_dictionary, fig=Non background_image_path = arguments["background_image"] if background_image_path is not None and os.path.exists(background_image_path): # Plot the image - self.background_image = scipy.ndimage.imread(background_image_path) + self.background_image = imread(background_image_path) self.y_sign = 1 im = self.background_image[:, :, :] self.ax.imshow(im)