update blender marker design
This commit is contained in:
+14
-26
@@ -35,6 +35,8 @@ PLOT_WINDOW_SEC = PLOT_BUFFER_POINTS / FORCE_SAMPLE_RATE_HZ # 4 s window
|
||||
# Minimum y-axis span so autoscale does not over-zoom on small fluctuations.
|
||||
Y_AXIS_MIN_SPAN = 20000
|
||||
CURVE_THEME_COLOR = '#00E5FF'
|
||||
NORMAL_FORCE_CAL_SLOPE = 3.92685554668795e-05
|
||||
NORMAL_FORCE_CAL_OFFSET = 0.0217596967278535
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QMainWindow, QWidget, QHBoxLayout, QVBoxLayout,
|
||||
@@ -125,6 +127,11 @@ def lowpass_filter(data, cutoff_hz, sample_rate_hz=FORCE_SAMPLE_RATE_HZ, order=2
|
||||
return filtfilt(b, a, y)
|
||||
|
||||
|
||||
def calibrate_normal_force(raw_value):
|
||||
"""Convert raw normal-force reading to Newtons using y = mx + c."""
|
||||
return NORMAL_FORCE_CAL_SLOPE * raw_value + NORMAL_FORCE_CAL_OFFSET
|
||||
|
||||
|
||||
class TeeStream:
|
||||
"""同时写入多个流"""
|
||||
def __init__(self, *streams):
|
||||
@@ -167,7 +174,7 @@ QMainWindow {
|
||||
}
|
||||
|
||||
/* ---- 图像面板 ---- */
|
||||
QLabel#arrowsLabel, QLabel#magLabel {
|
||||
QLabel#arrowsLabel {
|
||||
border: 1px solid #262626;
|
||||
border-radius: 4px;
|
||||
background-color: #0b0b0b;
|
||||
@@ -401,13 +408,6 @@ class MainWindow(QMainWindow):
|
||||
self.arrows_label.setAlignment(Qt.AlignCenter)
|
||||
left_layout.addWidget(self.arrows_label)
|
||||
|
||||
self.mag_label = QLabel()
|
||||
self.mag_label.setObjectName("magLabel")
|
||||
self.mag_label.setMinimumSize(160, 160)
|
||||
self.mag_label.setScaledContents(True)
|
||||
self.mag_label.setAlignment(Qt.AlignCenter)
|
||||
left_layout.addWidget(self.mag_label)
|
||||
|
||||
h_splitter.addWidget(left)
|
||||
|
||||
# 右侧力曲线
|
||||
@@ -437,7 +437,7 @@ class MainWindow(QMainWindow):
|
||||
root_layout.addWidget(v_splitter)
|
||||
|
||||
def _create_plots(self):
|
||||
titles = ["法向力", "切向力 X", "切向力 Y"]
|
||||
titles = ["法向力 (N)", "切向力 X", "切向力 Y"]
|
||||
self.plots = []
|
||||
self.curves = []
|
||||
self.dot_glows = []
|
||||
@@ -496,13 +496,13 @@ class MainWindow(QMainWindow):
|
||||
self.graph_widget.nextRow()
|
||||
|
||||
def adjust_square_images(self):
|
||||
"""根据窗口高度调整左侧面板宽度,使两张图保持正方形"""
|
||||
"""根据窗口高度调整左侧面板宽度,使左侧图像保持正方形"""
|
||||
top_bar_h = 48
|
||||
log_h = self.log_widget.height()
|
||||
spacing = 20
|
||||
available = self.height() - top_bar_h - log_h - spacing
|
||||
each_h = max(available // 2, 160)
|
||||
self.h_splitter.setSizes([each_h, self.width() - each_h])
|
||||
image_w = max(available, 160)
|
||||
self.h_splitter.setSizes([image_w, self.width() - image_w])
|
||||
|
||||
# ---- 帧处理 ----
|
||||
|
||||
@@ -534,13 +534,14 @@ class MainWindow(QMainWindow):
|
||||
is_touched = sensor.compute_deformation(check_motion=True, threshold=1)
|
||||
sensor.compute_contact()
|
||||
|
||||
fps, fn, fx, fy, flow, vnormal, vshear, depth_map = sensor.read_info(
|
||||
fps, fn_raw, fx, fy, flow, vnormal, vshear, _ = sensor.read_info(
|
||||
sensor.info.FPS, sensor.info.FNORMAL,
|
||||
sensor.info.FSHEARX, sensor.info.FSHEARY,
|
||||
sensor.info.VRAW, sensor.info.VNORMAL,
|
||||
sensor.info.VSHEAR,
|
||||
sensor.info.DEPTH
|
||||
)
|
||||
fn = calibrate_normal_force(fn_raw)
|
||||
|
||||
|
||||
print(f"FPS={fps:.2f}, 法向力={fn:.4f}, 切向力X={fx:.4f}, 切向力Y={fy:.4f}")
|
||||
@@ -564,19 +565,6 @@ class MainWindow(QMainWindow):
|
||||
arrows = cv2.resize(arrows, (400, 400), interpolation=cv2.INTER_CUBIC)
|
||||
self.arrows_label.setPixmap(cv2_to_pixmap(arrows))
|
||||
|
||||
# 显示深度图
|
||||
div_abs = depth_map
|
||||
if div_abs.max() > div_abs.min():
|
||||
div_normalized = ((div_abs - div_abs.min()) / (div_abs.max() - div_abs.min()) * 255).astype(np.uint8)
|
||||
else:
|
||||
div_normalized = np.zeros_like(div_abs, dtype=np.uint8)
|
||||
|
||||
# 应用颜色映射(使用JET:蓝色=低散度,红色=高散度)
|
||||
depth_colored = cv2.applyColorMap(div_normalized, cv2.COLORMAP_JET)
|
||||
|
||||
# mag = draw_magnitude_map(flow)
|
||||
self.mag_label.setPixmap(cv2_to_pixmap(depth_colored))
|
||||
|
||||
# 曲线:先顺序写入 npoints 个真实样本,满后再左移滚动
|
||||
current_time = time.time() - self.start_time
|
||||
if self._plot_sample_count < self.npoints:
|
||||
|
||||
Reference in New Issue
Block a user