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