Skip to content

Conversation

Alexei-Kornienko
Copy link
Contributor

With a certain camera:

rpicam-hello --list-cameras
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/axi/pcie@120000/rp1/i2c@88000/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                             1640x1232 [41.85 fps - (0, 0)/3280x2464 crop]
                             1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                             3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]
           'SRGGB8' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                      1640x1232 [83.70 fps - (0, 0)/3280x2464 crop]
                      1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                      3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]

You cannot select exact sensor mode by providing a pixel format. Cause when I set pixel format to RGGB expecting to select SRGGB8 1640x1232 [83.70 fps - (0, 0)/3280x2464 crop] libcamera selects 'SRGGB10_CSI2P' 1640x1232 [41.85 fps - (0, 0)/3280x2464 crop] sensor mode cause it's fully compatible in every part (cause both of them are extended to RGGB16).

This struct allows to define a specific sensor configuration and provide it to camera configuration before validate call. It allows user to specify exact sensor mode that needs to be used:

        let mut cfgs = camera.generate_configuration(&[StreamRole::Raw])
            .context("generate camera configuration")?;

        let mut sensor_mode = SensorConfiguration::new();
        sensor_mode.set_bit_depth(SENSOR_BIT_DEPTH);
        sensor_mode.set_output_size(FRAME_WIDTH, FRAME_HEIGHT);
        cfgs.set_sensor_configuration(sensor_mode);

        let mut config = cfgs.get_mut(0).unwrap();
        config.set_pixel_format(PIXEL_FORMAT_RAW);
        config.set_size(Size { width: FRAME_WIDTH, height: FRAME_HEIGHT });
        config.set_buffer_count(NUM_BUFFERS);

        match cfgs.validate() {
            CameraConfigurationStatus::Valid => log::debug!("Camera configuration valid!"),
            CameraConfigurationStatus::Adjusted => log::debug!("Camera configuration was adjusted: {:#?}", cfgs),
            CameraConfigurationStatus::Invalid => bail!("Error validating camera configuration"),
        }

For my setup it does exactly what I want - select exact sensor mode.

This struct allows to define a specific sensor configuration and provide
it to camera configuration before validate call. It allows user to
specify exact sensor mode that needs to be used
@chemicstry chemicstry merged commit 764c498 into lit-robotics:main Sep 25, 2025
5 checks passed
@chemicstry
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants