fps filter
parent
c88ced1f10
commit
bdf38130cc
|
@ -267,6 +267,11 @@ void OnroadHud::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, flo
|
|||
}
|
||||
|
||||
// NvgWindow
|
||||
NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) :
|
||||
CameraViewWidget("camerad", type, true, parent), fps_filter(20, 3, 1. / UI_FREQ) {
|
||||
|
||||
}
|
||||
|
||||
void NvgWindow::initializeGL() {
|
||||
CameraViewWidget::initializeGL();
|
||||
qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION));
|
||||
|
@ -376,9 +381,10 @@ void NvgWindow::paintGL() {
|
|||
|
||||
double cur_draw_t = millis_since_boot();
|
||||
double dt = cur_draw_t - prev_draw_t;
|
||||
if (dt > 66) {
|
||||
// warn on sub 15fps
|
||||
LOGW("slow frame time: %.2f", dt);
|
||||
double ui_freq = fps_filter.update(1. / (dt / 1000.));
|
||||
printf("%.2f\n", ui_freq);
|
||||
if (ui_freq < 15) {
|
||||
LOGW("UI lagging: %.2fHz", ui_freq);
|
||||
}
|
||||
prev_draw_t = cur_draw_t;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QStackedLayout>
|
||||
#include <QWidget>
|
||||
|
||||
#include "selfdrive/common/util.h"
|
||||
#include "selfdrive/ui/qt/widgets/cameraview.h"
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
|
@ -66,7 +67,7 @@ class NvgWindow : public CameraViewWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NvgWindow(VisionStreamType type, QWidget* parent = 0) : CameraViewWidget("camerad", type, true, parent) {}
|
||||
explicit NvgWindow(VisionStreamType type, QWidget* parent = 0);
|
||||
|
||||
protected:
|
||||
void paintGL() override;
|
||||
|
@ -77,7 +78,9 @@ protected:
|
|||
void drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd);
|
||||
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
|
||||
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
|
||||
|
||||
double prev_draw_t = 0;
|
||||
FirstOrderFilter fps_filter;
|
||||
};
|
||||
|
||||
// container for all onroad widgets
|
||||
|
|
Loading…
Reference in New Issue