Skip to content

Commit

Permalink
cleanup zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm committed Jun 27, 2022
1 parent 59cf95d commit 8cac9d6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
6 changes: 1 addition & 5 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,7 @@ void NvgWindow::updateFrameMat() {

s->fb_w = w;
s->fb_h = h;
auto intrinsic_matrix = s->wide_camera ? ecam_intrinsic_matrix : fcam_intrinsic_matrix;
float zoom = ZOOM / intrinsic_matrix.v[0];
if (s->wide_camera) {
zoom *= 0.5;
}

// Apply transformation such that video pixel coordinates match video
// 1) Put (0, 0) in the middle of the video
// 2) Apply same scaling as video
Expand Down
7 changes: 2 additions & 5 deletions selfdrive/ui/qt/widgets/cameraview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,8 @@ void CameraViewWidget::updateFrameMat() {
if (stream_type == VISION_STREAM_DRIVER) {
frame_mat = get_driver_view_transform(w, h, stream_width, stream_height);
} else {
auto intrinsic_matrix = stream_type == VISION_STREAM_WIDE_ROAD ? ecam_intrinsic_matrix : fcam_intrinsic_matrix;
float zoom = ZOOM / intrinsic_matrix.v[0];
if (stream_type == VISION_STREAM_WIDE_ROAD) {
zoom *= 0.5;
}
intrinsic_matrix = (stream_type == VISION_STREAM_WIDE_ROAD) ? ecam_intrinsic_matrix : fcam_intrinsic_matrix;
zoom = (stream_type == VISION_STREAM_WIDE_ROAD) ? 2.5 : 1.1;

// Project point at "infinity" to compute x and y offsets
// to ensure this ends up in the middle of the screen
Expand Down
8 changes: 6 additions & 2 deletions selfdrive/ui/qt/widgets/cameraview.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ class CameraViewWidget : public QOpenGLWidget, protected QOpenGLFunctions {
int stream_width = 0;
int stream_height = 0;
int stream_stride = 0;
std::atomic<VisionStreamType> stream_type;
QThread *vipc_thread = nullptr;

// Calibration
float x_offset = 0;
float y_offset = 0;
float zoom = 1.0;
mat3 calibration = DEFAULT_CALIBRATION;
std::atomic<VisionStreamType> stream_type;
QThread *vipc_thread = nullptr;
mat3 intrinsic_matrix = fcam_intrinsic_matrix;

std::deque<std::pair<uint32_t, VisionBuf*>> frames;
uint32_t draw_frame_id = 0;
Expand Down
2 changes: 0 additions & 2 deletions selfdrive/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const int footer_h = 280;
const int UI_FREQ = 20; // Hz
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert;

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

struct Alert {
Expand Down

0 comments on commit 8cac9d6

Please sign in to comment.