Revert "dmonitoring/DriverView: get crop_rect & transform by video size (#23014)"
This reverts commit 1af715d6a2
.
pull/23170/head
parent
1af715d6a2
commit
b5fdf646ff
|
@ -1,8 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include "selfdrive/common/mat.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
||||
const int TRAJECTORY_SIZE = 33;
|
||||
const int LAT_MPC_N = 16;
|
||||
|
@ -38,14 +36,10 @@ const std::array<double, TRAJECTORY_SIZE> X_IDXS = {
|
|||
168.75 , 180.1875, 192.};
|
||||
const auto X_IDXS_FLOAT = convert_array_to_type<double, float, TRAJECTORY_SIZE>(X_IDXS);
|
||||
|
||||
const int TICI_CAM_WIDTH = 1928;
|
||||
|
||||
namespace tici_dm_crop {
|
||||
const int x_offset = -72;
|
||||
const int y_offset = -144;
|
||||
const int width = 954;
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "selfdrive/common/mat.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
const mat3 fcam_intrinsic_matrix =
|
||||
Hardware::EON() ? (mat3){{910., 0., 1164.0 / 2,
|
||||
0., 910., 874.0 / 2,
|
||||
|
@ -68,3 +62,5 @@ static inline mat3 get_model_yuv_transform(bool bayer = true) {
|
|||
}};
|
||||
return bayer ? transform_scale_buffer(transform, db_s) : transform;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "libyuv.h"
|
||||
|
||||
#include "selfdrive/common/mat.h"
|
||||
#include "selfdrive/common/modeldata.h"
|
||||
#include "selfdrive/common/params.h"
|
||||
#include "selfdrive/common/timing.h"
|
||||
#include "selfdrive/hardware/hw.h"
|
||||
|
@ -68,14 +67,21 @@ void crop_yuv(uint8_t *raw, int width, int height, uint8_t *y, uint8_t *u, uint8
|
|||
|
||||
DMonitoringResult dmonitoring_eval_frame(DMonitoringModelState* s, void* stream_buf, int width, int height) {
|
||||
Rect crop_rect;
|
||||
if (width == TICI_CAM_WIDTH) {
|
||||
const int cropped_height = tici_dm_crop::width / 1.33;
|
||||
crop_rect = {tici_dm_crop::x_offset + (width - tici_dm_crop::width) / 2,
|
||||
tici_dm_crop::y_offset + (height - cropped_height) / 2,
|
||||
cropped_height / 2, cropped_height};
|
||||
if (Hardware::TICI()) {
|
||||
const int full_width_tici = 1928;
|
||||
const int full_height_tici = 1208;
|
||||
const int adapt_width_tici = 954;
|
||||
const int x_offset_tici = -72;
|
||||
const int y_offset_tici = -144;
|
||||
const int cropped_height = adapt_width_tici / 1.33;
|
||||
crop_rect = {full_width_tici / 2 - adapt_width_tici / 2 + x_offset_tici,
|
||||
full_height_tici / 2 - cropped_height / 2 + y_offset_tici,
|
||||
cropped_height / 2,
|
||||
cropped_height};
|
||||
if (!s->is_rhd) {
|
||||
crop_rect.x += tici_dm_crop::width - crop_rect.w;
|
||||
crop_rect.x += adapt_width_tici - crop_rect.w;
|
||||
}
|
||||
|
||||
} else {
|
||||
const int adapt_width = 372;
|
||||
crop_rect = {0, 0, adapt_width, height};
|
||||
|
|
|
@ -51,22 +51,28 @@ const mat4 device_transform = {{
|
|||
0.0, 0.0, 0.0, 1.0,
|
||||
}};
|
||||
|
||||
mat4 get_driver_view_transform(int screen_width, int screen_height, int stream_width, int stream_height) {
|
||||
mat4 get_driver_view_transform() {
|
||||
const float driver_view_ratio = 1.333;
|
||||
mat4 transform;
|
||||
if (stream_width == TICI_CAM_WIDTH) {
|
||||
const float yscale = stream_height * driver_view_ratio / tici_dm_crop::width;
|
||||
const float xscale = yscale*screen_height/screen_width*stream_width/stream_height;
|
||||
if (Hardware::TICI()) {
|
||||
// from dmonitoring.cc
|
||||
const int full_width_tici = 1928;
|
||||
const int full_height_tici = 1208;
|
||||
const int adapt_width_tici = 954;
|
||||
const int crop_x_offset = -72;
|
||||
const int crop_y_offset = -144;
|
||||
const float yscale = full_height_tici * driver_view_ratio / adapt_width_tici;
|
||||
const float xscale = yscale*(1080)/(2160)*full_width_tici/full_height_tici;
|
||||
transform = (mat4){{
|
||||
xscale, 0.0, 0.0, xscale*tici_dm_crop::x_offset/stream_width*2,
|
||||
0.0, yscale, 0.0, yscale*tici_dm_crop::y_offset/stream_height*2,
|
||||
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,
|
||||
}};
|
||||
} else {
|
||||
// frame from 4/3 to 16/9 display
|
||||
transform = (mat4){{
|
||||
driver_view_ratio * screen_height / screen_width, 0.0, 0.0, 0.0,
|
||||
driver_view_ratio*(1080)/(1920), 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,
|
||||
|
@ -172,7 +178,7 @@ void CameraViewWidget::hideEvent(QHideEvent *event) {
|
|||
void CameraViewWidget::updateFrameMat(int w, int h) {
|
||||
if (zoomed_view) {
|
||||
if (stream_type == VISION_STREAM_RGB_FRONT) {
|
||||
frame_mat = matmul(device_transform, get_driver_view_transform(w, h, stream_width, stream_height));
|
||||
frame_mat = matmul(device_transform, get_driver_view_transform());
|
||||
} else {
|
||||
auto intrinsic_matrix = stream_type == VISION_STREAM_RGB_WIDE ? ecam_intrinsic_matrix : fcam_intrinsic_matrix;
|
||||
float zoom = ZOOM / intrinsic_matrix.v[0];
|
||||
|
|
Loading…
Reference in New Issue