diff --git a/perception/vis/algo_stats b/perception/vis/algo_stats index a8faa4c..18849e7 100644 Binary files a/perception/vis/algo_stats and b/perception/vis/algo_stats differ diff --git a/perception/vis/vis.py b/perception/vis/vis.py index 5461b9d..e5f35e7 100644 --- a/perception/vis/vis.py +++ b/perception/vis/vis.py @@ -52,7 +52,6 @@ def main(): sep='') img = img.reshape(dframe.canvas.get_width_height()[::-1] + (3,)) img = cv.cvtColor(img, cv.COLOR_RGB2BGR) - img = cv.resize(img, (frame.shape[1], frame.shape[0])) debug_frames[i] = img to_show = window_builder.display(debug_frames) diff --git a/perception/vis/window_builder.py b/perception/vis/window_builder.py index 3e054cb..664db0e 100644 --- a/perception/vis/window_builder.py +++ b/perception/vis/window_builder.py @@ -7,12 +7,12 @@ def nothing(x): pass class Visualizer: - def __init__(self, vars: Dict[str, Tuple[Tuple[int, int], int]]): - self.variables = vars.keys() + def __init__(self, kwargs: Dict[str, Tuple[Tuple[int, int], int]]): + self.variables = kwargs.keys() cv.namedWindow('Debug Frames') - for name, info in vars.items(): - range, default_val = info - low_range, high_range = range + for name, info in kwargs.items(): + slider_range, default_val = info + low_range, high_range = slider_range cv.createTrackbar(name, 'Debug Frames', low_range, high_range, nothing) cv.setTrackbarPos(name, 'Debug Frames', default_val) @@ -24,10 +24,23 @@ def three_stack(self, frames: List[np.ndarray]) -> List[np.ndarray]: newLst.append((frame)) return newLst + # set the first frame as the standard dimension, resize every frame after + def reshape(self, frames: List[np.ndarray]) -> List[np.ndarray]: + newLst = [] + img = frames[0] + height = img.shape[0] + width = img.shape[1] + dim = (width, height) + for frame in frames: + if frame.shape[0] != height or frame.shape[1] != width: + frame = cv.resize(frame, dim, interpolation=cv.INTER_AREA) + newLst.append(frame) + return newLst + def display(self, frames: List[np.ndarray]) -> np.ndarray: num_frames = len(frames) assert (num_frames > 0 and num_frames <= 9), 'Invalid number of frames!' - frames = self.three_stack(frames) + frames = self.reshape(self.three_stack(frames)) columns = math.ceil(num_frames/math.sqrt(num_frames)) rows = math.ceil(num_frames/columns) @@ -42,7 +55,7 @@ def display(self, frames: List[np.ndarray]) -> np.ndarray: this_row = np.hstack((this_row, to_add)) else: this_row = np.hstack((this_row, np.zeros(frames[0].shape, dtype=np.uint8))) - if type(to_show) != int: + if not isinstance(to_show, int): to_show = np.vstack((to_show, this_row)) else: to_show = this_row