From aafed83accb0d01781878ac475a708b61eb11bc0 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 7 Sep 2023 04:25:40 +0800 Subject: [PATCH] ui/CameraView: fix divide by zero issue (#29770) old-commit-hash: a1306114bc8de7d55137258088d8d042afb86018 --- selfdrive/ui/qt/widgets/cameraview.cc | 4 +++- selfdrive/ui/qt/widgets/cameraview.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc index fea81ab910..ab1bafb883 100644 --- a/selfdrive/ui/qt/widgets/cameraview.cc +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -207,7 +207,9 @@ void CameraWidget::updateFrameMat() { if (zoomed_view) { if (active_stream_type == VISION_STREAM_DRIVER) { - frame_mat = get_driver_view_transform(w, h, stream_width, stream_height); + if (stream_width > 0 && stream_height > 0) { + frame_mat = get_driver_view_transform(w, h, stream_width, stream_height); + } } else { // Project point at "infinity" to compute x and y offsets // to ensure this ends up in the middle of the screen diff --git a/selfdrive/ui/qt/widgets/cameraview.h b/selfdrive/ui/qt/widgets/cameraview.h index 647653cdd3..fcd5b1b18f 100644 --- a/selfdrive/ui/qt/widgets/cameraview.h +++ b/selfdrive/ui/qt/widgets/cameraview.h @@ -65,7 +65,7 @@ protected: bool zoomed_view; GLuint frame_vao, frame_vbo, frame_ibo; GLuint textures[2]; - mat4 frame_mat; + mat4 frame_mat = {}; std::unique_ptr program; QColor bg = QColor("#000000");