From 53655e137271b315637d36ca9c6e42305bc07707 Mon Sep 17 00:00:00 2001 From: consti10 Date: Fri, 16 Feb 2024 21:10:57 +0100 Subject: [PATCH] update default resolution(s) --- app/telemetry/models/openhd_core/camera.hpp | 164 +++++++++++++------- 1 file changed, 109 insertions(+), 55 deletions(-) diff --git a/app/telemetry/models/openhd_core/camera.hpp b/app/telemetry/models/openhd_core/camera.hpp index 1a04163a1..b3efb440b 100644 --- a/app/telemetry/models/openhd_core/camera.hpp +++ b/app/telemetry/models/openhd_core/camera.hpp @@ -5,11 +5,12 @@ #ifndef OPENHD_CAMERA_HPP #define OPENHD_CAMERA_HPP +#include +#include #include #include #include #include -#include /** * NOTE: This file is copied into QOpenHD to populate the UI. @@ -51,8 +52,8 @@ static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_RPIF_V3_IMX708 = 32; static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_RPIF_HQ_IMX477 = 33; // .... 5 reserved for future use // Now to all the rpi libcamera arducam cameras -static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYMASTERHDR = 40; -static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYVISIONPRO = 41; +static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYMASTERHDR_IMX708 = 40; +static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYVISIONPRO_IMX519 = 41; static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX477M = 42; static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX462 = 43; static constexpr int X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX327 = 44; @@ -77,7 +78,7 @@ static constexpr int X_CAM_TYPE_ROCK_HDMI_IN = 80; static constexpr int X_CAM_TYPE_ROCK_IMX219 = 81; // // OpenIPC specific starts here -static constexpr int X_CAM_TYPE_OPENIPC_SOMETHING=90; +static constexpr int X_CAM_TYPE_OPENIPC_SOMETHING = 90; // // ... rest is reserved for future use @@ -110,9 +111,9 @@ static std::string x_cam_type_to_string(int camera_type) { return "RPIF_V3_IMX708"; case X_CAM_TYPE_RPI_LIBCAMERA_RPIF_HQ_IMX477: return "RPIF_HQ_IMX477"; - case X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYMASTERHDR: + case X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYMASTERHDR_IMX708: return "ARDUCAM_SKYMASTERHDR"; - case X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYVISIONPRO: + case X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYVISIONPRO_IMX519: return "ARDUCAM_SKYVISIONPRO"; case X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX477M: return "ARDUCAM_IMX477M"; @@ -156,9 +157,9 @@ struct ResolutionFramerate { int width_px; int height_px; int fps; - std::string as_string()const{ + std::string as_string() const { std::stringstream ss; - ss< get_supported_resolutions() const { if (requires_rpi_veye_pipeline()) { - // Veye camera(s) only do 1080p30 + // Except one, all veye camera(s) only do 1080p30 - + // Urghs but not via v4l2. So we only expose 1080p30 + /*if(camera_type==X_CAM_TYPE_RPI_V4L2_VEYE_CSIMX307){ + std::vector ret; + ret.push_back(ResolutionFramerate{640, 480, 90}); + ret.push_back(ResolutionFramerate{1280, 720, 50}); + ret.push_back(ResolutionFramerate{1280, 720, 60}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + }else{ + return {ResolutionFramerate{1920, 1080, 30}}; + }*/ return {ResolutionFramerate{1920, 1080, 30}}; } else if (requires_x20_cedar_pipeline()) { // also easy, 720p60 only (for now) return {ResolutionFramerate{1280, 720, 60}}; } else if (camera_type == X_CAM_TYPE_USB_INFIRAY) { - return {ResolutionFramerate{384,292,25}}; - } else if(camera_type==X_CAM_TYPE_USB_GENERIC){ + return {ResolutionFramerate{384, 292, 25}}; + } else if (camera_type == X_CAM_TYPE_USB_GENERIC) { // Return what's most likely going to work return {ResolutionFramerate{640, 480, 30}}; } else if (requires_rpi_libcamera_pipeline()) { std::vector ret; - ret.push_back(ResolutionFramerate{640, 480, 60}); - ret.push_back(ResolutionFramerate{1280, 720, 60}); - ret.push_back(ResolutionFramerate{1920, 1080, 30}); + if(camera_type==X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX462 || + camera_type==X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX462_LOWLIGHT_MINI){ + ret.push_back(ResolutionFramerate{640, 480, 60}); + ret.push_back(ResolutionFramerate{896, 504, 60}); + ret.push_back(ResolutionFramerate{1280, 720, 60}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + }else if(camera_type==X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX477M || + camera_type==X_CAM_TYPE_RPI_LIBCAMERA_RPIF_HQ_IMX477) { + ret.push_back(ResolutionFramerate{640, 480, 50}); + ret.push_back(ResolutionFramerate{896, 504, 50}); + ret.push_back(ResolutionFramerate{1280, 720, 50}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + }else if(camera_type==X_CAM_TYPE_RPI_LIBCAMERA_RPIF_V2_IMX219){ + ret.push_back(ResolutionFramerate{640, 480, 47}); + ret.push_back(ResolutionFramerate{896, 504, 47}); + ret.push_back(ResolutionFramerate{1280, 720, 47}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + }else if(camera_type==X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYVISIONPRO_IMX519){ + ret.push_back(ResolutionFramerate{640, 480, 60}); + ret.push_back(ResolutionFramerate{896, 504, 60}); + ret.push_back(ResolutionFramerate{1280, 720, 60}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + }else if(camera_type==X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_SKYMASTERHDR_IMX708 || + camera_type==X_CAM_TYPE_RPI_LIBCAMERA_RPIF_V3_IMX708){ + ret.push_back(ResolutionFramerate{640, 480, 60}); + ret.push_back(ResolutionFramerate{896, 504, 60}); + ret.push_back(ResolutionFramerate{1280, 720, 60}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + }else if(camera_type==X_CAM_TYPE_RPI_LIBCAMERA_ARDUCAM_IMX327) { + ret.push_back(ResolutionFramerate{640, 480, 60}); + ret.push_back(ResolutionFramerate{896, 504, 60}); + ret.push_back(ResolutionFramerate{1280, 720, 60}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + }else if(camera_type==X_CAM_TYPE_RPI_LIBCAMERA_RPIF_V1_OV5647){ + ret.push_back(ResolutionFramerate{1280, 720, 30}); + ret.push_back(ResolutionFramerate{1920, 1080, 30}); + } + else{ + std::cerr<<"Not yet mapped:"< ret; @@ -223,17 +272,17 @@ struct XCamera { ret.push_back(ResolutionFramerate{1920, 1080, 25}); ret.push_back(ResolutionFramerate{1280, 720, 60}); return ret; - }else if(camera_type==X_CAM_TYPE_DUMMY_SW){ + } else if (camera_type == X_CAM_TYPE_DUMMY_SW) { std::vector ret; - ret.push_back(ResolutionFramerate{640,480,30}); - ret.push_back(ResolutionFramerate{1280,720,30}); - ret.push_back(ResolutionFramerate{1280,720,60}); + ret.push_back(ResolutionFramerate{640, 480, 30}); + ret.push_back(ResolutionFramerate{1280, 720, 30}); + ret.push_back(ResolutionFramerate{1280, 720, 60}); return ret; - }else if(camera_type==X_CAM_TYPE_DEVELOPMENT_FILESRC){ + } else if (camera_type == X_CAM_TYPE_DEVELOPMENT_FILESRC) { std::vector ret; - ret.push_back(ResolutionFramerate{848,480,60}); - ret.push_back(ResolutionFramerate{1280,720,60}); - ret.push_back(ResolutionFramerate{1920,1080,60}); + ret.push_back(ResolutionFramerate{848, 480, 60}); + ret.push_back(ResolutionFramerate{1280, 720, 60}); + ret.push_back(ResolutionFramerate{1920, 1080, 60}); return ret; } // Not mapped yet @@ -242,8 +291,8 @@ struct XCamera { } // We default to the last supported resolution [[nodiscard]] ResolutionFramerate get_default_resolution_fps() const { - auto supported_resolutions=get_supported_resolutions(); - return supported_resolutions.at(supported_resolutions.size()-1); + auto supported_resolutions = get_supported_resolutions(); + return supported_resolutions.at(supported_resolutions.size() - 1); } }; @@ -252,32 +301,29 @@ static bool is_valid_primary_cam_type(int cam_type) { return false; } static bool is_valid_secondary_cam_type(int cam_type) { - if (cam_type == X_CAM_TYPE_DUMMY_SW || - cam_type == X_CAM_TYPE_USB_INFIRAY || - cam_type==X_CAM_TYPE_USB_GENERIC || - cam_type == X_CAM_TYPE_EXTERNAL || - cam_type == X_CAM_TYPE_EXTERNAL_IP || - cam_type == X_CAM_TYPE_DISABLED) { + if (cam_type == X_CAM_TYPE_DUMMY_SW || cam_type == X_CAM_TYPE_USB_INFIRAY || + cam_type == X_CAM_TYPE_USB_GENERIC || cam_type == X_CAM_TYPE_EXTERNAL || + cam_type == X_CAM_TYPE_EXTERNAL_IP || cam_type == X_CAM_TYPE_DISABLED) { return true; } return false; } static bool is_rpi_csi_camera(int cam_type) { - return cam_type >= 10 && cam_type <= 59; + return cam_type >= 20 && cam_type <= 69; } - -static bool supports_rotation(int cam_type){ - return is_rpi_csi_camera(cam_type); +static bool is_rock_csi_camera(int cam_type) { + return cam_type == X_CAM_TYPE_ROCK_IMX219; } -static bool is_usb_camera(int cam_type){ - return cam_type>=10 && cam_type<19; +static bool is_usb_camera(int cam_type) { + return cam_type >= 10 && cam_type < 19; } // Takes a string in the from {width}x{height}@{framerate} // e.g. 1280x720@30 -static std::optional parse_video_format(const std::string& videoFormat){ +static std::optional parse_video_format( + const std::string& videoFormat) { if (videoFormat.size() <= 5) { return std::nullopt; } @@ -299,29 +345,37 @@ static std::optional parse_video_format(const std::string& // // Used in QOpenHD UI // -static std::string get_verbose_string_of_resolution(const ResolutionFramerate& resolution_framerate){ - if(resolution_framerate.width_px==0 && resolution_framerate.height_px==0 && resolution_framerate.fps==0){ +static std::string get_verbose_string_of_resolution( + const ResolutionFramerate& resolution_framerate) { + if (resolution_framerate.width_px == 0 && + resolution_framerate.height_px == 0 && resolution_framerate.fps == 0) { return "AUTO"; } std::stringstream ss; - if(resolution_framerate.width_px==640 && resolution_framerate.height_px==480){ - ss<<"VGA 4:3"; - }else if(resolution_framerate.width_px==848 && resolution_framerate.height_px==480){ - ss<<"VGA 16:9"; - }else if(resolution_framerate.width_px==896 && resolution_framerate.height_px== 504){ - ss<<"SD 16:9"; - }else if(resolution_framerate.width_px==1280 && resolution_framerate.height_px==720){ - ss<<"HD 16:9"; - }else if(resolution_framerate.width_px==1920 && resolution_framerate.height_px==1080){ - ss<<"FHD 16:9"; - }else if(resolution_framerate.width_px==2560 && resolution_framerate.height_px==1440){ - ss<<"2K 16:9"; - }else{ - ss<