Skip to content

Commit

Permalink
BUG: Specify stream name for resolution (and image) in Picamera2Camera
Browse files Browse the repository at this point in the history
  • Loading branch information
vaughantnrc committed Jul 19, 2024
1 parent 7e9a6fd commit 3f67573
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/detector/implementations/camera_picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

_CAMERA_RESOLUTION_KEY: Final[str] = "size"

_CAMERA_STREAM: Final[str] = "main"
_CAMERA_CONTROLS_KEY: Final[str] = "controls"
_CAMERA_FPS_KEY: Final[str] = "FramesPerSecond"
_CAMERA_FPS_DEFAULT: Final[float] = 30.0
Expand Down Expand Up @@ -104,10 +105,6 @@ def get_image(self) -> numpy.ndarray:
raise MCTDetectorRuntimeError(message="There is no captured image.")
return self._image

def get_resolution(self) -> ImageResolution:
resolution: tuple[int, int] = self._camera_configuration[_CAMERA_RESOLUTION_KEY]
return ImageResolution(x_px=resolution[0], y_px=resolution[1])

def get_parameters(self, **_kwargs) -> list[KeyValueMetaAbstract]:
if self.get_status() != CameraStatus.RUNNING:
raise MCTDetectorRuntimeError(message="The capture is not active, and properties cannot be retrieved.")
Expand Down Expand Up @@ -170,6 +167,10 @@ def get_parameters(self, **_kwargs) -> list[KeyValueMetaAbstract]:

return return_value

def get_resolution(self) -> ImageResolution:
resolution: tuple[int, int] = self._camera_configuration[_CAMERA_STREAM][_CAMERA_RESOLUTION_KEY]
return ImageResolution(x_px=resolution[0], y_px=resolution[1])

@staticmethod
def get_type_identifier() -> str:
return "picamera2"
Expand Down Expand Up @@ -268,7 +269,7 @@ def stop(self) -> None:
self._camera.stop()

def update(self) -> None:
self._image = self._camera.capture_array()
self._image = self._camera.capture_array(_CAMERA_STREAM)

if self._image is None:
message: str = "Failed to grab frame."
Expand Down

0 comments on commit 3f67573

Please sign in to comment.