RodTracker.ui.detection¶
TBD
- class DetectorUI(ui: QWidget, image_managers: List[ImageData], *args, **kwargs)[source]¶
Bases:
QWidgetA custom
QWidgetto interface with a neural network for rod detection.- Parameters
ui (QWidget) – Widget containing the tab that is the GUI for the detection functionality.
image_managers (List[ImageData]) – List of (relevant) image data management objects providing access to loaded image datasets.
*args (Iterable) – Positional arguments for the
QWidgetsuperclass.**kwargs (dict) – Keyword arguments for the
QWidgetsuperclass.
- model¶
Neural network model that is used for detection.
Default is
None.- Type
ScriptModule
Signals
- _progress_update(val: float, data: DataFrame, cam_id: str)[source]¶
Accepts progress reports of a detection process, logs and propagates them.
- Parameters
val (float) – Progression value of the detection process/thread \(\in [0, 1]\).
data (pd.DataFrame) – The
DataFramecontaining the detected 2D particle position data as well as the frame, color and particle numbers.cam_id (str) – ID of the
ImageDataobject for which the detection process was started.
- add_color_row(color: str, amount: int, c_class: Optional[int] = None)[source]¶
Add a new row to those used for the next rod detection.
- Parameters
color (str) – Human readable name of the class.
amount (int) – Number of particles that shall be detected per frame.
c_class (int, optional) –
Class identifier used by the detection model.
By default
None.
- detected_data¶
Sends data of detected rods for one frame.
This signal is emitted once for every image during the detection process. The
DataFramein the payload only contains 2D position data as well as the frame, color and particle numbers.See also
- Type
pyqtSignal(DataFrame)
- end_frame: int = 0¶
Last frame for detecting particles in it.
Default is
0.- Type
int
- images_loaded(num_imgs: int, id: str, path)[source]¶
Hook to update the available frame range for detection.
This function is intended as a slot for the
data_loadedsignal which in this case acts as an indicator for new image data availability. The available range of frames is updated with the information stored in the object, that emitted the signal.- Parameters
num_imgs (int) – Variable to match the
data_loadedsignal signature. Otherwise not used.id (str) – ID of the image management object, that has updated its loaded dataset. This object is then used for updating the available frames for detection of particles.
path (Any) – Variable to match the
data_loadedsignal signature. Otherwise not used.
- Returns
None
- is_busy¶
Notifies when a background task is started/finished.
- Type
pyqtSignal(bool)
- load_model()[source]¶
Show a file selection dialog to a user to select a particle detection model.
Lets the user select a
*.ptfile that should contain their desired particle detection model. The file is then loaded and the contained model set for use in the next detection(s).- Returns
None
See also
- number_rods: int = 1¶
Expected number of rods per color in one frame.
Default is
1.- Type
int
- start_detection()[source]¶
(Re-)Start the detection process.
Starts a detection process for each dataset loaded in the
managersattribute. All frames betweenstart_frameandend_frameare used and only the selected colors in displayed in the tab’s table will be detected. This function cannot start the detection without a loadedmodel.- Returns
None
- start_frame: int = 0¶
First frame for detecting particles in it.
Default is
0.- Type
int
- table_colors: QTableWidget = None¶
- threshold: float = 0.5¶
Confidence threshold \(\in [0, 1]\) below which objects are rejected after detection.
Default is
0.5.- Type
float
- update_settings(settings: dict) None[source]¶
Catches updates of the settings from a Settings class.
Checks for the keys relevant to itself and updates the corresponding attributes. Redraws itself with the new settings in place.
- Parameters
settings (dict) –
- Returns
None
- used_colors: List[str] = []¶
Colors of rods that are supposed to be detected.
Default is
[].- Type
List[str]
- init_detection(ui: Ui_MainWindow, image_managers: List[ImageData])[source]¶
Initialize the functionality of detecting particles.
- Parameters
ui (Ui_MainWindow) – UI object of the main window of the application, i.e. also containing the UI tab/objects for detection tasks.
image_managers (List[ImageData]) – List of (relevant) image data management objects providing access to loaded image datasets. Only images from these objects will be available for particle detection.
- Returns
None | DetectorUI – Returns
None, if the system requirements for particle detections are not met. Otherwise theDetectorUIobject handling particle detections is returned.