"""UV flow-arrow panel for the Qt dashboard.""" from __future__ import annotations import cv2 from pipeline.frame import FingerFrameView from viz.render_2d import render_uv_arrows from ..layout import DashboardLayout, LAYOUT from .image_panel import ImagePanel from .qt_pixmap import ndarray_to_pixmap class ArrowPanelWidget(ImagePanel): """UV unrolled flow-arrow panel.""" def __init__( self, *, flow_threshold: float = 0.5, layout: DashboardLayout = LAYOUT, parent=None, ): slot = layout.top_slot("arrows") super().__init__( title=layout.arrows_panel_title, object_name="panelLabel", default_side=min(slot.width_px, slot.height_px), parent=parent, ) self.flow_threshold = flow_threshold def set_flow_threshold(self, threshold: float) -> None: self.flow_threshold = threshold def update_frame(self, frame: FingerFrameView) -> None: arrows = render_uv_arrows( frame.unrolled, frame.vnormal, flow_threshold=self.flow_threshold, ) arrows = cv2.rotate(arrows, cv2.ROTATE_180) self.set_source_pixmap(ndarray_to_pixmap(arrows, bgr=True))