Skip to content

Commit

Permalink
ui: enhance DriverView with real-time driver state rendering (commaai…
Browse files Browse the repository at this point in the history
…#33776)

enhance DriverView
  • Loading branch information
deanlee authored Oct 18, 2024
1 parent 34dde0b commit 6175106
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
11 changes: 2 additions & 9 deletions selfdrive/ui/qt/offroad/driverview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

#include "selfdrive/ui/qt/util.h"

const int FACE_IMG_SIZE = 130;

DriverViewWindow::DriverViewWindow(QWidget* parent) : CameraWidget("camerad", VISION_STREAM_DRIVER, parent) {
face_img = loadPixmap("../assets/img_driver_face_static.png", {FACE_IMG_SIZE, FACE_IMG_SIZE});
QObject::connect(this, &CameraWidget::clicked, this, &DriverViewWindow::done);
QObject::connect(device(), &Device::interactiveTimeout, this, [this]() {
if (isVisible()) {
Expand Down Expand Up @@ -68,12 +65,8 @@ void DriverViewWindow::paintGL() {
p.drawRoundedRect(fbox_x - box_size / 2, fbox_y - box_size / 2, box_size, box_size, 35.0, 35.0);
}

// icon
const int img_offset = 60;
const int img_x = is_rhd ? rect().right() - FACE_IMG_SIZE - img_offset : rect().left() + img_offset;
const int img_y = rect().bottom() - FACE_IMG_SIZE - img_offset;
p.setOpacity(face_detected ? 1.0 : 0.2);
p.drawPixmap(img_x, img_y, face_img);
driver_monitor.updateState(*uiState());
driver_monitor.draw(p, rect());
}

mat4 DriverViewWindow::calcFrameMatrix() {
Expand Down
3 changes: 2 additions & 1 deletion selfdrive/ui/qt/offroad/driverview.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "selfdrive/ui/qt/widgets/cameraview.h"
#include "selfdrive/ui/qt/onroad/driver_monitoring.h"

class DriverViewWindow : public CameraWidget {
Q_OBJECT
Expand All @@ -18,5 +19,5 @@ class DriverViewWindow : public CameraWidget {
void paintGL() override;

Params params;
QPixmap face_img;
DriverMonitorRenderer driver_monitor;
};

0 comments on commit 6175106

Please sign in to comment.