diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 7f41b14989..72b9a3e771 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -17,11 +17,21 @@ extern "C"{ #include "sidebar.hpp" // TODO: this is also hardcoded in common/transformations/camera.py +// TODO: choose based on frame input size +#ifdef QCOM2 +const mat3 intrinsic_matrix = (mat3){{ + 2648.0, 0.0, 1928.0/2, + 0.0, 2648.0, 1208.0/2, + 0.0, 0.0, 1.0 +}}; +#else const mat3 intrinsic_matrix = (mat3){{ 910., 0., 582., 0., 910., 437., 0., 0., 1. }}; +#endif + const uint8_t alert_colors[][4] = { [STATUS_OFFROAD] = {0x07, 0x23, 0x39, 0xf1}, diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 2926059e15..fadc07c049 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -19,13 +19,21 @@ volatile sig_atomic_t do_exit = 0; MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { main_layout = new QStackedLayout; +#ifdef QCOM2 + QLabel * label = new QLabel(this); + main_layout->addWidget(label); + + GLWindow * glWindow = new GLWindow; + glWindow->setLabel(label); + glWindow->show(); +#else GLWindow * glWindow = new GLWindow(this); main_layout->addWidget(glWindow); +#endif SettingsWindow * settingsWindow = new SettingsWindow(this); main_layout->addWidget(settingsWindow); - main_layout->setMargin(0); setLayout(main_layout); QObject::connect(glWindow, SIGNAL(openSettings()), this, SLOT(openSettings())); @@ -52,6 +60,10 @@ GLWindow::GLWindow(QWidget *parent) : QOpenGLWidget(parent) { timer = new QTimer(this); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate())); +#ifdef QCOM2 + setFixedWidth(vwp_w); + setFixedHeight(vwp_h); +#endif } GLWindow::~GLWindow() { @@ -59,6 +71,10 @@ GLWindow::~GLWindow() { doneCurrent(); } +void GLWindow::setLabel(QLabel * l){ + label = l; +} + void GLWindow::initializeGL() { initializeOpenGLFunctions(); std::cout << "OpenGL version: " << glGetString(GL_VERSION) << std::endl; @@ -78,6 +94,13 @@ void GLWindow::initializeGL() { void GLWindow::timerUpdate(){ ui_update(ui_state); update(); + + if (label != NULL){ + QImage img = grabFramebuffer(); + QTransform transform; + transform.rotate(90); + label->setPixmap(QPixmap::fromImage(img).transformed(transform)); + } } void GLWindow::resizeGL(int w, int h) { diff --git a/selfdrive/ui/qt/window.hpp b/selfdrive/ui/qt/window.hpp index cea6dd4982..d73acfe04f 100644 --- a/selfdrive/ui/qt/window.hpp +++ b/selfdrive/ui/qt/window.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -39,6 +40,7 @@ class GLWindow : public QOpenGLWidget, protected QOpenGLFunctions public: using QOpenGLWidget::QOpenGLWidget; explicit GLWindow(QWidget *parent = 0); + void setLabel(QLabel *l); ~GLWindow(); protected: @@ -52,6 +54,7 @@ private: QTimer * timer; UIState * ui_state; QtSound sound; + QLabel * label = NULL; public slots: void timerUpdate();