From 04561d2697ab703de9ee1575fd8091cfafbccd54 Mon Sep 17 00:00:00 2001 From: PowLu <1144983626@qq.com> Date: Tue, 7 Apr 2026 14:11:33 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=80=92=E8=BD=A6=E8=BE=85=E5=8A=A9?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __pycache__/config.cpython-38.pyc | Bin 0 -> 1164 bytes bash/close_shell.sh | 2 +- lj360_camera_keepalive.log | 0 surround_config.json | 4 +- web.py | 87 ++++++++++++++++++++++++------ 5 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 __pycache__/config.cpython-38.pyc delete mode 100644 lj360_camera_keepalive.log diff --git a/__pycache__/config.cpython-38.pyc b/__pycache__/config.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2765863a7a89c3449aa3fd04816959f103bfc4ea GIT binary patch literal 1164 zcmY+DO>f*p7{})sdu^|G8zmuvR_Y;0T=qgLPGA#3`{UE^zIyoc_~hOX{seWh zF<6p?5P6ZYFwV11viEXV=Gnx?zR4>l0EU*M7vcyjBzyZR<5C8` zh*%`TB1=@@%l-T?tb|~Gsz+%gdLc`s3Yr-EX>=#-<&4L;_|szctYf`~Rc06z=|V}B zH3rccw3V$a21oSU`4LgI(ixI5jNpB8ncN^-6Ialyh&`L{9C?YK+N+Y$tcciDE9~u6)hHV)01z?N5{ugUJt+j`oW*SYY?rbrn%I1 zKT`YJ;kWT3Qa7$`ZmhrkX87Lf_FLM{`#jUOfv4>>kC>ioudT1{T;C3-!*nfCyeG9U zxnjH%6{*towc9c8tHjJx)Sh9t(G74JSa23HkPXgy?n zegukktsxnrA(_SOyEc$BtkHyJO~DwB!06c}BXUwzf96c2U}BxuSs+gt@I~VnEzQudi!;fo|4LCl|d)i3RLwS;7z$ z&zVucEB@1P-Y5+j9q<|Mmr#&qH9`&Si?E2e#f$ijc5%ay<#8Aa^NUw|3J+W8kUYt> zv&U6@$fgIHLp|``-E6OgnA@OUwQlUJwyTs?3!XWKF@&hj;=P8yP?7T2O;Y7W47TNg SM;9%M*`Ga+ow^OE&;1XC5i&La literal 0 HcmV?d00001 diff --git a/bash/close_shell.sh b/bash/close_shell.sh index b5a5e1f..1e8dbd3 100644 --- a/bash/close_shell.sh +++ b/bash/close_shell.sh @@ -10,5 +10,5 @@ do echo kill${pid} kill -9 $pid echo kill${pid}success - sleep 1 + sleep 0.1 done diff --git a/lj360_camera_keepalive.log b/lj360_camera_keepalive.log deleted file mode 100644 index e69de29..0000000 diff --git a/surround_config.json b/surround_config.json index a970768..dab4e15 100644 --- a/surround_config.json +++ b/surround_config.json @@ -1,8 +1,8 @@ { "carousel_interval": 4, "brightness": 50, - "radar_unit": 1, + "radar_unit": 0, "show_radar": 1, - "radar_alarm_dist": 5, + "radar_alarm_dist": 15, "display_mode": 0 } \ No newline at end of file diff --git a/web.py b/web.py index aaf388b..4a0ce73 100644 --- a/web.py +++ b/web.py @@ -228,7 +228,7 @@ class SerialWorker(threading.Thread): def _parse_rx_frame(self, frame): - # print("[串口1 RX] " + " ".join("{:02X}".format(b) for b in frame)) + if len(frame) != 10 or frame[0] != 0x55 or frame[9] != 0xAA: return front = frame[1]; left = frame[2] @@ -266,7 +266,6 @@ class SerialWorker(threading.Thread): while self.running: try: frame = self._build_tx_frame() - print("[串口1 TX] " + " ".join("{:02X}".format(b) for b in frame)) ser.write(frame) except Exception as e: if self.running: @@ -331,7 +330,6 @@ class RemoteWorker(threading.Thread): if frame[:7] != REMOTE_HEADER: return code = frame[7] - print("[遥控] 0x{:02X}".format(code)) self.signals.key_pressed.emit(code) if code == KEY_OK: self.signals.enter_settings.emit() @@ -822,6 +820,71 @@ class RenderWorker(threading.Thread): else: back_part = np.zeros((sh, fw, 3), dtype=np.uint8) + # -------------------------- + # 新增:绘制红/黄/绿倒车辅助线 + # -------------------------- + if back_frame is not None: + h, w = back_part.shape[:2] + h=h//2 # 只在下半部分绘制辅助线 + + # ========================================== + # 倒车线参数 - 梯形向远方伸长版本 + # ========================================== + + # 底部(车尾)两个端点 - 宽 + bottom_left = (int(w * 0.10), h+h) # 左侧起始10% + bottom_right = (int(w * 0.90), h+h) # 右侧结束90% + + # 顶部(远方)- 更窄,形成更强的透视感 + # 绿色(最远,安全区)- 伸长到更高更窄的位置 + green_top_left = (int(w * 0.35), int(h * 0.12+h)) # 更窄更远 + green_top_right = (int(w * 0.65), int(h * 0.12+h)) + + # 黄色(中间,警示区) + yellow_top_left = (int(w * 0.28), int(h * 0.35+h)) # 稍宽 + yellow_top_right = (int(w * 0.72), int(h * 0.35+h)) + + # 红色(最近,危险区) + red_top_left = (int(w * 0.21), int(h * 0.60+h)) # 更宽 + red_top_right = (int(w * 0.79), int(h * 0.60+h)) + + # 颜色定义(BGR格式) + color_green = (0, 0, 255) # 绿色 + color_red = (0, 255, 255) # 黄色 + color_yellow = (0, 255, 0) # 红色 + + + # 绘制梯形(填充半透明) + overlay = back_part.copy() + alpha = 0.2 # 透明度 + + + # 绘制绿色区域(最远,安全区) + green_pts = np.array([bottom_left, green_top_left, green_top_right, bottom_right], np.int32) + cv2.fillPoly(overlay, [green_pts], color_green) + + # 绘制黄色区域(中间,警示区) + yellow_pts = np.array([green_top_left, yellow_top_left, yellow_top_right, green_top_right], np.int32) + cv2.fillPoly(overlay, [yellow_pts], color_yellow) + + # 绘制红色区域(最近,危险区) + red_pts = np.array([yellow_top_left, red_top_left, red_top_right, yellow_top_right], np.int32) + cv2.fillPoly(overlay, [red_pts], color_red) + + + + # 绘制左右车道线(加强透视感) + # 左线 + cv2.line(overlay, bottom_left, green_top_left, (255, 255, 255), 2) + # 右线 + cv2.line(overlay, bottom_right, green_top_right, (255, 255, 255), 2) + + + # 混合半透明效果 + back_part = cv2.addWeighted(overlay, alpha, back_part, 1 - alpha, 0) + # -------------------------- + # 原有亮度调节逻辑(保留) + # -------------------------- if brightness != 50: alpha_v = brightness / 50.0 back_part = cv2.convertScaleAbs(back_part, alpha=alpha_v, beta=0) @@ -842,19 +905,18 @@ class RenderWorker(threading.Thread): else radar_dist) alarm_d = cfg.get("radar_alarm_dist", 50) rc = ((255, 80, 80) if dist_val <= alarm_d else (180, 220, 255)) - texts.append((bw + 10, sh - 80, + texts.append((bw + 10, 48, f"雷达: {dist_val} {unit_str} 报警值: {alarm_d}{unit_str}", - rc, 22)) + rc, 26)) # 停机状态 stop_text = "已停机" if is_stopped else "运行中" stop_color = ((255, 100, 100) if is_stopped else (100, 255, 100)) - texts.append((bw + 10, sh - 52, f"状态: {stop_text}", stop_color, 22)) + texts.append((bw + 500, 20, f"状态: {stop_text}", stop_color, 30)) # 时间戳 - texts.append((bw + 10, sh - 26, - time.strftime("%Y-%m-%d %H:%M:%S"), (160, 160, 160), 20)) - + # texts.append((bw + 10, sh - 26, + # time.strftime("%Y-%m-%d %H:%M:%S"), (160, 160, 160), 20)) elif display_mode == "fullscreen": # ========================================== # 全屏轮播模式:显示有人方向的画面 @@ -1023,13 +1085,6 @@ class RenderWorker(threading.Thread): presence[0], presence[1], presence[2], presence[3], radar_thr) - # 记录状态用于调试 - if self._last_active_dirs != active_dirs: - self._last_active_dirs = active_dirs.copy() - mode_str = {"reverse": "倒车模式", "fullscreen": "全屏轮播", - "normal": "正常模式"}.get(display_mode, display_mode) - print(f"[RENDER] 模式切换: {mode_str}, 检测到: {active_dirs}, 倒车: {is_reverse}") - except Exception as e: print("[RENDER ERROR] {}".format(e))