Screenrecorder
Credit goes to Neokii! https: //github.com/neokii Co-Authored-By: neokii <3665951+neokii@users.noreply.github.com>
This commit is contained in:
@@ -444,8 +444,17 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par
|
||||
main_layout->setMargin(UI_BORDER_SIZE);
|
||||
main_layout->setSpacing(0);
|
||||
|
||||
// Neokii screen recorder
|
||||
QHBoxLayout *top_right_layout = new QHBoxLayout();
|
||||
top_right_layout->setSpacing(0);
|
||||
recorder_btn = new ScreenRecorder(this);
|
||||
top_right_layout->addWidget(recorder_btn);
|
||||
|
||||
experimental_btn = new ExperimentalButton(this);
|
||||
main_layout->addWidget(experimental_btn, 0, Qt::AlignTop | Qt::AlignRight);
|
||||
top_right_layout->addWidget(experimental_btn);
|
||||
|
||||
main_layout->addLayout(top_right_layout, 0);
|
||||
main_layout->setAlignment(top_right_layout, Qt::AlignTop | Qt::AlignRight);
|
||||
|
||||
map_settings_btn = new MapSettingsButton(this);
|
||||
main_layout->addWidget(map_settings_btn, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
@@ -962,8 +971,12 @@ void AnnotatedCameraWidget::drawLead(QPainter &painter, const cereal::RadarState
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::paintGL() {
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) {
|
||||
UIState *s = uiState();
|
||||
SubMaster &sm = *(s->sm);
|
||||
QPainter painter(this);
|
||||
const double start_draw_t = millis_since_boot();
|
||||
const cereal::ModelDataV2::Reader &model = sm["modelV2"].getModelV2();
|
||||
|
||||
@@ -1008,11 +1021,12 @@ void AnnotatedCameraWidget::paintGL() {
|
||||
} else {
|
||||
CameraWidget::updateCalibration(DEFAULT_CALIBRATION);
|
||||
}
|
||||
painter.beginNativePainting();
|
||||
CameraWidget::setFrameId(model.getFrameId());
|
||||
CameraWidget::paintGL();
|
||||
painter.endNativePainting();
|
||||
}
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
@@ -1110,6 +1124,15 @@ void AnnotatedCameraWidget::initializeFrogPilotWidgets() {
|
||||
connect(animationTimer, &QTimer::timeout, this, [this] {
|
||||
animationFrameIndex = (animationFrameIndex + 1) % totalFrames;
|
||||
});
|
||||
|
||||
// Initialize the timer for the screen recorder
|
||||
QTimer *record_timer = new QTimer(this);
|
||||
connect(record_timer, &QTimer::timeout, this, [this]() {
|
||||
if (this->recorder_btn) {
|
||||
this->recorder_btn->update_screen();
|
||||
}
|
||||
});
|
||||
record_timer->start(1000 / UI_FREQ);
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/qt/widgets/cameraview.h"
|
||||
|
||||
#include "selfdrive/frogpilot/screenrecorder/screenrecorder.h"
|
||||
|
||||
const int btn_size = 192;
|
||||
const int img_size = (btn_size / 4) * 3;
|
||||
@@ -151,6 +152,7 @@ private:
|
||||
UIScene &scene;
|
||||
|
||||
Compass *compass_img;
|
||||
ScreenRecorder *recorder_btn;
|
||||
|
||||
QHBoxLayout *bottom_layout;
|
||||
|
||||
@@ -201,6 +203,7 @@ protected:
|
||||
void drawLead(QPainter &painter, const cereal::RadarState::LeadData::Reader &lead_data, const QPointF &vd);
|
||||
void drawHud(QPainter &p);
|
||||
void drawDriverState(QPainter &painter, const UIState *s);
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
|
||||
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
|
||||
inline QColor blackColor(int alpha = 255) { return QColor(0, 0, 0, alpha); }
|
||||
|
||||
Reference in New Issue
Block a user