|
|
@ -263,19 +263,22 @@ static void ui_draw_vision_face(UIState *s) { |
|
|
|
static void ui_draw_driver_view(UIState *s) { |
|
|
|
static void ui_draw_driver_view(UIState *s) { |
|
|
|
s->sidebar_collapsed = true; |
|
|
|
s->sidebar_collapsed = true; |
|
|
|
const bool is_rhd = s->scene.is_rhd; |
|
|
|
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 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}; |
|
|
|
const Rect valid_rect = {is_rhd ? rect.right() - rect.h / 2 : rect.x, rect.y, rect.h / 2, rect.h}; |
|
|
|
|
|
|
|
|
|
|
|
// blackout
|
|
|
|
// blackout
|
|
|
|
const int blackout_x = is_rhd ? rect.x : valid_rect.right(); |
|
|
|
const int blackout_x_r = valid_rect.right(); |
|
|
|
const int blackout_w = rect.w - valid_rect.w; |
|
|
|
#ifndef QCOM2 |
|
|
|
NVGpaint gradient = nvgLinearGradient(s->vg, blackout_x, rect.y, blackout_x + blackout_w, rect.y, |
|
|
|
const int blackout_w_r = rect.right() - valid_rect.right(); |
|
|
|
COLOR_BLACK_ALPHA(is_rhd ? 255 : 0), COLOR_BLACK_ALPHA(is_rhd ? 0 : 255)); |
|
|
|
const int blackout_x_l = rect.x; |
|
|
|
ui_fill_rect(s->vg, {blackout_x, rect.y, blackout_w, rect.h}, gradient); |
|
|
|
#else |
|
|
|
ui_fill_rect(s->vg, {blackout_x, rect.y, blackout_w, rect.h}, COLOR_BLACK_ALPHA(144)); |
|
|
|
const int blackout_w_r = s->viz_rect.right() - valid_rect.right(); |
|
|
|
// border
|
|
|
|
const int blackout_x_l = s->viz_rect.x; |
|
|
|
ui_draw_rect(s->vg, rect, bg_colors[STATUS_OFFROAD], 1); |
|
|
|
#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; |
|
|
|
const bool face_detected = s->scene.driver_state.getFaceProb() > 0.4; |
|
|
|
if (face_detected) { |
|
|
|
if (face_detected) { |
|
|
@ -494,13 +497,32 @@ static const mat4 device_transform = {{ |
|
|
|
0.0, 0.0, 0.0, 1.0, |
|
|
|
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
|
|
|
|
// frame from 4/3 to 16/9 display
|
|
|
|
static const mat4 full_to_wide_frame_transform = {{ |
|
|
|
static const mat4 driver_view_transform = {{ |
|
|
|
.75, 0.0, 0.0, 0.0, |
|
|
|
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, 1.0, 0.0, 0.0, |
|
|
|
0.0, 0.0, 1.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, 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) { |
|
|
|
void ui_nvg_init(UIState *s) { |
|
|
|
// init drawing
|
|
|
|
// init drawing
|
|
|
@ -606,7 +628,7 @@ void ui_nvg_init(UIState *s) { |
|
|
|
0.0, 0.0, 0.0, 1.0, |
|
|
|
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); |
|
|
|
s->rear_frame_mat = matmul(device_transform, frame_transform); |
|
|
|
|
|
|
|
|
|
|
|
// Apply transformation such that video pixel coordinates match video
|
|
|
|
// Apply transformation such that video pixel coordinates match video
|
|
|
|