added mesh surface arrows
This commit is contained in:
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import cv2
|
||||
|
||||
from pipeline.frame import FingerFrameView
|
||||
from viz.render_2d import render_uv_arrows
|
||||
from viz.render_2d import ArrowBackground, ArrowCanvasColors, render_uv_arrows
|
||||
|
||||
from ..layout import DashboardLayout, LAYOUT
|
||||
from .image_panel import ImagePanel
|
||||
@@ -19,6 +19,8 @@ class ArrowPanelWidget(ImagePanel):
|
||||
self,
|
||||
*,
|
||||
flow_threshold: float = 0.5,
|
||||
background: ArrowBackground = "unrolled",
|
||||
canvas_colors: ArrowCanvasColors | None = None,
|
||||
layout: DashboardLayout = LAYOUT,
|
||||
parent=None,
|
||||
):
|
||||
@@ -30,15 +32,18 @@ class ArrowPanelWidget(ImagePanel):
|
||||
parent=parent,
|
||||
)
|
||||
self.flow_threshold = flow_threshold
|
||||
self.background = background
|
||||
self.canvas_colors = canvas_colors if canvas_colors is not None else layout.arrow_canvas_colors
|
||||
|
||||
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,
|
||||
frame,
|
||||
flow_threshold=self.flow_threshold,
|
||||
background=self.background,
|
||||
canvas_colors=self.canvas_colors,
|
||||
)
|
||||
arrows = cv2.rotate(arrows, cv2.ROTATE_180)
|
||||
self.set_source_pixmap(ndarray_to_pixmap(arrows, bgr=True))
|
||||
|
||||
@@ -7,6 +7,7 @@ from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtWidgets import QSizePolicy
|
||||
|
||||
from gui.layout import DashboardLayout, LAYOUT
|
||||
from gui.styles import LOG_FONT_PRIMARY, UI_FONT_PRIMARY
|
||||
from pipeline.frame import FingerFrameView
|
||||
from viz.signal_filters import lowpass_filter
|
||||
|
||||
@@ -72,21 +73,21 @@ class ForceChartWidget:
|
||||
def _create_plots(self) -> None:
|
||||
pg = self._pg
|
||||
layout = self._layout
|
||||
titles = ["法向力", "切向力 X", "切向力 Y"]
|
||||
titles = ["Normal Deformation", "X Deformation", "Y Deformation"]
|
||||
self.plots = []
|
||||
self.curves = []
|
||||
self.dot_glows = []
|
||||
self.dot_cores = []
|
||||
|
||||
axis_pen = pg.mkPen(color=(38, 38, 38), width=1)
|
||||
label_font = QFont("SimHei", layout.chart_axis_label_font_pt)
|
||||
label_font = QFont(UI_FONT_PRIMARY, layout.chart_axis_label_font_pt)
|
||||
title_pt = layout.chart_title_font_pt
|
||||
|
||||
for i, title in enumerate(titles):
|
||||
plot = self.widget.addPlot(title=None)
|
||||
plot.setTitle(title, color="#999999", size=f"{title_pt}pt")
|
||||
plot.titleLabel.setFont(QFont("SimHei", title_pt))
|
||||
plot.setLabel("bottom", "时间", units="s")
|
||||
plot.titleLabel.setFont(QFont(UI_FONT_PRIMARY, title_pt))
|
||||
plot.setLabel("bottom", "Time", units="s")
|
||||
plot.getAxis("bottom").label.setFont(label_font)
|
||||
plot.showAxis("top", False)
|
||||
plot.showAxis("right", False)
|
||||
@@ -94,7 +95,7 @@ class ForceChartWidget:
|
||||
plot.getAxis("bottom").setPen(axis_pen)
|
||||
plot.showGrid(x=False, y=True, alpha=0.12)
|
||||
|
||||
tick_font = QFont("Consolas", layout.chart_tick_font_pt)
|
||||
tick_font = QFont(LOG_FONT_PRIMARY, layout.chart_tick_font_pt)
|
||||
tick_font.setStyleHint(QFont.Monospace)
|
||||
plot.getAxis("left").setTickFont(tick_font)
|
||||
plot.getAxis("bottom").setTickFont(tick_font)
|
||||
|
||||
@@ -65,7 +65,9 @@ class MeshViewportWidget(ImagePanel):
|
||||
world_to_cam=pipeline.world_to_cam,
|
||||
lookat=pipeline.mesh_lookat,
|
||||
mesh_lighting=self._layout.mesh_lighting,
|
||||
mesh_background=self._layout.mesh_background.color,
|
||||
contact_arrow_style=self._layout.mesh_contact_arrow,
|
||||
flow_arrow_style=self._layout.mesh_flow_arrow,
|
||||
)
|
||||
|
||||
def _stop_worker(self) -> None:
|
||||
@@ -93,6 +95,7 @@ class MeshViewportWidget(ImagePanel):
|
||||
centroid=frame.centroid,
|
||||
centroid_found=frame.centroid_found,
|
||||
fnormal=frame.fnormal,
|
||||
valid_mask=frame.valid_mask,
|
||||
)
|
||||
return 0.0
|
||||
|
||||
@@ -105,6 +108,7 @@ class MeshViewportWidget(ImagePanel):
|
||||
centroid=frame.centroid,
|
||||
centroid_found=frame.centroid_found,
|
||||
fnormal=frame.fnormal,
|
||||
valid_mask=frame.valid_mask,
|
||||
)
|
||||
self.set_source_pixmap(ndarray_to_pixmap(rgb, bgr=False))
|
||||
return (time.perf_counter() - t0) * 1000.0
|
||||
|
||||
Reference in New Issue
Block a user