From 39006f7401a68876cd002288f76c19ba0cb07beb Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 27 May 2023 23:59:18 -0400 Subject: [PATCH] Invert DM cam if reversing (#74) --- selfdrive/ui/qt/widgets/cameraview.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc index 016129c348..ffcd1b3aab 100644 --- a/selfdrive/ui/qt/widgets/cameraview.cc +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -62,11 +62,14 @@ const char frame_fragment_shader[] = #endif mat4 get_driver_view_transform(int screen_width, int screen_height, int stream_width, int stream_height) { + UIState *s = uiState(); + const float driver_view_ratio = 2.0; const float yscale = stream_height * driver_view_ratio / stream_width; const float xscale = yscale*screen_height/screen_width*stream_width/stream_height; + float xscale_invert = (s->scene.reverse_dm_cam ? -xscale : xscale); mat4 transform = (mat4){{ - xscale, 0.0, 0.0, 0.0, + xscale_invert, 0.0, 0.0, 0.0, 0.0, yscale, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0,