From da5b3f829fb04ed94a082ef5b0ee0cd24639708c Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:39:07 -0500 Subject: [PATCH] black pink in your area2 --- selfdrive/ui/mici/layouts/settings/visuals.py | 2 +- .../ui/mici/onroad/augmented_road_view.py | 52 ++++++++++++------- selfdrive/ui/qt/onroad/annotated_camera.cc | 28 ++++++++-- starpilot/ui/qt/offroad/visual_settings.cc | 2 +- .../qt/onroad/starpilot_annotated_camera.cc | 6 +-- .../ui/qt/onroad/starpilot_annotated_camera.h | 2 +- 6 files changed, 63 insertions(+), 29 deletions(-) diff --git a/selfdrive/ui/mici/layouts/settings/visuals.py b/selfdrive/ui/mici/layouts/settings/visuals.py index 264e6720f..77b47bfb4 100644 --- a/selfdrive/ui/mici/layouts/settings/visuals.py +++ b/selfdrive/ui/mici/layouts/settings/visuals.py @@ -5,7 +5,7 @@ from openpilot.selfdrive.ui.mici.widgets.dialog import BigDialog, BigMultiOption from openpilot.system.ui.lib.application import gui_app from openpilot.system.ui.widgets.scroller import NavScroller -CAMERA_VIEW_LABELS = ["Auto", "Driver", "Standard", "Wide"] +CAMERA_VIEW_LABELS = ["Auto", "Driver", "Standard", "Wide", "None"] class CameraViewBigButton(BigButton): diff --git a/selfdrive/ui/mici/onroad/augmented_road_view.py b/selfdrive/ui/mici/onroad/augmented_road_view.py index 90bb39fc0..e7959b0da 100644 --- a/selfdrive/ui/mici/onroad/augmented_road_view.py +++ b/selfdrive/ui/mici/onroad/augmented_road_view.py @@ -40,6 +40,7 @@ CAMERA_VIEW_AUTO = 0 CAMERA_VIEW_DRIVER = 1 CAMERA_VIEW_STANDARD = 2 CAMERA_VIEW_WIDE = 3 +CAMERA_VIEW_NONE = 4 class BookmarkState(IntEnum): @@ -420,7 +421,9 @@ class AugmentedRoadView(CameraView): def _render(self, _): start_draw = time.monotonic() - self._switch_stream_if_needed(ui_state.sm) + camera_view = self._camera_view() + camera_view_none = camera_view == CAMERA_VIEW_NONE + self._switch_stream_if_needed(ui_state.sm, camera_view) # Update calibration before rendering self._update_calibration() @@ -443,7 +446,10 @@ class AugmentedRoadView(CameraView): ) # Render the base camera view - super()._render(self._content_rect) + if camera_view_none: + rl.draw_rectangle_rec(self._content_rect, rl.BLACK) + else: + super()._render(self._content_rect) waiting_for_controls = ui_state.started and not self._controls_ready() if waiting_for_controls: @@ -462,39 +468,41 @@ class AugmentedRoadView(CameraView): in_reverse = self._is_in_reverse() is_driver_stream = self.stream_type == DRIVER_CAM + draw_road_overlays = not in_reverse and not is_driver_stream and not camera_view_none + draw_hud_controls = camera_view_none or (not in_reverse and not is_driver_stream) self._hud_renderer.prepare(self._content_rect) # Draw all UI overlays - if not in_reverse and not is_driver_stream: + if draw_road_overlays: self._model_renderer.render(self._content_rect) # Fade out bottom of overlays for looks rl.draw_texture_ex(self._fade_texture, rl.Vector2(self._content_rect.x, self._content_rect.y), 0.0, 1.0, rl.WHITE) - if not in_reverse and not is_driver_stream: + if draw_hud_controls: self._hud_renderer.render_background() alert_to_render, not_animating_out = self._alert_renderer.will_render() should_draw_dmoji = ui_state.is_onroad() and ( - is_driver_stream or ((not in_reverse) and (not self._hud_renderer.drawing_top_icons())) + is_driver_stream or camera_view_none or ((not in_reverse) and (not self._hud_renderer.drawing_top_icons())) ) self._driver_state_renderer.set_should_draw(should_draw_dmoji) self._driver_state_renderer.set_position(self._rect.x + 16, self._rect.y + 10) - if is_driver_stream or not in_reverse: + if camera_view_none or is_driver_stream or not in_reverse: self._driver_state_renderer.render() - self._hud_renderer.set_can_draw_top_icons((not in_reverse) and (not is_driver_stream) and (alert_to_render is None)) - self._hud_renderer.set_wheel_critical_icon((not in_reverse) and (not is_driver_stream) and alert_to_render is not None and not not_animating_out and + self._hud_renderer.set_can_draw_top_icons(draw_hud_controls and (alert_to_render is None)) + self._hud_renderer.set_wheel_critical_icon(draw_hud_controls and alert_to_render is not None and not not_animating_out and alert_to_render.visual_alert == car.CarControl.HUDControl.VisualAlert.steerRequired) # TODO: have alert renderer draw offroad mici label below if ui_state.started: self._alert_renderer.render(self._content_rect) - if not in_reverse and not is_driver_stream: + if draw_hud_controls: self._hud_renderer.render_foreground() rendered_standstill_timer = False - if not in_reverse and not is_driver_stream: + if draw_hud_controls: rendered_standstill_timer = self._standstill_timer.render(self._content_rect, in_reverse) - if not in_reverse and not is_driver_stream and not rendered_standstill_timer: + if draw_hud_controls and not rendered_standstill_timer: self._min_steer_speed_banner.render(self._content_rect) # End clipping region @@ -502,9 +510,9 @@ class AugmentedRoadView(CameraView): # Custom UI extension point - add custom overlays here # Use self._content_rect for positioning within camera bounds - if not in_reverse and not is_driver_stream: + if draw_road_overlays: self._confidence_ball.render(self.rect) - if is_driver_stream or not in_reverse: + if camera_view_none or is_driver_stream or not in_reverse: self._draw_border() self._bookmark_icon.render(self.rect) @@ -555,17 +563,25 @@ class AugmentedRoadView(CameraView): def is_in_reverse(self) -> bool: return self._is_in_reverse() - def _switch_stream_if_needed(self, sm): + @staticmethod + def _camera_view() -> int: + camera_view = ui_state.params.get_int("CameraView", return_default=True, default=CAMERA_VIEW_WIDE) + if camera_view not in (CAMERA_VIEW_AUTO, CAMERA_VIEW_DRIVER, CAMERA_VIEW_STANDARD, CAMERA_VIEW_WIDE, CAMERA_VIEW_NONE): + return CAMERA_VIEW_WIDE + return camera_view + + def _switch_stream_if_needed(self, sm, camera_view: int): + if camera_view == CAMERA_VIEW_NONE: + self._reverse_driver_camera_frames = 0 + self._reverse_driver_camera_active = False + return + if self._update_reverse_driver_camera_state(): target = DRIVER_CAM if self.stream_type != target: self.switch_stream(target) return - camera_view = ui_state.params.get_int("CameraView", return_default=True, default=CAMERA_VIEW_WIDE) - if camera_view not in (CAMERA_VIEW_AUTO, CAMERA_VIEW_DRIVER, CAMERA_VIEW_STANDARD, CAMERA_VIEW_WIDE): - camera_view = CAMERA_VIEW_WIDE - if camera_view == CAMERA_VIEW_DRIVER: target = DRIVER_CAM elif camera_view == CAMERA_VIEW_STANDARD: diff --git a/selfdrive/ui/qt/onroad/annotated_camera.cc b/selfdrive/ui/qt/onroad/annotated_camera.cc index 48fbcd902..fe21332f8 100644 --- a/selfdrive/ui/qt/onroad/annotated_camera.cc +++ b/selfdrive/ui/qt/onroad/annotated_camera.cc @@ -4,11 +4,15 @@ #include #include #include +#include +#include #include "common/params.h" #include "common/swaglog.h" #include "selfdrive/ui/qt/util.h" +constexpr int CAMERA_VIEW_NONE = 4; + // Window that shows camera view and variety of info drawn on top AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget *parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraWidget("camerad", type, parent) { @@ -139,9 +143,22 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) { const double start_draw_t = millis_since_boot(); QPainter painter(this); + static Params params; + const std::string camera_view_param = params.get("CameraView"); + int camera_view = starpilot_toggles.value("camera_view").toInt(); + if (!camera_view_param.empty()) { + try { + camera_view = std::stoi(camera_view_param); + } catch (const std::exception &) { + LOGW("invalid CameraView param: %s", camera_view_param.c_str()); + } + } + const bool camera_view_none = camera_view == CAMERA_VIEW_NONE; // draw camera frame - { + if (camera_view_none) { + painter.fillRect(rect(), Qt::black); + } else { std::lock_guard lk(frame_lock); if (frames.empty()) { @@ -166,9 +183,8 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) { } else if (v_ego > 15) { wide_cam_requested = false; } - wide_cam_requested = wide_cam_requested && sm["selfdriveState"].getSelfdriveState().getExperimentalMode() && starpilot_toggles.value("camera_view").toInt() == 0; + wide_cam_requested = wide_cam_requested && sm["selfdriveState"].getSelfdriveState().getExperimentalMode() && camera_view == 0; } - int camera_view = starpilot_toggles.value("camera_view").toInt(); CameraWidget::setStreamType(camera_view == 1 ? VISION_STREAM_DRIVER : ((camera_view == 3 && has_wide_cam) || wide_cam_requested) ? VISION_STREAM_WIDE_ROAD : VISION_STREAM_ROAD); @@ -194,12 +210,14 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) { hud.starpilot_toggles = starpilot_toggles; model.starpilot_toggles = starpilot_toggles; - model.draw(painter, rect()); + if (!camera_view_none) { + model.draw(painter, rect()); + } dmon.draw(painter, rect()); hud.updateState(*s); hud.draw(painter, rect()); - starpilot_nvg->paintStarPilotWidgets(painter, *s); + starpilot_nvg->paintStarPilotWidgets(painter, *s, camera_view_none); double cur_draw_t = millis_since_boot(); double dt = cur_draw_t - prev_draw_t; diff --git a/starpilot/ui/qt/offroad/visual_settings.cc b/starpilot/ui/qt/offroad/visual_settings.cc index 5d15a7f69..7e7e88dc0 100644 --- a/starpilot/ui/qt/offroad/visual_settings.cc +++ b/starpilot/ui/qt/offroad/visual_settings.cc @@ -135,7 +135,7 @@ StarPilotVisualsPanel::StarPilotVisualsPanel(StarPilotSettingsWindow *parent, bo }); visualToggle = qolToggle; } else if (param == "CameraView") { - std::vector cameraOptions{tr("Auto"), tr("Driver"), tr("Standard"), tr("Wide")}; + std::vector cameraOptions{tr("Auto"), tr("Driver"), tr("Standard"), tr("Wide"), tr("None")}; ButtonParamControl *cameraSelection = new ButtonParamControl(param, title, desc, icon, cameraOptions); visualToggle = cameraSelection; diff --git a/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc b/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc index a8578bdc7..9aaf00ae9 100644 --- a/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc +++ b/starpilot/ui/qt/onroad/starpilot_annotated_camera.cc @@ -297,7 +297,7 @@ void StarPilotAnnotatedCameraWidget::mousePressEvent(QMouseEvent *mouseEvent) { mouseEvent->ignore(); } -void StarPilotAnnotatedCameraWidget::paintStarPilotWidgets(QPainter &p, UIState &s) { +void StarPilotAnnotatedCameraWidget::paintStarPilotWidgets(QPainter &p, UIState &s, bool hideCameraOverlays) { if (cachedSimpleMode) { cemStatusPosition = QPoint(0, 0); compassPosition = QPoint(0, 0); @@ -345,7 +345,7 @@ void StarPilotAnnotatedCameraWidget::paintStarPilotWidgets(QPainter &p, UIState paintPedalIcons(p); } - if (cachedRadarTracks) { + if (!hideCameraOverlays && cachedRadarTracks) { paintRadarTracks(p); } @@ -368,7 +368,7 @@ void StarPilotAnnotatedCameraWidget::paintStarPilotWidgets(QPainter &p, UIState paintStandstillTimer(p); } - if (track_vertices.length() >= 1 && redLight && cachedShowStoppingPoint) { + if (!hideCameraOverlays && track_vertices.length() >= 1 && redLight && cachedShowStoppingPoint) { paintStoppingPoint(p); } diff --git a/starpilot/ui/qt/onroad/starpilot_annotated_camera.h b/starpilot/ui/qt/onroad/starpilot_annotated_camera.h index 91c1276d9..4d779c301 100644 --- a/starpilot/ui/qt/onroad/starpilot_annotated_camera.h +++ b/starpilot/ui/qt/onroad/starpilot_annotated_camera.h @@ -14,7 +14,7 @@ public: void mousePressEvent(QMouseEvent *mouseEvent) override; void paintAdjacentPaths(QPainter &p); void paintBlindSpotPath(QPainter &p); - void paintStarPilotWidgets(QPainter &p, UIState &s); + void paintStarPilotWidgets(QPainter &p, UIState &s, bool hideCameraOverlays = false); void paintLeadMetrics(QPainter &p, bool adjacent, QPointF *chevron, const cereal::RadarState::LeadData::Reader &lead_data); void paintPathEdges(QPainter &p, int height); void paintRainbowPath(QPainter &p, QLinearGradient &bg, float lin_grad_point);