frame_id is a uint32_t

pull/24335/head
Shane Smiskol 3 years ago
parent aff7d92696
commit 2cc2a2f1c9
  1. 8
      selfdrive/ui/qt/widgets/cameraview.cc
  2. 8
      selfdrive/ui/qt/widgets/cameraview.h

@ -103,6 +103,7 @@ mat4 get_fit_view_transform(float widget_aspect_ratio, float frame_aspect_ratio)
CameraViewWidget::CameraViewWidget(std::string stream_name, VisionStreamType type, bool zoom, QWidget* parent) : CameraViewWidget::CameraViewWidget(std::string stream_name, VisionStreamType type, bool zoom, QWidget* parent) :
stream_name(stream_name), stream_type(type), zoomed_view(zoom), QOpenGLWidget(parent) { stream_name(stream_name), stream_type(type), zoomed_view(zoom), QOpenGLWidget(parent) {
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
qRegisterMetaType<uint8_t>("uint32_t");
connect(this, &CameraViewWidget::vipcThreadConnected, this, &CameraViewWidget::vipcConnected, Qt::BlockingQueuedConnection); connect(this, &CameraViewWidget::vipcThreadConnected, this, &CameraViewWidget::vipcConnected, Qt::BlockingQueuedConnection);
connect(this, &CameraViewWidget::vipcThreadFrameReceived, this, &CameraViewWidget::vipcFrameReceived); connect(this, &CameraViewWidget::vipcThreadFrameReceived, this, &CameraViewWidget::vipcFrameReceived);
} }
@ -221,12 +222,11 @@ void CameraViewWidget::paintGL() {
if (frames.size() == 0) return; if (frames.size() == 0) return;
VisionBuf *latest_frame; VisionBuf *latest_frame;
std::deque<int>::iterator it = std::find(frame_ids.begin(), frame_ids.end(), draw_frame_id); std::deque<uint32_t>::iterator it = std::find(frame_ids.begin(), frame_ids.end(), draw_frame_id);
if (it == frame_ids.end()) { if (it == frame_ids.end()) {
latest_frame = frames[frames.size() - 1]; latest_frame = frames[frames.size() - 1];
} else { } else {
int frame_id = it - frame_ids.begin(); latest_frame = frames[it - frame_ids.begin()];
latest_frame = frames[frame_id];
} }
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@ -277,7 +277,7 @@ void CameraViewWidget::vipcConnected(VisionIpcClient *vipc_client) {
updateFrameMat(width(), height()); updateFrameMat(width(), height());
} }
void CameraViewWidget::vipcFrameReceived(VisionBuf *buf, int frame_id) { void CameraViewWidget::vipcFrameReceived(VisionBuf *buf, uint32_t frame_id) {
frames.push_back(buf); frames.push_back(buf);
frame_ids.push_back(frame_id); frame_ids.push_back(frame_id);
while (frames.size() > FRAME_BUFFER_LEN) { while (frames.size() > FRAME_BUFFER_LEN) {

@ -19,12 +19,12 @@ public:
~CameraViewWidget(); ~CameraViewWidget();
void setStreamType(VisionStreamType type) { stream_type = type; } void setStreamType(VisionStreamType type) { stream_type = type; }
void setBackgroundColor(const QColor &color) { bg = color; } void setBackgroundColor(const QColor &color) { bg = color; }
int draw_frame_id; uint32_t draw_frame_id;
signals: signals:
void clicked(); void clicked();
void vipcThreadConnected(VisionIpcClient *); void vipcThreadConnected(VisionIpcClient *);
void vipcThreadFrameReceived(VisionBuf *, int); void vipcThreadFrameReceived(VisionBuf *, uint32_t);
protected: protected:
void paintGL() override; void paintGL() override;
@ -38,7 +38,7 @@ protected:
bool zoomed_view; bool zoomed_view;
std::deque<VisionBuf*> frames; std::deque<VisionBuf*> frames;
std::deque<int> frame_ids; std::deque<uint32_t> frame_ids;
GLuint frame_vao, frame_vbo, frame_ibo; GLuint frame_vao, frame_vbo, frame_ibo;
mat4 frame_mat; mat4 frame_mat;
std::unique_ptr<QOpenGLShaderProgram> program; std::unique_ptr<QOpenGLShaderProgram> program;
@ -54,5 +54,5 @@ protected:
protected slots: protected slots:
void vipcConnected(VisionIpcClient *vipc_client); void vipcConnected(VisionIpcClient *vipc_client);
void vipcFrameReceived(VisionBuf *vipc_client, int frame_id); void vipcFrameReceived(VisionBuf *vipc_client, uint32_t frame_id);
}; };

Loading…
Cancel
Save