init files
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
#ifndef Hd_CameraModule_HIK3_H
|
||||
#define Hd_CameraModule_HIK3_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include<opencv2/opencv.hpp>
|
||||
#include <MvCameraControl.h>
|
||||
#include <opencv.hpp>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include<iostream>
|
||||
#include <Windows.h>
|
||||
#include <time.h>
|
||||
#include <QThread>
|
||||
#include <QtConcurrent/qtconcurrent>
|
||||
#include <qfuture.h>
|
||||
#include "qobject.h"
|
||||
#include "qjsonobject.h"
|
||||
#include "qjsonarray.h"
|
||||
#include "qjsondocument.h"
|
||||
#include "QLibrary.h"
|
||||
#include "QMetaType.h"
|
||||
#include "QDateTime.h"
|
||||
#include "QThread.h"
|
||||
#include "QMutex.h"
|
||||
#include "QDebug.h"
|
||||
#include "QQueue.h"
|
||||
#include "QMap.h"
|
||||
#include "QDir.h"
|
||||
#include <QJsonParseError>
|
||||
|
||||
|
||||
#include "pbglobalobject.h"
|
||||
//#include "base.h"
|
||||
|
||||
using namespace cv;
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
struct myPBGLOBAL_callBack
|
||||
{
|
||||
void (*callBackFun)(QObject*, const std::vector<cv::Mat>&);
|
||||
QObject* m_QObject;
|
||||
QString cameraIndex;
|
||||
};
|
||||
class MyThread;
|
||||
class MyData;
|
||||
class Hd_CameraModule_HIK3 :public PbGlobalObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
//1、创建:赋值给famliy
|
||||
explicit Hd_CameraModule_HIK3(int settype = -1, QObject* parent = nullptr);//对应哪个品牌相机(触发方式)/通信
|
||||
~Hd_CameraModule_HIK3();
|
||||
//#######################通用函数#######################
|
||||
//初始化参数;通信/相机的初始化参数
|
||||
bool setParameter(const QMap<QString, QString>&);
|
||||
|
||||
//setParameter之后再调用,返回当前参数
|
||||
//相机:获取默认参数;
|
||||
//通信:获取初始化示例参数
|
||||
QMap<QString, QString> parameters();
|
||||
//初始化(加载模块到内存)
|
||||
bool init();
|
||||
|
||||
//设置数据
|
||||
//相机:第一张图的参数,QStringList:00 曝光值 增益值;
|
||||
//相机:第N张图的参数,QStringList:非00 曝光值 增益值;
|
||||
//完成后发送信号trigged(bool);
|
||||
bool setData(const std::vector<cv::Mat>&, const QStringList&);
|
||||
//获取数据
|
||||
bool data(std::vector<cv::Mat>&, QStringList&);
|
||||
//注册回调 string对应自身的参数协议 (自定义)
|
||||
void registerCallBackFun(PBGLOBAL_CALLBACK_FUN, QObject*, const QString&);
|
||||
//注销回调 string对应自身的参数协议 (自定义)--->注销后还得取消连接状态
|
||||
void cancelCallBackFun(PBGLOBAL_CALLBACK_FUN, QObject*, const QString&);
|
||||
|
||||
|
||||
|
||||
//Hd_CameraModule_HIK3();
|
||||
//virtual ~Hd_CameraModule_HIK3();
|
||||
//从类中读数据到实例对象
|
||||
bool readData(std::vector<cv::Mat>& mat, QByteArray& data);
|
||||
//实例对象把数据写入到类
|
||||
bool writeData(std::vector<cv::Mat>& mat, QByteArray& data);
|
||||
bool initParas(QByteArray&);
|
||||
bool run();
|
||||
bool checkStatus();
|
||||
|
||||
void threadCheckCallBack(int code);
|
||||
int SearchDevice();
|
||||
bool connctDevice();
|
||||
QJsonObject load_camera_Example();
|
||||
QString getmoduleName();
|
||||
|
||||
MyData* m_MyData;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class MyThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Hd_CameraModule_HIK3* camera = nullptr;
|
||||
explicit MyThread(QObject *parent = nullptr) : QObject(parent){}
|
||||
void runEmit(int code, MyData* m_MyData);
|
||||
};
|
||||
|
||||
class MyData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MyData(QObject* parent = nullptr) : QObject(parent) {}
|
||||
void run(int);
|
||||
|
||||
|
||||
bool ifFirst = true;
|
||||
//参数设置的数据
|
||||
QMap<QString, QString> ParasValueMap;
|
||||
|
||||
QByteArray mv_Status = "connected";//0106 新增相机断联报警
|
||||
//cv::Mat srcImage;
|
||||
int index = -1; //相机序号
|
||||
void* handle = NULL; //相机指针
|
||||
std::string Username = "";
|
||||
bool m_flag = false;
|
||||
MV_CC_DEVICE_INFO_LIST m_stDevList;//相机设备
|
||||
//cv::Mat srcImage;
|
||||
QQueue<cv::Mat> QQueue_srcImage;
|
||||
bool moduleStatus = true;
|
||||
//data == "rest_newProductIn"时要结束run;机台报警,取图超时,复位后重新拍的情况。
|
||||
bool ifBreak = false;
|
||||
//ifRunning减少ifBreak的判断;"rest_newProductIn"时,Logic_camera_thread框架会结束未处理完的相相机取图
|
||||
bool ifRunning = false;
|
||||
bool ifChangeExpourseAndGain = true;
|
||||
MV_CAM_TRIGGER_SOURCE initTriggerSource = MV_TRIGGER_SOURCE_SOFTWARE;
|
||||
MV_CAM_TRIGGER_SOURCE currentTriggerSource = MV_TRIGGER_SOURCE_SOFTWARE;
|
||||
QMutex* n_mutex;// = new QMutex();
|
||||
//是否为标准通信流程:
|
||||
//标准通信流程,run函数设置曝光/增益;非标准通信流程(简单通信流程),回调函数设置曝光/增益
|
||||
bool ifStandard = false;
|
||||
//相机取图超时时间
|
||||
int getImageTimeOut = 1000;
|
||||
//总取图数
|
||||
int imgIndex = 0;
|
||||
//曝光值列表
|
||||
QQueue<float> expourseTimeList;
|
||||
//增益列表
|
||||
QQueue<float> gainList;
|
||||
//模块名称
|
||||
QString moduleName="";
|
||||
QQueue< myPBGLOBAL_callBack> QQueue_myPBGLOBAL_callBack;
|
||||
int callBackNum = 0;
|
||||
int triggedNum = 0;
|
||||
bool ifThemoduleStatus = true;
|
||||
cv::Mat srcImage;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Q_DECL_EXPORT Hd_CameraModule_HIK3* create(int type = -1);
|
||||
Q_DECL_EXPORT void destory(Hd_CameraModule_HIK3* ptr);
|
||||
}
|
||||
|
||||
#endif // Hd_CameraModule_HIK3_H
|
||||
Reference in New Issue
Block a user