Loading openflexure_microscope/camera/pi.py +11 −11 Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Raspberry Pi camera implementation of the StreamingCamera class. Raspberry Pi camera implementation of the PiCameraStreamer class. NOTES: Still port used for image capture Loading @@ -12,7 +12,7 @@ Video port: Splitter port 2: Video capture Splitter port 3: [Currently unused] StreamingCamera streams at video_resolution PiCameraStreamer streams at video_resolution Camera capture resolution set to stream_resolution in frames() Video port uses that resolution for everything. If a different resolution is specified for video capture, this is handled by the resizer. Loading Loading @@ -41,8 +41,8 @@ from .set_picamera_gain import set_analog_gain, set_digital_gain # MAIN CLASS class StreamingCamera(BaseCamera): """Raspberry Pi camera implementation of StreamingCamera.""" class PiCameraStreamer(BaseCamera): """Raspberry Pi camera implementation of PiCameraStreamer.""" picamera_settings_keys = [ 'exposure_mode', 'analog_gain', Loading @@ -61,7 +61,7 @@ class StreamingCamera(BaseCamera): # Attach to Pi camera self.camera = picamera.PiCamera() #: :py:class:`picamera.PiCamera`: Picamera object # Store state of StreamingCamera # Store state of PiCameraStreamer self.state.update({ 'stream_active': False, 'record_active': False, Loading @@ -87,7 +87,7 @@ class StreamingCamera(BaseCamera): pass def close(self): """Close the Raspberry Pi StreamingCamera.""" """Close the Raspberry Pi PiCameraStreamer.""" # Run BaseCamera close method BaseCamera.close(self) # Detach Pi camera Loading @@ -97,7 +97,7 @@ class StreamingCamera(BaseCamera): # HANDLE SETTINGS def read_config(self) -> dict: """ Return config dictionary of the StreamingCamera. Return config dictionary of the PiCameraStreamer. """ conf_dict = { Loading @@ -109,7 +109,7 @@ class StreamingCamera(BaseCamera): } # PiCamera parameters for key in StreamingCamera.picamera_settings_keys: for key in PiCameraStreamer.picamera_settings_keys: try: value = getattr(self.camera, key) logging.debug("Reading PiCamera().{}: {}".format(key, value)) Loading @@ -121,7 +121,7 @@ class StreamingCamera(BaseCamera): def apply_config(self, config: dict): """ Write a config dictionary to the StreamingCamera config. Write a config dictionary to the PiCameraStreamer config. The passed dictionary may contain other parameters not relevant to camera config. Eg. Passing a general config file will work fine. Loading @@ -132,7 +132,7 @@ class StreamingCamera(BaseCamera): # TODO: Include timing and batching logic when applying PiCamera settings paused_stream = False logging.debug("StreamingCamera: Applying config:") logging.debug("PiCameraStreamer: Applying config:") logging.debug(config) with self.lock: Loading @@ -150,7 +150,7 @@ class StreamingCamera(BaseCamera): if 'picamera_settings' in config: # If new settings are given self.apply_picamera_settings(config['picamera_settings'], pause_for_effect=True) # StreamingCamera parameters # PiCameraStreamer parameters for key, value in config.items(): # For each provided setting if (key != 'picamera_settings') and hasattr(self, key): setattr(self, key, value) Loading tests/test_camera.py +2 −2 Original line number Diff line number Diff line #!/usr/bin/env python from openflexure_microscope.camera.pi import StreamingCamera, CaptureObject from openflexure_microscope.camera.pi import PiCameraStreamer, CaptureObject import os import io Loading Loading @@ -279,7 +279,7 @@ class TestThreadStarting(unittest.TestCase): if __name__ == '__main__': with StreamingCamera() as camera: with PiCameraStreamer() as camera: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestCaptureMethods), Loading tests/test_plugins.py +2 −2 Original line number Diff line number Diff line #!/usr/bin/env python from openflexure_microscope.camera.pi import StreamingCamera from openflexure_microscope.camera.pi import PiCameraStreamer from openflexure_stage import OpenFlexureStage from openflexure_microscope import Microscope, config Loading Loading @@ -31,7 +31,7 @@ class TestPluginMethods(unittest.TestCase): if __name__ == '__main__': with Microscope(StreamingCamera(), OpenFlexureStage("/dev/ttyUSB0")) as microscope: with Microscope(PiCameraStreamer(), OpenFlexureStage("/dev/ttyUSB0")) as microscope: microscope.plugin.attach("openflexure_microscope.plugins.testing:Plugin") Loading Loading
openflexure_microscope/camera/pi.py +11 −11 Original line number Diff line number Diff line # -*- coding: utf-8 -*- """ Raspberry Pi camera implementation of the StreamingCamera class. Raspberry Pi camera implementation of the PiCameraStreamer class. NOTES: Still port used for image capture Loading @@ -12,7 +12,7 @@ Video port: Splitter port 2: Video capture Splitter port 3: [Currently unused] StreamingCamera streams at video_resolution PiCameraStreamer streams at video_resolution Camera capture resolution set to stream_resolution in frames() Video port uses that resolution for everything. If a different resolution is specified for video capture, this is handled by the resizer. Loading Loading @@ -41,8 +41,8 @@ from .set_picamera_gain import set_analog_gain, set_digital_gain # MAIN CLASS class StreamingCamera(BaseCamera): """Raspberry Pi camera implementation of StreamingCamera.""" class PiCameraStreamer(BaseCamera): """Raspberry Pi camera implementation of PiCameraStreamer.""" picamera_settings_keys = [ 'exposure_mode', 'analog_gain', Loading @@ -61,7 +61,7 @@ class StreamingCamera(BaseCamera): # Attach to Pi camera self.camera = picamera.PiCamera() #: :py:class:`picamera.PiCamera`: Picamera object # Store state of StreamingCamera # Store state of PiCameraStreamer self.state.update({ 'stream_active': False, 'record_active': False, Loading @@ -87,7 +87,7 @@ class StreamingCamera(BaseCamera): pass def close(self): """Close the Raspberry Pi StreamingCamera.""" """Close the Raspberry Pi PiCameraStreamer.""" # Run BaseCamera close method BaseCamera.close(self) # Detach Pi camera Loading @@ -97,7 +97,7 @@ class StreamingCamera(BaseCamera): # HANDLE SETTINGS def read_config(self) -> dict: """ Return config dictionary of the StreamingCamera. Return config dictionary of the PiCameraStreamer. """ conf_dict = { Loading @@ -109,7 +109,7 @@ class StreamingCamera(BaseCamera): } # PiCamera parameters for key in StreamingCamera.picamera_settings_keys: for key in PiCameraStreamer.picamera_settings_keys: try: value = getattr(self.camera, key) logging.debug("Reading PiCamera().{}: {}".format(key, value)) Loading @@ -121,7 +121,7 @@ class StreamingCamera(BaseCamera): def apply_config(self, config: dict): """ Write a config dictionary to the StreamingCamera config. Write a config dictionary to the PiCameraStreamer config. The passed dictionary may contain other parameters not relevant to camera config. Eg. Passing a general config file will work fine. Loading @@ -132,7 +132,7 @@ class StreamingCamera(BaseCamera): # TODO: Include timing and batching logic when applying PiCamera settings paused_stream = False logging.debug("StreamingCamera: Applying config:") logging.debug("PiCameraStreamer: Applying config:") logging.debug(config) with self.lock: Loading @@ -150,7 +150,7 @@ class StreamingCamera(BaseCamera): if 'picamera_settings' in config: # If new settings are given self.apply_picamera_settings(config['picamera_settings'], pause_for_effect=True) # StreamingCamera parameters # PiCameraStreamer parameters for key, value in config.items(): # For each provided setting if (key != 'picamera_settings') and hasattr(self, key): setattr(self, key, value) Loading
tests/test_camera.py +2 −2 Original line number Diff line number Diff line #!/usr/bin/env python from openflexure_microscope.camera.pi import StreamingCamera, CaptureObject from openflexure_microscope.camera.pi import PiCameraStreamer, CaptureObject import os import io Loading Loading @@ -279,7 +279,7 @@ class TestThreadStarting(unittest.TestCase): if __name__ == '__main__': with StreamingCamera() as camera: with PiCameraStreamer() as camera: suites = [ unittest.TestLoader().loadTestsFromTestCase(TestCaptureMethods), Loading
tests/test_plugins.py +2 −2 Original line number Diff line number Diff line #!/usr/bin/env python from openflexure_microscope.camera.pi import StreamingCamera from openflexure_microscope.camera.pi import PiCameraStreamer from openflexure_stage import OpenFlexureStage from openflexure_microscope import Microscope, config Loading Loading @@ -31,7 +31,7 @@ class TestPluginMethods(unittest.TestCase): if __name__ == '__main__': with Microscope(StreamingCamera(), OpenFlexureStage("/dev/ttyUSB0")) as microscope: with Microscope(PiCameraStreamer(), OpenFlexureStage("/dev/ttyUSB0")) as microscope: microscope.plugin.attach("openflexure_microscope.plugins.testing:Plugin") Loading