Camera view selection

Added toggle to select the preferred camera view between "auto", "standard", "wide", and "driver".
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent e20aaf75e5
commit 4b511bb036
7 changed files with 19 additions and 2 deletions

View File

@@ -217,6 +217,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"AlwaysOnLateralMain", PERSISTENT},
{"ApiCache_DriveStats", PERSISTENT},
{"BlindSpotPath", PERSISTENT},
{"CameraView", PERSISTENT},
{"CustomAlerts", PERSISTENT},
{"CustomUI", PERSISTENT},
{"DecelerationProfile", PERSISTENT},

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -11,6 +11,8 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
{"WarningSoftVolume", "Warning Soft Volume", "Related alerts:\n\nBRAKE!, Risk of Collision\nTAKE CONTROL IMMEDIATELY", ""},
{"WarningImmediateVolume", "Warning Immediate Volume", "Related alerts:\n\nDISENGAGE IMMEDIATELY, Driver Distracted\nDISENGAGE IMMEDIATELY, Driver Unresponsive", ""},
{"CameraView", "Camera View", "Choose your preferred camera view for the onroad UI. This is a visual change only and doesn't impact openpilot.", "../frogpilot/assets/toggle_icons/icon_camera.png"},
{"CustomAlerts", "Custom Alerts", "Enable custom alerts for various logic or situational changes.", "../frogpilot/assets/toggle_icons/icon_green_light.png"},
{"CustomUI", "Custom Onroad UI", "Customize the Onroad UI with some additional visual functions.", "../assets/offroad/icon_road.png"},
@@ -40,6 +42,11 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map<int, QString>(), this, false, "%");
}
} else if (param == "CameraView") {
std::vector<QString> cameraOptions{tr("Auto"), tr("Standard"), tr("Wide"), tr("Driver")};
FrogPilotButtonParamControl *preferredCamera = new FrogPilotButtonParamControl(param, title, desc, icon, cameraOptions);
toggle = preferredCamera;
} else if (param == "CustomAlerts") {
FrogPilotParamManageControl *customAlertsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this);
QObject::connect(customAlertsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() {

View File

@@ -659,7 +659,7 @@ void AnnotatedCameraWidget::paintGL() {
// Wide or narrow cam dependent on speed
bool has_wide_cam = available_streams.count(VISION_STREAM_WIDE_ROAD);
if (has_wide_cam) {
if (has_wide_cam && cameraView == 0) {
float v_ego = sm["carState"].getCarState().getVEgo();
if ((v_ego < 10) || available_streams.size() == 1) {
wide_cam_requested = true;
@@ -670,7 +670,9 @@ void AnnotatedCameraWidget::paintGL() {
// for replay of old routes, never go to widecam
wide_cam_requested = wide_cam_requested && s->scene.calibration_wide_valid;
}
CameraWidget::setStreamType(wide_cam_requested ? VISION_STREAM_WIDE_ROAD : VISION_STREAM_ROAD);
CameraWidget::setStreamType(cameraView == 3 ? VISION_STREAM_DRIVER :
cameraView == 2 || wide_cam_requested ? VISION_STREAM_WIDE_ROAD :
VISION_STREAM_ROAD);
s->scene.wide_cam = CameraWidget::getStreamType() == VISION_STREAM_WIDE_ROAD;
if (s->scene.calibration_valid) {
@@ -758,6 +760,8 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
blindSpotLeft = scene.blind_spot_left;
blindSpotRight = scene.blind_spot_right;
cameraView = scene.camera_view;
experimentalMode = scene.experimental_mode;
if (alwaysOnLateral) {

View File

@@ -124,6 +124,8 @@ private:
bool blindSpotRight;
bool experimentalMode;
int cameraView;
protected:
void paintGL() override;
void initializeGL() override;

View File

@@ -260,6 +260,7 @@ void ui_update_frogpilot_params(UIState *s) {
UIScene &scene = s->scene;
scene.always_on_lateral = params.getBool("AlwaysOnLateral");
scene.camera_view = params.getInt("CameraView");
bool custom_onroad_ui = params.getBool("CustomUI");
scene.acceleration_path = custom_onroad_ui && params.getBool("AccelerationPath");

View File

@@ -181,6 +181,8 @@ typedef struct UIScene {
float lane_width_left;
float lane_width_right;
int camera_view;
QPolygonF track_adjacent_vertices[6];
} UIScene;