70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
#ifndef __BASECLASS_H__
|
||||
|
|
#define __BASECLASS_H__
|
|||
|
|
|
|||
|
|
#include <iostream>
|
|||
|
|
#include <QObject>
|
|||
|
|
#include <QByteArray>
|
|||
|
|
#include <opencv2/opencv.hpp>
|
|||
|
|
#include <opencv2/core.hpp>
|
|||
|
|
#include <opencv2/imgproc.hpp>
|
|||
|
|
#include<QJsonDocument>
|
|||
|
|
#include<QJsonObject>
|
|||
|
|
#include<QJsonArray>
|
|||
|
|
|
|||
|
|
class Base :public QObject
|
|||
|
|
{
|
|||
|
|
Q_OBJECT
|
|||
|
|
public:
|
|||
|
|
bool init_flag; //是否初始化,false,true
|
|||
|
|
bool status = true; //相机状态(判断相机是否断开连接)
|
|||
|
|
std::string paras; //传输数据
|
|||
|
|
std::vector<cv::Mat> m_mat; //传输图片
|
|||
|
|
std::string moduleName; //模块名称
|
|||
|
|
public:
|
|||
|
|
Base(){}
|
|||
|
|
virtual ~Base(){}
|
|||
|
|
virtual bool readData(std::vector<cv::Mat>&,QByteArray&){return true;}
|
|||
|
|
virtual bool writeData(std::vector<cv::Mat>&,QByteArray&){return true;}
|
|||
|
|
virtual bool initParas(QByteArray&){return true;}
|
|||
|
|
virtual bool run() {return true;}
|
|||
|
|
virtual bool checkStatus() { return true; }
|
|||
|
|
|
|||
|
|
//signals:
|
|||
|
|
//QByteArrayList,根据实际项目进行解析;因不确定每个参数的长度,固用队列的方式。每个QByteArray表示一个值,使用时先转换为QString
|
|||
|
|
//参数,例:返回结果图;相机关键字(SN或userID)+保存路径+缺陷信息列表(缺陷名称,缺陷位置int(x,y,w,h),画框颜色Scalar(a,b,c),缺陷面积double)
|
|||
|
|
//void sendResultData(cv::Mat resMat, QJsonObject resQbj);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
//QJsonObject 转QByteArray
|
|||
|
|
{
|
|||
|
|
QJsonDocument document;
|
|||
|
|
QJsonObject obj;
|
|||
|
|
obj.insert(password, "pwd");
|
|||
|
|
obj.insert(userName, "usr");
|
|||
|
|
document.setObject(obj);
|
|||
|
|
QByteArray abyte = document.toJson(QJsonDocument::Compact);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//QByteArray转QJsonObject
|
|||
|
|
{
|
|||
|
|
QByteArray ba = reply->readAll();
|
|||
|
|
QJsonDocument doc = QJsonDocument::fromJson(ba);
|
|||
|
|
QJsonObject obj = doc.object();
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
/*
|
|||
|
|
//从类中读数据到实例对象
|
|||
|
|
virtual bool readData(std::vector<cv::Mat>&,QByteArray&){return true;}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#endif
|