Manages model configurations in a directory and exposes UI-friendly state.
More...
#include <ModelManager.h>
|
| enum class | ModelState |
| | High-level availability state of a model entry.
|
| |
|
| void | onModelActivationRequested (const QString &modelName) |
| | Slot to handle model activation requests from UI thread.
|
| |
| void | onClassSelectionRequested (const QString &modelName, uint classId, bool selected) |
| | Slot to handle class selection requests from UI thread.
|
| |
|
void | onModelsRefreshRequested () |
| | Slot to handle refresh requests from UI thread.
|
| |
| void | onApplyMeanStdRequested (const QString &modelName, bool apply) |
| | Slot to handle apply mean/std setting changes from UI thread.
|
| |
| void | onNormalizeTo01Requested (const QString &modelName, bool normalize) |
| | Slot to handle normalize to [0,1] setting changes from UI thread.
|
| |
| void | onInputAlignmentRequested (const QString &modelName, uint alignment) |
| | Slot to handle input alignment changes from UI thread.
|
| |
|
| | ModelManager (QString modelDir=defaultModelDirectory()) |
| | Construct a manager for a specific model directory.
|
| |
|
| ~ModelManager () |
| | Destructor.
|
| |
| void | setNameFilter (const QString &pattern) |
| | Set a filename filter pattern (wildcard style) Only model configs matching this pattern will be loaded. Uses wildcard matching (e.g., "Detection_*", "*yolo*") By default (empty string), all models are loaded.
|
| |
| QString | nameFilter () const noexcept |
| | Get the current name filter pattern.
|
| |
|
void | refresh () |
| | Re-scan the model directory and rebuild model list/state.
|
| |
|
const QVector< ModelEntry > & | models () const noexcept |
| | Get all discovered model entries (ready and invalid).
|
| |
| QStringList | availableModelNames () const |
| | Get sorted names of models currently in Ready state.
|
| |
| ModelState | modelState (const QString &name) const noexcept |
| | Get state of a model by name.
|
| |
| QString | modelError (const QString &name) const noexcept |
| | Get error text of a model by name.
|
| |
| std::optional< ModelEntry > | activateModel (const QString &name) |
| | Activate a model and emit activation/class-list signals.
|
| |
| std::optional< ModelEntry > | activeModel () const noexcept |
| | Get currently active model entry.
|
| |
|
const QString & | activeModelName () const noexcept |
| | Get name of active model, or empty if none active.
|
| |
| bool | setClassSelected (const QString &modelName, ModelConfig::ClassId id, bool selected) |
| | Update selected state of one class of one model.
|
| |
| void | markModelIncompatible (const QString &name, const QString &reason) |
| | Mark a model as incompatible with runtime/model consumer.
|
| |
| QString | modelToString (const QString &name) const noexcept |
| | Serialize model selection summary as user-friendly text.
|
| |
| QJsonObject | modelToJson (const QString &name) const noexcept |
| | Serialize model class-selection state to JSON.
|
| |
| std::optional< ModelEntry > | modelFromJson (const QJsonObject &obj) const noexcept |
| | Restore class-selection state from JSON for a known model.
|
| |
Manages model configurations in a directory and exposes UI-friendly state.
The manager scans a model directory for JSON/ONNX pairs, validates each model using ModelConfig::loadFromFile(), tracks per-model readiness/error states, and emits Qt signals for GUI synchronization.
The corresponding JSON schema is described in ModelConfig.md.
- Author
- Dominik Wüst (domin.nosp@m.ik.w.nosp@m.uest@.nosp@m.iosb.nosp@m..frau.nosp@m.nhof.nosp@m.er.de)
- Date
- March 2026
◆ ModelManager()
Construct a manager for a specific model directory.
- Parameters
-
◆ activateModel()
Activate a model and emit activation/class-list signals.
- Parameters
-
- Returns
- Activated entry on success, std::nullopt otherwise.
◆ activeModel()
Get currently active model entry.
- Returns
- Active entry or std::nullopt if no valid model is active.
◆ availableModelNames()
| QStringList MCFG::ModelManager::availableModelNames |
( |
| ) |
const |
Get sorted names of models currently in Ready state.
- Returns
- List of usable model names.
◆ classListUpdated
Emitted when class list is updated for the current model.
- Parameters
-
| classIds | Vector of class IDs for the current model |
◆ defaultModelDirectory()
| QString MCFG::ModelManager::defaultModelDirectory |
( |
| ) |
|
|
static |
Get the platform-specific default model directory.
- Returns
- Absolute path used by default constructor.
◆ markModelIncompatible()
| void MCFG::ModelManager::markModelIncompatible |
( |
const QString & |
name, |
|
|
const QString & |
reason |
|
) |
| |
Mark a model as incompatible with runtime/model consumer.
- Parameters
-
| name | Model base name. |
| reason | Human-readable incompatibility reason. |
◆ modelActivated
| void MCFG::ModelManager::modelActivated |
( |
const QString & |
modelName, |
|
|
ModelManager::ModelState |
state, |
|
|
const QString & |
error |
|
) |
| |
|
signal |
Emitted when a model is activated and initial data is ready.
- Parameters
-
| modelName | Name of the activated model |
| state | Current state of the model |
| error | Error message if state is not Ready, otherwise empty |
◆ modelError()
| QString MCFG::ModelManager::modelError |
( |
const QString & |
name | ) |
const |
|
noexcept |
Get error text of a model by name.
- Parameters
-
- Returns
- Error string or a message indicating unknown model.
◆ modelFromJson()
Restore class-selection state from JSON for a known model.
- Parameters
-
- Returns
- Updated model entry, or std::nullopt if model name is unknown.
◆ modelsListUpdated
| void MCFG::ModelManager::modelsListUpdated |
( |
const QVector< ModelEntry > & |
models | ) |
|
|
signal |
Emitted when models list is refreshed.
- Parameters
-
| models | The updated list of models |
◆ modelState()
Get state of a model by name.
- Parameters
-
- Returns
- Current model state, or MissingConfig for unknown names.
◆ modelToJson()
| QJsonObject MCFG::ModelManager::modelToJson |
( |
const QString & |
name | ) |
const |
|
noexcept |
Serialize model class-selection state to JSON.
- Parameters
-
- Returns
- JSON object containing model name and selected classes.
◆ modelToString()
| QString MCFG::ModelManager::modelToString |
( |
const QString & |
name | ) |
const |
|
noexcept |
Serialize model selection summary as user-friendly text.
- Parameters
-
- Returns
- Description string, empty if model is unknown.
◆ nameFilter()
| QString MCFG::ModelManager::nameFilter |
( |
| ) |
const |
|
noexcept |
Get the current name filter pattern.
- Returns
- The wildcard pattern, or empty string if no filter is set
◆ onApplyMeanStdRequested
| void MCFG::ModelManager::onApplyMeanStdRequested |
( |
const QString & |
modelName, |
|
|
bool |
apply |
|
) |
| |
|
slot |
Slot to handle apply mean/std setting changes from UI thread.
- Parameters
-
| modelName | Name of the model |
| apply | Whether to apply mean/std normalization |
◆ onClassSelectionRequested
| void MCFG::ModelManager::onClassSelectionRequested |
( |
const QString & |
modelName, |
|
|
uint |
classId, |
|
|
bool |
selected |
|
) |
| |
|
slot |
Slot to handle class selection requests from UI thread.
- Parameters
-
| modelName | Name of the model |
| classId | ID of the class |
| selected | Whether the class should be selected |
◆ onInputAlignmentRequested
| void MCFG::ModelManager::onInputAlignmentRequested |
( |
const QString & |
modelName, |
|
|
uint |
alignment |
|
) |
| |
|
slot |
Slot to handle input alignment changes from UI thread.
- Parameters
-
| modelName | Name of the model |
| alignment | Input alignment value |
◆ onModelActivationRequested
| void MCFG::ModelManager::onModelActivationRequested |
( |
const QString & |
modelName | ) |
|
|
slot |
Slot to handle model activation requests from UI thread.
- Parameters
-
| modelName | Name of the model to activate |
◆ onNormalizeTo01Requested
| void MCFG::ModelManager::onNormalizeTo01Requested |
( |
const QString & |
modelName, |
|
|
bool |
normalize |
|
) |
| |
|
slot |
Slot to handle normalize to [0,1] setting changes from UI thread.
- Parameters
-
| modelName | Name of the model |
| normalize | Whether to normalize input to [0,1] |
◆ setClassSelected()
| bool MCFG::ModelManager::setClassSelected |
( |
const QString & |
modelName, |
|
|
ModelConfig::ClassId |
id, |
|
|
bool |
selected |
|
) |
| |
Update selected state of one class of one model.
- Parameters
-
| modelName | Model base name. |
| id | Class ID. |
| selected | Desired selected state. |
- Returns
- true if model/class was found and updated.
◆ setNameFilter()
| void MCFG::ModelManager::setNameFilter |
( |
const QString & |
pattern | ) |
|
Set a filename filter pattern (wildcard style) Only model configs matching this pattern will be loaded. Uses wildcard matching (e.g., "Detection_*", "*yolo*") By default (empty string), all models are loaded.
- Parameters
-
| pattern | Wildcard pattern (e.g., "Detection_*") |
The documentation for this class was generated from the following files:
- iVS3D/src/iVS3D-modelConfig/include/ModelManager.h
- iVS3D/src/iVS3D-modelConfig/src/ModelManager.cpp