refactor(demo): simplify visualizer wiring and typing
Apply Oracle-guided cleanup to make the demo pipeline contract explicit and remove defensive runtime indirection while preserving existing visualization behavior.
This commit is contained in:
+21
-11
@@ -315,20 +315,30 @@ class OpenCVVisualizer:
|
||||
Returns:
|
||||
Displayable side-by-side image
|
||||
"""
|
||||
# Prepare individual views
|
||||
raw_view = self._prepare_raw_view(mask_raw)
|
||||
norm_view = self._prepare_normalized_view(silhouette)
|
||||
|
||||
# Convert to grayscale for side-by-side composition
|
||||
if len(raw_view.shape) == 3:
|
||||
raw_gray = cast(ImageArray, cv2.cvtColor(raw_view, cv2.COLOR_BGR2GRAY))
|
||||
# Prepare individual views without mode indicators (will be drawn on combined)
|
||||
# Raw view preparation (without indicator)
|
||||
if mask_raw is None:
|
||||
raw_gray = np.zeros((DISPLAY_HEIGHT, DISPLAY_WIDTH), dtype=np.uint8)
|
||||
else:
|
||||
raw_gray = raw_view
|
||||
if len(mask_raw.shape) == 3:
|
||||
mask_gray = cast(ImageArray, cv2.cvtColor(mask_raw, cv2.COLOR_BGR2GRAY))
|
||||
else:
|
||||
mask_gray = mask_raw
|
||||
raw_gray = cast(
|
||||
ImageArray,
|
||||
cv2.resize(
|
||||
mask_gray,
|
||||
(DISPLAY_WIDTH, DISPLAY_HEIGHT),
|
||||
interpolation=cv2.INTER_NEAREST,
|
||||
),
|
||||
)
|
||||
|
||||
if len(norm_view.shape) == 3:
|
||||
norm_gray = cast(ImageArray, cv2.cvtColor(norm_view, cv2.COLOR_BGR2GRAY))
|
||||
# Normalized view preparation (without indicator)
|
||||
if silhouette is None:
|
||||
norm_gray = np.zeros((DISPLAY_HEIGHT, DISPLAY_WIDTH), dtype=np.uint8)
|
||||
else:
|
||||
norm_gray = norm_view
|
||||
upscaled = self._upscale_silhouette(silhouette)
|
||||
norm_gray = upscaled
|
||||
|
||||
# Stack horizontally
|
||||
combined = np.hstack([raw_gray, norm_gray])
|
||||
|
||||
Reference in New Issue
Block a user