|
@@ -1,82 +0,0 @@
|
|
|
-#ifndef ALGORITHMBASE_H
|
|
|
|
|
-#define ALGORITHMBASE_H
|
|
|
|
|
-
|
|
|
|
|
-#include <opencv2/opencv.hpp>
|
|
|
|
|
-#include <QString>
|
|
|
|
|
-#include <QVariant>
|
|
|
|
|
-#include <QMap>
|
|
|
|
|
-#include <QList>
|
|
|
|
|
-#include <typeindex>
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-// 1. Parameter type enum (for OpenCV algorithm common parameter types)
|
|
|
|
|
-enum class ParamType {
|
|
|
|
|
- Int, // Integer (e.g., kernel size, threshold)
|
|
|
|
|
- Float, // Float (e.g., sigma, dp)
|
|
|
|
|
- Bool, // Boolean (e.g., L2gradient)
|
|
|
|
|
- Enum // Enum (e.g., threshold type THRESH_BINARY)
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-// 2. Single parameter metadata
|
|
|
|
|
-struct ParamMeta {
|
|
|
|
|
- QString name; // Parameter name (e.g., threshold1)
|
|
|
|
|
- QString displayName; // Display name (e.g., "Threshold 1")
|
|
|
|
|
- ParamType type; // Parameter type
|
|
|
|
|
- double minVal; // Minimum value (int/float)
|
|
|
|
|
- double maxVal; // Maximum value (int/float)
|
|
|
|
|
- double defaultValue; // Default value
|
|
|
|
|
- QMap<int, QString> enumItems; // Enum items (key=enum value, value=display name)
|
|
|
|
|
- QVariant value; // Current value
|
|
|
|
|
-
|
|
|
|
|
- // Constructor (simplify initialization)
|
|
|
|
|
- ParamMeta(QString n, QString dn, ParamType t, double min, double max, double def)
|
|
|
|
|
- : name(n), displayName(dn), type(t), minVal(min), maxVal(max), defaultValue(def), value(def) {}
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-// 3. Algorithm metadata (includes algorithm type + all parameter metadata)
|
|
|
|
|
-struct AlgorithmMeta {
|
|
|
|
|
- QString type; // Algorithm type (e.g., canny/threshold)
|
|
|
|
|
- QString name; // Algorithm name (e.g., "Canny Edge Detection")
|
|
|
|
|
- QList<ParamMeta> params; // Parameter list
|
|
|
|
|
-
|
|
|
|
|
- // Add parameter method
|
|
|
|
|
- void addParam(const QString& displayName, const QString& type, double value, double min, double max) {
|
|
|
|
|
- ParamType paramType = ParamType::Int;
|
|
|
|
|
- if (type == "float") {
|
|
|
|
|
- paramType = ParamType::Float;
|
|
|
|
|
- } else if (type == "bool") {
|
|
|
|
|
- paramType = ParamType::Bool;
|
|
|
|
|
- }
|
|
|
|
|
- params << ParamMeta(displayName, displayName, paramType, min, max, value);
|
|
|
|
|
- }
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-struct RuntimeParamsBase {
|
|
|
|
|
- virtual ~RuntimeParamsBase() = default;
|
|
|
|
|
- std::type_index type() const {
|
|
|
|
|
- return std::type_index(typeid(*this));
|
|
|
|
|
- }
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-class AlgorithmBase {
|
|
|
|
|
-public:
|
|
|
|
|
- virtual ~AlgorithmBase() = default;
|
|
|
|
|
- virtual void process(cv::Mat image) = 0;
|
|
|
|
|
-
|
|
|
|
|
- virtual AlgorithmMeta getParams() = 0;
|
|
|
|
|
- virtual void setParams(const AlgorithmMeta& params) = 0;
|
|
|
|
|
-
|
|
|
|
|
- // Get runtime parameters (returns nullptr if not implemented)
|
|
|
|
|
- virtual RuntimeParamsBase* getRuntimeParams() {
|
|
|
|
|
- return nullptr;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- std::unique_ptr<RuntimeParamsBase> m_params;
|
|
|
|
|
-
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-#endif // ALGORITHMBASE_H
|
|
|