Skip to content

Commit eba0dec

Browse files
committed
SimulatedCamera: new sensor_shape argument instead of hardcoding (512, 512).
1 parent 4bd0ddc commit eba0dec

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

NEWS.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Version 0.7.0 (upcoming)
2828
accidentally changed from "strobed" to "trig. first". This has
2929
now been reversed.
3030

31+
* `SimulatedCamera` now takes an optional `sensor_shape` constructor
32+
argument instead of always being 512x512 pixels.
33+
3134
* The device server logging was broken in version 0.6.0 for Windows
3235
and macOS (systems not using fork for multiprocessing). This
3336
version fixes that issue.

microscope/simulators/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import random
3030
import time
3131
import typing
32+
from typing import Tuple
3233

3334
import numpy as np
3435
from PIL import Image, ImageDraw, ImageFont
@@ -154,10 +155,11 @@ def sawtooth(self, w, h, dark, light):
154155
class SimulatedCamera(
155156
microscope._utils.OnlyTriggersOnceOnSoftwareMixin, microscope.abc.Camera
156157
):
157-
def __init__(self, **kwargs):
158+
def __init__(self, sensor_shape: Tuple[int, int] = (512, 512), **kwargs):
158159
super().__init__(**kwargs)
159160
# Binning and ROI
160-
self._roi = microscope.ROI(0, 0, 512, 512)
161+
self._sensor_shape = sensor_shape
162+
self._roi = microscope.ROI(0, 0, *sensor_shape)
161163
self._binning = microscope.Binning(1, 1)
162164
# Function used to generate test image
163165
self._image_generator = _ImageGenerator()
@@ -278,7 +280,7 @@ def get_cycle_time(self):
278280
return self._exposure_time
279281

280282
def _get_sensor_shape(self):
281-
return (512, 512)
283+
return self._sensor_shape
282284

283285
def soft_trigger(self):
284286
# deprecated, use self.trigger()

0 commit comments

Comments
 (0)