ui: enhance DriverView with real-time driver state rendering (#33776)

enhance DriverView
This commit is contained in:
Dean Lee 2024-10-18 11:25:32 +08:00 committed by GitHub
parent 34dde0bb36
commit 6175106b19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 10 deletions

View File

@ -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()) {
@ -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() {

View File

@ -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
@ -18,5 +19,5 @@ protected:
void paintGL() override;
Params params;
QPixmap face_img;
DriverMonitorRenderer driver_monitor;
};