Moved autofocus plugin to its own module
This commit is contained in:
parent
a6791d55ac
commit
4450ee132e
5 changed files with 4 additions and 27 deletions
|
|
@ -1 +0,0 @@
|
|||
from .plugin import Plugin
|
||||
|
|
@ -0,0 +1 @@
|
|||
from .plugin import AutofocusPlugin
|
||||
|
|
@ -7,20 +7,6 @@ from flask import request, Response, escape, jsonify
|
|||
|
||||
import logging
|
||||
|
||||
|
||||
class IdentifyAPI(MicroscopeViewPlugin):
|
||||
"""
|
||||
A simple example API plugin, attached through the main microscope plugin.
|
||||
"""
|
||||
def get(self):
|
||||
"""
|
||||
Default plugin to return a plaintext representation of the camera and stage objects.
|
||||
|
||||
.. :quickref: Default plugin; Identify hardware
|
||||
"""
|
||||
data = self.microscope.plugin.default.identify() # Call a method from our plugin, using the full route
|
||||
return Response(escape(data))
|
||||
|
||||
class MeasureSharpnessAPI(MicroscopeViewPlugin):
|
||||
def post(self):
|
||||
payload = JsonPayload(request)
|
||||
|
|
@ -5,28 +5,19 @@ from openflexure_microscope.plugins import MicroscopePlugin
|
|||
from openflexure_microscope.utilities import set_properties
|
||||
|
||||
from .focus_utils import sharpness_sum_lap2
|
||||
from .api import IdentifyAPI, MeasureSharpnessAPI, AutofocusAPI
|
||||
from .api import MeasureSharpnessAPI, AutofocusAPI
|
||||
|
||||
|
||||
class Plugin(MicroscopePlugin):
|
||||
class AutofocusPlugin(MicroscopePlugin):
|
||||
"""
|
||||
A set of default plugins
|
||||
Basic autofocus plugin
|
||||
"""
|
||||
|
||||
api_views = {
|
||||
'/identify': IdentifyAPI,
|
||||
'/measure_sharpness': MeasureSharpnessAPI,
|
||||
'/autofocus': AutofocusAPI,
|
||||
}
|
||||
|
||||
def identify(self):
|
||||
"""
|
||||
Demonstrate access to Microscope.camera, and Microscope.stage
|
||||
"""
|
||||
|
||||
response = "My parent camera is {}, and my parent stage is {}.".format(self.microscope.camera, self.microscope.stage)
|
||||
return response
|
||||
|
||||
def autofocus(self, dz, settle=0.5, metric_fn=sharpness_sum_lap2):
|
||||
"""Perform a simple autofocus routine.
|
||||
The stage is moved to z positions (relative to current position) in dz,
|
||||
Loading…
Add table
Add a link
Reference in a new issue