mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-21 14:02:05 +08:00
tici driverview support (#20223)
* add tici support and clean up * not exactly 4/3 * keep c2 style Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
+34
-12
@@ -263,19 +263,22 @@ static void ui_draw_vision_face(UIState *s) {
|
||||
static void ui_draw_driver_view(UIState *s) {
|
||||
s->sidebar_collapsed = true;
|
||||
const bool is_rhd = s->scene.is_rhd;
|
||||
const int width = 3 * s->viz_rect.w / 4;
|
||||
const int width = 4 * s->viz_rect.h / 3;
|
||||
const Rect rect = {s->viz_rect.centerX() - width / 2, s->viz_rect.y, width, s->viz_rect.h}; // x, y, w, h
|
||||
const Rect valid_rect = {is_rhd ? rect.right() - rect.h / 2 : rect.x, rect.y, rect.h / 2, rect.h};
|
||||
|
||||
// blackout
|
||||
const int blackout_x = is_rhd ? rect.x : valid_rect.right();
|
||||
const int blackout_w = rect.w - valid_rect.w;
|
||||
NVGpaint gradient = nvgLinearGradient(s->vg, blackout_x, rect.y, blackout_x + blackout_w, rect.y,
|
||||
COLOR_BLACK_ALPHA(is_rhd ? 255 : 0), COLOR_BLACK_ALPHA(is_rhd ? 0 : 255));
|
||||
ui_fill_rect(s->vg, {blackout_x, rect.y, blackout_w, rect.h}, gradient);
|
||||
ui_fill_rect(s->vg, {blackout_x, rect.y, blackout_w, rect.h}, COLOR_BLACK_ALPHA(144));
|
||||
// border
|
||||
ui_draw_rect(s->vg, rect, bg_colors[STATUS_OFFROAD], 1);
|
||||
const int blackout_x_r = valid_rect.right();
|
||||
#ifndef QCOM2
|
||||
const int blackout_w_r = rect.right() - valid_rect.right();
|
||||
const int blackout_x_l = rect.x;
|
||||
#else
|
||||
const int blackout_w_r = s->viz_rect.right() - valid_rect.right();
|
||||
const int blackout_x_l = s->viz_rect.x;
|
||||
#endif
|
||||
const int blackout_w_l = valid_rect.x - blackout_x_l;
|
||||
ui_fill_rect(s->vg, {blackout_x_l, rect.y, blackout_w_l, rect.h}, COLOR_BLACK_ALPHA(144));
|
||||
ui_fill_rect(s->vg, {blackout_x_r, rect.y, blackout_w_r, rect.h}, COLOR_BLACK_ALPHA(144));
|
||||
|
||||
const bool face_detected = s->scene.driver_state.getFaceProb() > 0.4;
|
||||
if (face_detected) {
|
||||
@@ -494,13 +497,32 @@ static const mat4 device_transform = {{
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
|
||||
static const float driver_view_ratio = 1.333;
|
||||
#ifndef QCOM2
|
||||
// frame from 4/3 to 16/9 display
|
||||
static const mat4 full_to_wide_frame_transform = {{
|
||||
.75, 0.0, 0.0, 0.0,
|
||||
static const mat4 driver_view_transform = {{
|
||||
driver_view_ratio*(1080-2*bdr_s)/(1920-2*bdr_s), 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
#else
|
||||
// from dmonitoring.cc
|
||||
static const int full_width_tici = 1928;
|
||||
static const int full_height_tici = 1208;
|
||||
static const int adapt_width_tici = 668;
|
||||
static const int crop_x_offset = 32;
|
||||
static const int crop_y_offset = -196;
|
||||
static const float yscale = full_height_tici * driver_view_ratio / adapt_width_tici;
|
||||
static const float xscale = yscale*(1080-2*bdr_s)/(2160-2*bdr_s)*full_width_tici/full_height_tici;
|
||||
|
||||
static const mat4 driver_view_transform = {{
|
||||
xscale, 0.0, 0.0, xscale*crop_x_offset/full_width_tici*2,
|
||||
0.0, yscale, 0.0, yscale*crop_y_offset/full_height_tici*2,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
#endif
|
||||
|
||||
void ui_nvg_init(UIState *s) {
|
||||
// init drawing
|
||||
@@ -606,7 +628,7 @@ void ui_nvg_init(UIState *s) {
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
|
||||
s->front_frame_mat = matmul(device_transform, full_to_wide_frame_transform);
|
||||
s->front_frame_mat = matmul(device_transform, driver_view_transform);
|
||||
s->rear_frame_mat = matmul(device_transform, frame_transform);
|
||||
|
||||
// Apply transformation such that video pixel coordinates match video
|
||||
|
||||
Reference in New Issue
Block a user