70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
#pragma once
|
||
|
||
#include <iostream>
|
||
#include <QObject>
|
||
#include <QWidget>
|
||
#include <QThread>
|
||
|
||
#include "DataModelRegistry.hpp"
|
||
#include "NodeDataModel.hpp"
|
||
|
||
#include "opcv/CvImageData.h"
|
||
#include "opcv/CvAlgorithmTools.h"
|
||
|
||
#include <opencv2/opencv.hpp>
|
||
#include <opencv2/imgproc/types_c.h>
|
||
|
||
using QtNodes::PortType;
|
||
using QtNodes::PortIndex;
|
||
using QtNodes::NodeData;
|
||
using QtNodes::NodeDataType;
|
||
using QtNodes::NodeDataModel;
|
||
using QtNodes::NodeValidationState;
|
||
|
||
class CvImageRGB2GrayModel :public NodeDataModel
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
CvImageRGB2GrayModel();
|
||
virtual ~CvImageRGB2GrayModel() {}
|
||
|
||
public:
|
||
QString caption() const override { return QStringLiteral("cvͼÏñת»Ò¶È"); }
|
||
QString name() const override { return QStringLiteral("cvͼÏñת»Ò¶È"); }
|
||
virtual QString modelName() const { return QStringLiteral("cvͼÏñת»Ò¶È"); }
|
||
|
||
QWidget* embeddedWidget() override { return Q_NULLPTR; }
|
||
|
||
bool resizable() const override { return false; }
|
||
|
||
NodeValidationState validationState() const override { return modelValidationState; }
|
||
QString validationMessage() const override { return modelValidationError; }
|
||
|
||
unsigned int nPorts(PortType portType) const override;
|
||
|
||
NodeDataType dataType(PortType portType, PortIndex portIndex) const override { return CvImageData().type(); };
|
||
|
||
void setInData(std::shared_ptr<NodeData>, int) override;
|
||
std::shared_ptr<NodeData> outData(PortIndex port) override;
|
||
|
||
protected:
|
||
bool RunTask();
|
||
|
||
signals:
|
||
void SignalCvImageRgb2Gray(cv::Mat rgbImg);
|
||
|
||
public slots:
|
||
void GetRgb2GrayResult(cv::Mat grayImg);
|
||
|
||
public:
|
||
NodeValidationState modelValidationState = NodeValidationState::Warning;
|
||
QString modelValidationError = QStringLiteral("ͼƬÊäÈëδÁ¬½Ó!");
|
||
|
||
private:
|
||
CvAlgorithmTools* mAlgoTool = Q_NULLPTR;
|
||
QThread* mChildThread = Q_NULLPTR;
|
||
|
||
std::shared_ptr<CvImageData> mCvImage;
|
||
};
|
||
|