diff --git a/openpilot/common/transformations/camera.py b/openpilot/common/transformations/camera.py index 6bec901f6..17ac226cd 100644 --- a/openpilot/common/transformations/camera.py +++ b/openpilot/common/transformations/camera.py @@ -10,7 +10,6 @@ class CameraConfig: width: int height: int focal_length: float - focal_length_y: float | None = None @property def size(self): @@ -19,10 +18,9 @@ class CameraConfig: @property def intrinsics(self): # aka 'K' aka camera_frame_from_view_frame - focal_length_y = self.focal_length if self.focal_length_y is None else self.focal_length_y return np.array([ [self.focal_length, 0.0, float(self.width)/2], - [0.0, focal_length_y, float(self.height)/2], + [0.0, self.focal_length, float(self.height)/2], [0.0, 0.0, 1.0] ]) @@ -51,11 +49,6 @@ class DeviceCameraConfig: _ar_ox_fisheye = CameraConfig(1928, 1208, 567.0) # focal length probably wrong? magnification is not consistent across frame _os_fisheye = CameraConfig(2688 // 2, 1520 // 2, 567.0 / 4 * 3) _ar_ox_config = DeviceCameraConfig(CameraConfig(1928, 1208, 2648.0), _ar_ox_fisheye, _ar_ox_fisheye) -# C3XL OX03C10 is resized to the mici 1344x760 frame in the ISP before modeld. -_ar_ox_c3xl_fisheye = CameraConfig(1344, 760, 567.0 * 1344 / 1928, 567.0 * 760 / 1208) -_ar_ox_c3xl_config = DeviceCameraConfig( - CameraConfig(1344, 760, 2648.0 * 1344 / 1928, 2648.0 * 760 / 1208), - _ar_ox_c3xl_fisheye, _ar_ox_c3xl_fisheye) _os_config = DeviceCameraConfig(CameraConfig(2688 // 2, 1520 // 2, 1522.0 * 3 / 4), _os_fisheye, _os_fisheye) _neo_config = DeviceCameraConfig(CameraConfig(1164, 874, 910.0), CameraConfig(816, 612, 650.0), _NoneCameraConfig()) @@ -74,7 +67,7 @@ DEVICE_CAMERAS: dict[tuple[str, str], DeviceCameraConfig] = { # simulator (emulates a tici) ("pc", "unknown"): _ar_ox_config, } -prods = itertools.product(('tici', 'tizi', 'mici'), (('ar0231', _ar_ox_config), ('ox03c10', _ar_ox_c3xl_config), ('os04c10', _os_config))) +prods = itertools.product(('tici', 'tizi', 'mici'), (('ar0231', _ar_ox_config), ('ox03c10', _ar_ox_config), ('os04c10', _os_config))) DEVICE_CAMERAS.update({(d, c[0]): c[1] for d, c in prods}) # device/mesh : x->forward, y-> right, z->down diff --git a/openpilot/system/camerad/camerad b/openpilot/system/camerad/camerad index 98378db6c..fdfd0da2f 100755 Binary files a/openpilot/system/camerad/camerad and b/openpilot/system/camerad/camerad differ diff --git a/openpilot/system/camerad/cameras/camera_qcom2.cc b/openpilot/system/camerad/cameras/camera_qcom2.cc index b00a3ef0e..4d30cd1e2 100644 --- a/openpilot/system/camerad/cameras/camera_qcom2.cc +++ b/openpilot/system/camerad/cameras/camera_qcom2.cc @@ -63,8 +63,7 @@ void CameraState::init(VisionIpcServer *v) { if (!camera.enabled) return; - const float output_scale_x = static_cast(camera.sensor->frame_width) / camera.buf.out_img_width; - fl_pix = camera.cc.focal_len / camera.sensor->pixel_size_mm / output_scale_x; + fl_pix = camera.cc.focal_len / camera.sensor->pixel_size_mm / camera.sensor->out_scale; set_exposure_rect(); dc_gain_weight = camera.sensor->dc_gain_min_weight; diff --git a/openpilot/system/camerad/cameras/spectra.cc b/openpilot/system/camerad/cameras/spectra.cc index 1a59d7c4c..2cbf3594c 100644 --- a/openpilot/system/camerad/cameras/spectra.cc +++ b/openpilot/system/camerad/cameras/spectra.cc @@ -280,8 +280,8 @@ void SpectraCamera::camera_open(VisionIpcServer *v) { if (!enabled) return; - buf.out_img_width = sensor->output_width(); - buf.out_img_height = sensor->output_height(); + buf.out_img_width = sensor->frame_width / sensor->out_scale; + buf.out_img_height = (sensor->hdr_offset > 0 ? (sensor->frame_height - sensor->hdr_offset) / 2 : sensor->frame_height) / sensor->out_scale; // size is driven by all the HW that handles frames, // the video encoder has certain alignment requirements in this case diff --git a/openpilot/system/camerad/sensors/ox03c10.cc b/openpilot/system/camerad/sensors/ox03c10.cc index 9dd10e7c5..e0e0dec2f 100644 --- a/openpilot/system/camerad/sensors/ox03c10.cc +++ b/openpilot/system/camerad/sensors/ox03c10.cc @@ -34,10 +34,6 @@ OX03C10::OX03C10() { frame_stride = (frame_width * 12 / 8) + 4; extra_height = 16; // top 2 + bot 14 frame_offset = 2; - // C3XL: match the mici model input resolution before modeld. This cuts the - // per-frame vision upload by about 49%; camera.py carries separate X/Y intrinsics. - out_width = 1344; - out_height = 760; start_reg_array.assign(std::begin(start_reg_array_ox03c10), std::end(start_reg_array_ox03c10)); init_reg_array.assign(std::begin(init_array_ox03c10), std::end(init_array_ox03c10)); diff --git a/openpilot/system/camerad/sensors/sensor.h b/openpilot/system/camerad/sensors/sensor.h index a9bd04de2..251f5d64b 100644 --- a/openpilot/system/camerad/sensors/sensor.h +++ b/openpilot/system/camerad/sensors/sensor.h @@ -28,7 +28,6 @@ public: uint32_t frame_stride; uint32_t frame_offset = 0; uint32_t extra_height = 0; - uint32_t out_width = 0, out_height = 0; // explicit ISP output; 0 keeps the legacy integer out_scale behavior int out_scale = 1; int registers_offset = -1; int stats_offset = -1; @@ -86,15 +85,6 @@ public: const int num() const { return static_cast(image_sensor); }; - - uint32_t output_width() const { - return out_width > 0 ? out_width : frame_width / out_scale; - } - - uint32_t output_height() const { - if (out_height > 0) return out_height; - return (hdr_offset > 0 ? (frame_height - hdr_offset) / 2 : frame_height) / out_scale; - } }; class OX03C10 : public SensorInfo {