camerad: downscale C3XL OX03C10 to 1344x760

This commit is contained in:
Comma Device
2026-10-25 15:24:38 +08:00
parent bb68b59ed7
commit 00487741ec
6 changed files with 27 additions and 5 deletions
+9 -2
View File
@@ -10,6 +10,7 @@ class CameraConfig:
width: int
height: int
focal_length: float
focal_length_y: float | None = None
@property
def size(self):
@@ -18,9 +19,10 @@ 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, self.focal_length, float(self.height)/2],
[0.0, focal_length_y, float(self.height)/2],
[0.0, 0.0, 1.0]
])
@@ -49,6 +51,11 @@ 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())
@@ -67,7 +74,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_config), ('os04c10', _os_config)))
prods = itertools.product(('tici', 'tizi', 'mici'), (('ar0231', _ar_ox_config), ('ox03c10', _ar_ox_c3xl_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
Binary file not shown.
@@ -63,7 +63,8 @@ void CameraState::init(VisionIpcServer *v) {
if (!camera.enabled) return;
fl_pix = camera.cc.focal_len / camera.sensor->pixel_size_mm / camera.sensor->out_scale;
const float output_scale_x = static_cast<float>(camera.sensor->frame_width) / camera.buf.out_img_width;
fl_pix = camera.cc.focal_len / camera.sensor->pixel_size_mm / output_scale_x;
set_exposure_rect();
dc_gain_weight = camera.sensor->dc_gain_min_weight;
+2 -2
View File
@@ -280,8 +280,8 @@ void SpectraCamera::camera_open(VisionIpcServer *v) {
if (!enabled) return;
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;
buf.out_img_width = sensor->output_width();
buf.out_img_height = sensor->output_height();
// size is driven by all the HW that handles frames,
// the video encoder has certain alignment requirements in this case
@@ -34,6 +34,10 @@ 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));
+10
View File
@@ -28,6 +28,7 @@ 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;
@@ -85,6 +86,15 @@ public:
const int num() const {
return static_cast<int>(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 {