Skip to content

Commit acd04e5

Browse files
committed
cleanup zoom
1 parent 73c3594 commit acd04e5

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

selfdrive/ui/qt/onroad.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,7 @@ void NvgWindow::updateFrameMat() {
412412

413413
s->fb_w = w;
414414
s->fb_h = h;
415-
auto intrinsic_matrix = s->wide_camera ? ecam_intrinsic_matrix : fcam_intrinsic_matrix;
416-
float zoom = ZOOM / intrinsic_matrix.v[0];
417-
if (s->wide_camera) {
418-
zoom *= 0.5;
419-
}
415+
420416
// Apply transformation such that video pixel coordinates match video
421417
// 1) Put (0, 0) in the middle of the video
422418
// 2) Apply same scaling as video

selfdrive/ui/qt/widgets/cameraview.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,8 @@ void CameraViewWidget::updateFrameMat() {
187187
if (stream_type == VISION_STREAM_DRIVER) {
188188
frame_mat = get_driver_view_transform(w, h, stream_width, stream_height);
189189
} else {
190-
auto intrinsic_matrix = stream_type == VISION_STREAM_WIDE_ROAD ? ecam_intrinsic_matrix : fcam_intrinsic_matrix;
191-
float zoom = ZOOM / intrinsic_matrix.v[0];
192-
if (stream_type == VISION_STREAM_WIDE_ROAD) {
193-
zoom *= 0.5;
194-
}
190+
intrinsic_matrix = (stream_type == VISION_STREAM_WIDE_ROAD) ? ecam_intrinsic_matrix : fcam_intrinsic_matrix;
191+
zoom = (stream_type == VISION_STREAM_WIDE_ROAD) ? 2.5 : 1.1;
195192

196193
// Project point at "infinity" to compute x and y offsets
197194
// to ensure this ends up in the middle of the screen

selfdrive/ui/qt/widgets/cameraview.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ class CameraViewWidget : public QOpenGLWidget, protected QOpenGLFunctions {
6666
int stream_width = 0;
6767
int stream_height = 0;
6868
int stream_stride = 0;
69+
std::atomic<VisionStreamType> stream_type;
70+
QThread *vipc_thread = nullptr;
71+
72+
// Calibration
6973
float x_offset = 0;
7074
float y_offset = 0;
75+
float zoom = 1.0;
7176
mat3 calibration = DEFAULT_CALIBRATION;
72-
std::atomic<VisionStreamType> stream_type;
73-
QThread *vipc_thread = nullptr;
77+
mat3 intrinsic_matrix = fcam_intrinsic_matrix;
7478

7579
std::deque<std::pair<uint32_t, VisionBuf*>> frames;
7680
uint32_t draw_frame_id = 0;

selfdrive/ui/ui.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ const int footer_h = 280;
2222
const int UI_FREQ = 20; // Hz
2323
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert;
2424

25-
// TODO: choose based on frame input size
26-
const float ZOOM = 2912.8;
2725
const mat3 DEFAULT_CALIBRATION = {{ 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0 }};
2826

2927
struct Alert {

0 commit comments

Comments
 (0)