Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified perception/vis/algo_stats
Binary file not shown.
1 change: 0 additions & 1 deletion perception/vis/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 20 additions & 7 deletions perception/vis/window_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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
Expand Down