Skip to content

Configured camera resolution is ignored, cameras always start at their maximum #323

Description

@Moret84

CameraDriver._get_initial_resolution compares the resolution read from
the config, which is a string, against available_resolutions, which is
a set of Resolution objects:

configured_resolution = config.get("resolution", str(highest_resolution))
if configured_resolution not in available_resolutions:
    configured_resolution = highest_resolution

Resolution.__eq__ returns False for anything that is not a
Resolution, and the hashes differ too, so the membership test never
matches and the highest resolution is always used. The default branch
has the same problem, since it also builds a string.

>>> avail = {Resolution(1600, 1200), Resolution(3280, 2464)}
>>> print(CameraDriver._get_initial_resolution(avail, {"resolution": "1600x1200"}))
3280x2464

PiCameraDriver._connect then writes that value back into
self._config["resolution"], so the stored setting is overwritten and
lost.

On a Raspberry Pi 3B+ with an IMX219 this means an 8 MP capture on every
snapshot instead of the configured 1600x1200. Seen on 0.8.1, still
present on master (24f7f5f).

The suite does not catch it because DummyDriver._connect assigns
self._config["resolution"] directly and never calls the function.

Camera.settings_from_string already parses the string correctly;
reusing that conversion here fixes it. Happy to open a PR if useful.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions