Complete UI for arbitrary dectector settings. Required better method for invoking actions.
Error handling was fixed in the process of getting the above correct.
This commit is contained in:
parent
92d15d921b
commit
33413a591a
5 changed files with 102 additions and 25 deletions
|
|
@ -8,7 +8,7 @@ current camera field of view contains sample.
|
|||
from typing import Optional, Any
|
||||
import cv2
|
||||
import numpy as np
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from pydantic.errors import PydanticUserError
|
||||
from scipy.stats import norm
|
||||
from labthings_fastapi.thing_description import type_to_dataschema
|
||||
|
|
@ -153,13 +153,18 @@ class ChannelDistributions(BaseModel):
|
|||
class ColourChannelDetectSettings(BaseModel):
|
||||
"""A BaseModel for storing the settings for colour channel detectors."""
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
channel_tolerance: float = 7.0
|
||||
"""Channel Tolerance
|
||||
|
||||
The number of standard deviations a pixel value must be from the background mean
|
||||
to be considered sample.
|
||||
"""
|
||||
min_sample_coverage: float = 25.0
|
||||
|
||||
# Use Field to set Title reported to UI. By default Pydantic will convert the name
|
||||
# from snake_case to Title Case.
|
||||
min_sample_coverage: float = Field(25, title="Sample Coverage Required (%)")
|
||||
"""Sample Coverage Required (%)
|
||||
|
||||
The minimum percentage of the image that needs to be identified as sample for the
|
||||
|
|
|
|||
|
|
@ -516,6 +516,20 @@ class BaseCamera(lt.Thing):
|
|||
"""The status of the active detector for the UI."""
|
||||
return self.active_detector.status
|
||||
|
||||
@lt.thing_action
|
||||
def update_detector_settings(self, data) -> None:
|
||||
"""Update the settings of the current detector.
|
||||
|
||||
This is an action not a setting/property as the data model depends on the
|
||||
selected detector. As such, it cannot be specified with the necessary precision
|
||||
to be included in a ThingDescription as a setting/property, while retaining
|
||||
enough useful information to communicate to the UI how it is set and read.
|
||||
|
||||
The information on how to read the settings is exposed in
|
||||
``background_detector_status``.
|
||||
"""
|
||||
self.active_detector.settings = data
|
||||
|
||||
@lt.thing_setting
|
||||
def background_detector_data(self) -> dict:
|
||||
"""The data for each background detector, used to save to disk."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue