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.
CameraDriver._get_initial_resolutioncompares the resolution read fromthe config, which is a string, against
available_resolutions, which isa set of
Resolutionobjects:Resolution.__eq__returnsFalsefor anything that is not aResolution, and the hashes differ too, so the membership test nevermatches and the highest resolution is always used. The default branch
has the same problem, since it also builds a string.
PiCameraDriver._connectthen writes that value back intoself._config["resolution"], so the stored setting is overwritten andlost.
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._connectassignsself._config["resolution"]directly and never calls the function.Camera.settings_from_stringalready parses the string correctly;reusing that conversion here fixes it. Happy to open a PR if useful.