备份
This commit is contained in:
@@ -19,7 +19,7 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/back
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/front
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/handleAi
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/halconAlgo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/additionalFunc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/logger
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/simpleTools
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/uiModule
|
||||
|
||||
@@ -32,7 +32,7 @@ camera::camera(cameraModule cameraModulePtrIn, int indexIn,qtFuncBridge* bridgeI
|
||||
{
|
||||
bridge = bridgeIn;
|
||||
cameraModulePtr = cameraModulePtrIn;
|
||||
_cameraStruct = cameraModulePtr._cameraStruct;
|
||||
config = cameraModulePtr._cameraStruct;
|
||||
cameraName = cameraModulePtr.key;
|
||||
index = indexIn;
|
||||
lastUpdateTime.start();
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#ifndef CAMERAManager_H
|
||||
#define CAMERAManager_H
|
||||
#include <QString>
|
||||
#include <QString>
|
||||
#include <unordered_map>
|
||||
#include <qlibrary.h>
|
||||
#include <opencv.hpp>
|
||||
#include <unordered_map>
|
||||
#include <qqueue.h>
|
||||
#include <qthread.h>
|
||||
#include <qdebug.h>
|
||||
@@ -24,7 +21,7 @@ public:
|
||||
QString cameraName;
|
||||
int imgShowCnt = 0;
|
||||
cameraModule cameraModulePtr;
|
||||
cameraStruct _cameraStruct;
|
||||
cameraStruct config;
|
||||
camera(cameraModule cameraModulePtrIn, int indexIn, qtFuncBridge* bridgeIn);
|
||||
~camera()
|
||||
{
|
||||
@@ -98,7 +95,6 @@ public:
|
||||
}
|
||||
private:
|
||||
qtFuncBridge* bridge;
|
||||
//detData* data = nullptr;
|
||||
void readData(std::string str)
|
||||
{
|
||||
QByteArray task_name(QByteArray::fromStdString(str));
|
||||
@@ -129,7 +125,7 @@ public:
|
||||
_cameraStruct.connectionName = data["connectionName"];
|
||||
_cameraStruct.dllPath = data["dllPath"];
|
||||
_cameraStruct.oriSaveFormat = data["oriSaveFormat"];
|
||||
for (auto& imageShow : data["oriImageShow"])
|
||||
for (auto& imageShow : data["imageShow"])
|
||||
{
|
||||
QString str = QString::fromStdString(imageShow);
|
||||
QStringList l = str.split("#");
|
||||
@@ -182,5 +178,4 @@ public slots:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
#include <triggerManager.h>
|
||||
#include <handleAiModel.h>
|
||||
#include <summaryData.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
//所有检测需要的数据均放在这里
|
||||
class camera;
|
||||
class detData;
|
||||
class detDataManager;
|
||||
class triggerManager;
|
||||
@@ -104,21 +105,23 @@ public:
|
||||
std::unordered_map<unsigned long long, std::shared_ptr<detData>>map;
|
||||
QMutex dataMutex;
|
||||
|
||||
std::shared_ptr <detData> insertDetData(
|
||||
std::shared_ptr <detData> createDetData(
|
||||
QString IN_cameraKeyName,
|
||||
std::string IN_SN,int imgAmountMin,
|
||||
resultHandleCallback resultSolver,
|
||||
algoEvaluateCallback _algoEvaluateCallback){
|
||||
algoEvaluateCallback _algoEvaluateCallback,
|
||||
std::vector<std::string> oriFormat){
|
||||
|
||||
QMutexLocker locker(&dataMutex);
|
||||
std::shared_ptr <detData>dataPtr(new detData(IN_cameraKeyName.toStdString()));
|
||||
|
||||
dataPtr->oriFormat = oriFormat;
|
||||
dataPtr->triggerPtr = _triggerManager;
|
||||
dataPtr->SNcode = IN_SN;
|
||||
dataPtr->registerResultHandleCallback(resultSolver);
|
||||
dataPtr->registerAlgoEvaluateCallback(_algoEvaluateCallback);
|
||||
dataPtr->imgAmountMin = imgAmountMin;
|
||||
dataPtr->dManager = this;
|
||||
|
||||
map.insert({ dataPtr->timeCode,dataPtr });
|
||||
|
||||
if (dataPtr == nullptr)
|
||||
|
||||
@@ -148,6 +148,7 @@ public:
|
||||
{
|
||||
std::vector<std::string> resultFileNames;
|
||||
std::string fileName;
|
||||
fileName += data->SNcode;
|
||||
for (auto str : data->imgSaveNameParameter)
|
||||
fileName += str + "_";
|
||||
switch (type)
|
||||
|
||||
@@ -1,406 +0,0 @@
|
||||
/*###############################################
|
||||
* 常用函数集合
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* ############################################*/
|
||||
|
||||
#include "toolkit.h"
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QDirIterator>
|
||||
#include <QTextCodec>
|
||||
|
||||
bool isDirExist(const QString & fullDirName, bool Crt)
|
||||
{
|
||||
QDir photo;
|
||||
bool exist = photo.exists(fullDirName);
|
||||
if (exist)
|
||||
{
|
||||
return true;
|
||||
//qDebug() << fullDirName << QString::fromLocal8Bit("::已存在");
|
||||
}
|
||||
else
|
||||
{
|
||||
//创建文件夹
|
||||
if(Crt)photo.mkdir(fullDirName);
|
||||
//qDebug() << fullDirName << QString::fromLocal8Bit("::不存在,创建");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isFileExist(const QString & fullFileName, bool Crt)
|
||||
{
|
||||
QFile file(fullFileName);
|
||||
if (file.exists())
|
||||
{
|
||||
//qDebug() << fullFileName << QString::fromLocal8Bit("::已存在");
|
||||
return true;
|
||||
}
|
||||
if(Crt){
|
||||
if(file.open(QIODevice::WriteOnly)){
|
||||
//WriteOnly或ReadWrite当文件不存在时创建
|
||||
file.flush();
|
||||
file.close();
|
||||
//qDebug() << fullFileName << QString::fromLocal8Bit("::已创建");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QString createMultipleFoldes(const QString &fullDirName)
|
||||
{
|
||||
QString path=QDir::fromNativeSeparators(fullDirName);// 将\\转/
|
||||
QDir dir(path);
|
||||
if(dir.exists()){
|
||||
return dir.absolutePath();
|
||||
}
|
||||
QString parent=createMultipleFoldes(path.mid(0,path.lastIndexOf("/")));
|
||||
QString dirName=path.mid(path.lastIndexOf("/")+1);
|
||||
QDir parentPath(parent);
|
||||
if(!dirName.isEmpty()){
|
||||
parentPath.mkpath(dirName);
|
||||
}
|
||||
return parent+"/"+dirName;
|
||||
}
|
||||
|
||||
QString GetTimeStamp(QString Stamp)
|
||||
{
|
||||
QDateTime time = QDateTime::currentDateTime();
|
||||
QString times = time.toString(Stamp);
|
||||
return times;
|
||||
}
|
||||
|
||||
bool QSetFileTimes(const QString & filepath, QDateTime& CreationTime)
|
||||
{
|
||||
bool fing=true;
|
||||
if(!isFileExist(filepath))return false;
|
||||
#if (QT_VERSION<QT_VERSION_CHECK(5,10,0))
|
||||
HANDLE hFile;
|
||||
//可输入中文路径
|
||||
hFile=CreateFileW(filepath.toStdWString().data(),GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if(hFile!=NULL){
|
||||
FILETIME lpCreationTime; // 文件夹的创建时间
|
||||
// FILETIME lpLastAccessTime; // 对文件夹的最近访问时间
|
||||
// FILETIME lpLastWriteTime; // 文件夹的最近修改时间
|
||||
// int i=GetFileTime (hFile, &lpCreationTime, &lpLastAccessTime, &lpLastWriteTime); // 获取文件夹时间属性信息
|
||||
// SYSTEMTIME stc;
|
||||
// FILETIME localTime;
|
||||
// FileTimeToLocalFileTime(&lpCreatxionTime,&localTime);
|
||||
// FileTimeToSystemTime(&localTime,&stc);//UTC转本地时间
|
||||
SYSTEMTIME newDay;
|
||||
newDay.wDayOfWeek=CreationTime.date().dayOfWeek();
|
||||
newDay.wMonth=CreationTime.date().month();
|
||||
newDay.wDay=CreationTime.date().day();
|
||||
newDay.wYear=CreationTime.date().year();
|
||||
newDay.wHour=CreationTime.time().hour();
|
||||
newDay.wMinute=CreationTime.time().minute();
|
||||
newDay.wSecond=CreationTime.time().second();
|
||||
newDay.wMilliseconds=CreationTime.time().msec();
|
||||
SystemTimeToFileTime(&newDay,&lpCreationTime);
|
||||
fing&=SetFileTime(hFile,&lpCreationTime,&lpCreationTime,&lpCreationTime);//输入UTC格式
|
||||
CloseHandle(hFile);//关闭句柄
|
||||
}
|
||||
#else
|
||||
QFile file(filepath);
|
||||
if(file.open(QIODevice::ReadWrite)){
|
||||
fing&=file.setFileTime(CreationTime,QFileDevice::FileBirthTime);
|
||||
fing&=file.setFileTime(CreationTime,QFileDevice::FileAccessTime);
|
||||
fing&=file.setFileTime(CreationTime,QFileDevice::FileModificationTime);
|
||||
file.close();
|
||||
}else{
|
||||
fing=false;
|
||||
};
|
||||
#endif
|
||||
return fing;
|
||||
}
|
||||
|
||||
|
||||
int QGetRandom(int max, int min, bool timeC)
|
||||
{
|
||||
if(max-min<1)return -1;
|
||||
//秒级随机种子
|
||||
//qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
|
||||
if(timeC)QThread::msleep(1);
|
||||
//毫秒级随机种子
|
||||
QTime time= QTime::currentTime();
|
||||
qsrand(time.msec()+time.second()*1000);
|
||||
return min+qrand()%abs(max-min);
|
||||
}
|
||||
|
||||
void deleteDirectory(const QString &fullFileName)
|
||||
{
|
||||
|
||||
QDir dir(fullFileName);
|
||||
if (!dir.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
|
||||
QFileInfoList fileList = dir.entryInfoList();
|
||||
|
||||
foreach (QFileInfo fi, fileList) {
|
||||
if (fi.isFile()) {
|
||||
fi.dir().remove(fi.fileName());
|
||||
} else {
|
||||
deleteDirectory(fi.absoluteFilePath());
|
||||
dir.rmdir(fi.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
QStringList addNextDirectory(const QString &fullFileName, bool isDir,QString suffix)
|
||||
{
|
||||
|
||||
// 判断路径是否存在
|
||||
QDir dir(fullFileName);
|
||||
if(!dir.exists())
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
dir.setFilter(QDir::Dirs | QDir::NoSymLinks);
|
||||
QFileInfoList list = dir.entryInfoList();
|
||||
|
||||
int file_count = list.count();
|
||||
if(file_count <= 0)
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList string_list;
|
||||
for(int i=0; i<file_count; i++)
|
||||
{
|
||||
QFileInfo file_info = list.at(i);
|
||||
if(file_info.fileName()=="."|file_info.fileName()=="..")continue;
|
||||
if(isDir){
|
||||
if(file_info.isDir()){
|
||||
QString absolute_file_path = file_info.absoluteFilePath();
|
||||
string_list.append(absolute_file_path);
|
||||
}
|
||||
}else{
|
||||
if(!suffix.isEmpty()){
|
||||
if(QString::compare(file_info.suffix(), QString(suffix), Qt::CaseInsensitive) != 0)
|
||||
continue;
|
||||
}
|
||||
QString absolute_file_path = file_info.absoluteFilePath();
|
||||
string_list.append(absolute_file_path);
|
||||
}
|
||||
|
||||
}
|
||||
return string_list;
|
||||
}
|
||||
|
||||
QStringList addSubFolderDirectory(const QString &fullFileName, QStringList filters)
|
||||
{
|
||||
|
||||
// 判断路径是否存在
|
||||
QDir dir(fullFileName);
|
||||
if(!dir.exists())
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
// 定义迭代器并设置过滤器
|
||||
QDirIterator dir_iterator(fullFileName,
|
||||
filters,
|
||||
QDir::Files | QDir::NoSymLinks,
|
||||
QDirIterator::Subdirectories);
|
||||
QStringList string_list;
|
||||
while(dir_iterator.hasNext())
|
||||
{
|
||||
dir_iterator.next();
|
||||
QFileInfo file_info = dir_iterator.fileInfo();
|
||||
QString absolute_file_path = file_info.absoluteFilePath();
|
||||
string_list.append(absolute_file_path);
|
||||
}
|
||||
return string_list;
|
||||
|
||||
}
|
||||
|
||||
void getAllFiles(std::string path, std::vector<std::string> &files, std::string format)
|
||||
{
|
||||
intptr_t hFile = 0;//文件句柄
|
||||
struct _finddata_t fileinfo;//文件信息
|
||||
std::string p;
|
||||
if ((hFile = _findfirst(p.assign(path).append("\\*" + format).c_str(), &fileinfo)) != -1) //文件存在
|
||||
{
|
||||
do
|
||||
{
|
||||
if ((fileinfo.attrib & _A_SUBDIR))//判断是否为文件夹
|
||||
{
|
||||
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)//文件夹名中不含"."和".."
|
||||
{
|
||||
files.push_back(p.assign(path).append("\\").append(fileinfo.name)); //保存文件夹名
|
||||
getAllFiles(p.assign(path).append("\\").append(fileinfo.name), files, format); //递归遍历文件夹
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
files.push_back(p.assign(path).append("\\").append(fileinfo.name));//如果不是文件夹,储存文件名
|
||||
}
|
||||
} while (_findnext(hFile, &fileinfo) == 0);
|
||||
_findclose(hFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QJsonObject loadJsonCfg(const QString path)
|
||||
{
|
||||
QJsonObject json_object;
|
||||
try
|
||||
{
|
||||
QJsonParseError jsonError;
|
||||
QString json_cfg = path;
|
||||
if (json_cfg.isEmpty())
|
||||
{
|
||||
qCritical() << " [error] " << __FUNCTION__ << " line:" << __LINE__ << " JsonPath is null!";
|
||||
return json_object;
|
||||
}
|
||||
|
||||
QFile JsonFile;
|
||||
JsonFile.setFileName(json_cfg);
|
||||
JsonFile.open(QIODevice::ReadOnly);
|
||||
|
||||
QByteArray m_Byte = JsonFile.readAll();
|
||||
if (m_Byte.isEmpty())
|
||||
{
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__ << json_cfg + " Content is empty";
|
||||
JsonFile.close();
|
||||
return json_object;
|
||||
}
|
||||
|
||||
QJsonDocument jsonDocument(QJsonDocument::fromJson(m_Byte, &jsonError));
|
||||
|
||||
if (!jsonDocument.isNull() && jsonError.error == QJsonParseError::NoError)
|
||||
{
|
||||
if (jsonDocument.isObject())
|
||||
{
|
||||
json_object = jsonDocument.object();
|
||||
return json_object;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << " [error] " << __FUNCTION__ << " line:" << __LINE__ << json_cfg + " is error!";
|
||||
}
|
||||
|
||||
JsonFile.close();
|
||||
|
||||
}
|
||||
catch (QString ev)
|
||||
{
|
||||
qCritical() << " [error] " << __FUNCTION__ << " line:" << __LINE__ << " ev:" << ev;
|
||||
}
|
||||
return json_object;
|
||||
}
|
||||
|
||||
QStringList ReadTextCfg(const QString path)
|
||||
{
|
||||
|
||||
QString csvpath = path;
|
||||
// 读取每日csv
|
||||
QStringList lines; //配置信息列表
|
||||
QFile configFile;
|
||||
configFile.setFileName(csvpath);
|
||||
bool isTxT = false;
|
||||
if (path.indexOf(".txt") != -1)isTxT = true;
|
||||
if (configFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream stream_text(&configFile);
|
||||
stream_text.setCodec(QTextCodec::codecForName("utf-8"));
|
||||
// //可读取中文
|
||||
stream_text.seek(0);
|
||||
while (!stream_text.atEnd())
|
||||
{
|
||||
|
||||
lines.push_back(gb2312ToUtf8(stream_text.readLine()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "read csv " << csvpath << " failed!" << endl;
|
||||
}
|
||||
configFile.close();
|
||||
return lines;
|
||||
|
||||
}
|
||||
|
||||
bool WriteTXTCfg(const QStringList& parm,const QString path) {
|
||||
|
||||
QString fileName = path;
|
||||
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return false;
|
||||
|
||||
//用文本流读取文件
|
||||
QTextStream stream(&file);
|
||||
|
||||
//转换为字符串
|
||||
|
||||
for each (auto var in parm) {
|
||||
//写入文本流
|
||||
stream << var << endl;
|
||||
}
|
||||
//关闭文件
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
EncodingFormat FileCharacterEncoding(const QString& fileName)
|
||||
{
|
||||
//假定默认编码utf8
|
||||
EncodingFormat code = EncodingFormat::UTF8;
|
||||
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
//读取3字节用于判断
|
||||
QByteArray buffer = file.read(3);
|
||||
quint8 sz1st = buffer.at(0);
|
||||
quint8 sz2nd = buffer.at(1);
|
||||
quint8 sz3rd = buffer.at(2);
|
||||
if (sz1st == 0xFF && sz2nd == 0xFE)
|
||||
{
|
||||
code = EncodingFormat::UTF16LE;
|
||||
}
|
||||
else if (sz1st == 0xFE && sz2nd == 0xFF)
|
||||
{
|
||||
code = EncodingFormat::UTF16BE;
|
||||
}
|
||||
else if (sz1st == 0xEF && sz2nd == 0xBB && sz3rd == 0xBF)
|
||||
{
|
||||
code = EncodingFormat::UTF8BOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
//尝试用utf8转换,如果无效字符数大于0,则表示是ansi编码
|
||||
QTextCodec::ConverterState cs;
|
||||
QTextCodec* tc = QTextCodec::codecForName("utf-8");
|
||||
tc->toUnicode(buffer.constData(), buffer.size(), &cs);
|
||||
code = (cs.invalidChars > 0) ? EncodingFormat::ANSI : EncodingFormat::UTF8;
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
QString gb2312ToUtf8(const QString strUtf8)
|
||||
{
|
||||
//printf("~~~~ utf8 str is:%s\n", strUtf8);
|
||||
QTextCodec* utf8Codec = QTextCodec::codecForName("utf-8");
|
||||
QTextCodec* gb2312Codec = QTextCodec::codecForName("gb2312");
|
||||
|
||||
QString strUnicode = gb2312Codec->toUnicode(strUtf8.toLocal8Bit().data());
|
||||
QByteArray ByteUtf8 = utf8Codec->fromUnicode(strUnicode);
|
||||
return ByteUtf8;
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
/******************************************************************************
|
||||
* @project JTDemoUI
|
||||
* @file toolkit.h
|
||||
* @brief 常用工具包
|
||||
*
|
||||
* @author LWQ
|
||||
* @date 2021/12/01/10/23/43
|
||||
* @history
|
||||
*****************************************************************************/
|
||||
#ifndef TOOLKIT_H
|
||||
#define TOOLKIT_H
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
#include <QStringList>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <vector>
|
||||
#include "io.h"
|
||||
#include <iostream>
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
/********************************************//**
|
||||
* <Time File>
|
||||
***********************************************/
|
||||
|
||||
|
||||
/**
|
||||
* @brief GetTimeStamp
|
||||
* @param Stamp 时间格式"yyyy-MM-dd hh:mm:ss:zzz"
|
||||
* @return 时间戳
|
||||
*/
|
||||
QString GetTimeStamp(QString Stamp="yyyy-MM-dd hh:mm:ss:zzz");
|
||||
|
||||
/**
|
||||
* @brief QGetRandom
|
||||
* @param max 最大值
|
||||
* @param min 最小值
|
||||
* @param timeC 添加毫秒延时修正随机种子
|
||||
* @return 生成 min~max内的随机数
|
||||
*/
|
||||
int QGetRandom(int max,int min=0,bool timeC=true);
|
||||
|
||||
/// \brief QSetFileTimes
|
||||
/// \param filepath
|
||||
/// \param CreationTime
|
||||
/// \return 修改文件创建时间(QT 5.10版本之后有SetFileTimes)
|
||||
bool QSetFileTimes(const QString & filepath,QDateTime& CreationTime);
|
||||
|
||||
/// \brief createMultipleFoldes
|
||||
/// \param fullDirName
|
||||
/// \param
|
||||
/// \return 创建多级文件夹
|
||||
QString createMultipleFoldes(const QString & fullDirName);
|
||||
|
||||
/// \brief isDirExist
|
||||
/// \param fullDirName
|
||||
/// \param Crt 创建
|
||||
/// \return 判断文件夹是否存在,不存在则创建
|
||||
bool isDirExist(const QString & fullDirName,bool Crt=false);
|
||||
|
||||
/// \brief isFileExist
|
||||
/// \param fullFileName
|
||||
/// \param Crt 是否创建文件
|
||||
/// \return 判断文件是否存在,不存在则创建
|
||||
bool isFileExist(const QString & fullFileName,bool Crt=false);
|
||||
|
||||
/// \brief deleteDirectory
|
||||
/// \param fullFileName
|
||||
/// \param
|
||||
/// \return 删除文件夹下所有文件
|
||||
void deleteDirectory(const QString &fullFileName);
|
||||
|
||||
/// \brief addNextDirectory
|
||||
/// \param fullFileName
|
||||
/// \param isDir 只读取文件夹
|
||||
/// \param suffix 匹配文件格式
|
||||
/// \return 遍历文件夹下一层文件
|
||||
QStringList addNextDirectory(const QString &fullFileName,bool isDir=true,QString suffix="");
|
||||
|
||||
/// \brief addSubFolderDirectory
|
||||
/// \param fullFileName
|
||||
/// \param filters 匹配文件格式
|
||||
/// \return 遍历文件夹所有匹配文件
|
||||
QStringList addSubFolderDirectory(const QString &fullFileName,QStringList filters=QStringList()<<"*.jpeg"<<"*.jpg"<<"*.bmp"<<"*.png"<<"*.tiff");
|
||||
|
||||
/**
|
||||
* @brief getAllFiles 遍历文件夹所有匹配文件
|
||||
* @param path 遍历地址
|
||||
* @param files string文件名容器
|
||||
* @param format 匹配文件格式
|
||||
*/
|
||||
void getAllFiles(std::string path, std::vector<std::string>& files, std::string format);
|
||||
|
||||
/// <summary>
|
||||
/// 加载Json
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
QJsonObject loadJsonCfg(const QString path);
|
||||
|
||||
QStringList ReadTextCfg(const QString path);
|
||||
|
||||
bool WriteTXTCfg(const QStringList& parm, const QString path);
|
||||
|
||||
// 编码格式检查
|
||||
|
||||
enum class EncodingFormat : int
|
||||
{
|
||||
ANSI = 0,//GBK
|
||||
UTF16LE,
|
||||
UTF16BE,
|
||||
UTF8,
|
||||
UTF8BOM,
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief 检查文件编码
|
||||
*/
|
||||
EncodingFormat FileCharacterEncoding(const QString& fileName);
|
||||
|
||||
//csv中文读取
|
||||
QString gb2312ToUtf8(const QString strUtf8);
|
||||
|
||||
|
||||
#endif // TOOLKIT_H
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
class
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
for (int i = 0 ;i < filesMax;i++)
|
||||
{
|
||||
//std::shared_ptr <detData> data = _detDataManager->insertDetData("Manual", "Manual", 0);
|
||||
//std::shared_ptr <detData> data = _detDataManager->createDetData("Manual", "Manual", 0);
|
||||
//data->algoThreadIndex = algoIndex;
|
||||
//data->oriImgMutex.lock();
|
||||
//for(int o = 0 ; o < pathCount;o++)
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
class SummuaryDataPage :public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SummuaryDataPage() {
|
||||
SummuaryDataPage(nlohmann::json& json) {
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
QFont font("微软雅黑", 24, QFont::Bold);
|
||||
@@ -93,12 +93,12 @@ public:
|
||||
|
||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
this->setMaximumSize(9999, 9999);
|
||||
this->setObjectName(u8"生产数据");
|
||||
this->setObjectName(u8"生产数据采集");
|
||||
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
|
||||
m_title = new QLabel(u8"生产数据");
|
||||
m_title = new QLabel(u8"生产数据采集");
|
||||
m_title->setFont(font);
|
||||
m_title->setPalette(palette);
|
||||
m_title->setAlignment(Qt::AlignLeft);
|
||||
@@ -107,8 +107,16 @@ public:
|
||||
|
||||
m_mainWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_layout->addWidget(m_mainWidget);
|
||||
costomFunc();
|
||||
parsingJson(json);
|
||||
//costomFunc();
|
||||
}
|
||||
void parsingJson(nlohmann::json& json) {
|
||||
for (auto& jsonData : json) {
|
||||
if (jsonData.at("widgetType") == "WaveFormWidget") {
|
||||
addPlot(QString::fromStdString(jsonData.at("key")), jsonData.at("x"), jsonData.at("y"), jsonData.at("limitHigh"), jsonData.at("limitLow"));
|
||||
}
|
||||
}
|
||||
}
|
||||
void costomFunc() {
|
||||
double limitHigh = 1, limitLow = -1;
|
||||
addPlot("后段1-左上留白", 0, 0, limitHigh, limitLow);
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <appCore.hpp>
|
||||
const int topBarHeight = 35;
|
||||
MainWindow::MainWindow(appConfig* configIn, qtFuncBridge*bridgeIn)
|
||||
MainWindow::MainWindow(appConfig* configIn, qtFuncBridge*bridgeIn, nlohmann::json jsonIn)
|
||||
: ui(new Ui::MainWindow),
|
||||
bridge(bridgeIn),
|
||||
config(configIn),
|
||||
json(jsonIn),
|
||||
_SummuaryDataPage(jsonIn["sublUiSetting"]),
|
||||
_loadingWidget(bridgeIn)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -40,13 +40,13 @@ QT_END_NAMESPACE
|
||||
class fbBridge;
|
||||
class appConfig;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow : public QMainWindow{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(appConfig* config = nullptr,
|
||||
qtFuncBridge* bridge = nullptr);
|
||||
qtFuncBridge* bridge = nullptr,
|
||||
nlohmann::json _jsonIn = nlohmann::json());
|
||||
~MainWindow();
|
||||
//主要控件
|
||||
std::vector<toolBarButton*>pageBtns;
|
||||
@@ -68,6 +68,7 @@ private:
|
||||
Ui::MainWindow* ui;
|
||||
qtFuncBridge* bridge = nullptr;
|
||||
appConfig* config;
|
||||
nlohmann::json json;
|
||||
//动画效果
|
||||
QGraphicsBlurEffect* blurEffect;
|
||||
QPropertyAnimation* blurEffectAnimation;
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
explicit SonGraphicsView(const QString& nameIn)
|
||||
: name(nameIn),
|
||||
scene(new QGraphicsScene(this)),
|
||||
rectGroup(new QGraphicsItemGroup()),
|
||||
//rectGroup(new QGraphicsItemGroup()),
|
||||
imageWidth(1),
|
||||
imageHeight(1),
|
||||
m_isPan(false),
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
setEnabled(false);
|
||||
setObjectName("SonGraphicsView");
|
||||
|
||||
scene->addItem(rectGroup);
|
||||
//scene->addItem(rectGroup);
|
||||
setScene(scene);
|
||||
|
||||
setStyleSheet(R"(
|
||||
@@ -95,9 +95,9 @@ protected:
|
||||
startPos = mapToScene(event->pos());
|
||||
rightClicked = true;
|
||||
|
||||
rectItem = new QGraphicsRectItem(QRectF(startPos, QSizeF(0, 0)));
|
||||
rectItem->setPen(QPen(Qt::red, 5, Qt::DashLine));
|
||||
rectGroup->addToGroup(rectItem);
|
||||
//rectItem = new QGraphicsRectItem(QRectF(startPos, QSizeF(0, 0)));
|
||||
//rectItem->setPen(QPen(Qt::red, 5, Qt::DashLine));
|
||||
//rectGroup->addToGroup(rectItem);
|
||||
update();
|
||||
}
|
||||
else {
|
||||
@@ -108,12 +108,12 @@ protected:
|
||||
void mouseMoveEvent(QMouseEvent* event) override {
|
||||
currentPos = mapToScene(event->pos());
|
||||
|
||||
if (rightClicked && rectItem) {
|
||||
/* if (rightClicked && rectItem) {
|
||||
QPointF endPos = currentPos;
|
||||
qreal width = endPos.x() - startPos.x();
|
||||
qreal height = endPos.y() - startPos.y();
|
||||
rectItem->setRect(startPos.x(), startPos.y(), width, height);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (m_isPan) {
|
||||
pan(event->pos());
|
||||
@@ -129,20 +129,20 @@ protected:
|
||||
togglePan(false);
|
||||
event->accept();
|
||||
}
|
||||
else if (event->button() == Qt::RightButton) {
|
||||
rightClicked = false;
|
||||
QPointF endPos = mapToScene(event->pos());
|
||||
qreal width = endPos.x() - startPos.x();
|
||||
qreal height = endPos.y() - startPos.y();
|
||||
//else if (event->button() == Qt::RightButton) {
|
||||
// rightClicked = false;
|
||||
// QPointF endPos = mapToScene(event->pos());
|
||||
// qreal width = endPos.x() - startPos.x();
|
||||
// qreal height = endPos.y() - startPos.y();
|
||||
|
||||
deleteAllRect();
|
||||
// deleteAllRect();
|
||||
|
||||
if (width != 0 && height != 0) {
|
||||
double scaleRate = getMax(width == 0 ? 1.0 : rect().width() / width,height == 0 ? 1.0 : rect().height() / height);
|
||||
scale(scaleRate, scaleRate);
|
||||
centerOn(startPos + QPointF(width / 2, height / 2));
|
||||
}
|
||||
}
|
||||
// if (width != 0 && height != 0) {
|
||||
// double scaleRate = getMax(width == 0 ? 1.0 : rect().width() / width,height == 0 ? 1.0 : rect().height() / height);
|
||||
// scale(scaleRate, scaleRate);
|
||||
// centerOn(startPos + QPointF(width / 2, height / 2));
|
||||
// }
|
||||
//}
|
||||
else {
|
||||
event->ignore();
|
||||
}
|
||||
@@ -151,8 +151,8 @@ protected:
|
||||
private:
|
||||
QString name;
|
||||
QGraphicsScene* scene = nullptr;
|
||||
QGraphicsItemGroup* rectGroup = nullptr;
|
||||
QGraphicsRectItem* rectItem = nullptr;
|
||||
//QGraphicsItemGroup* rectGroup = nullptr;
|
||||
//QGraphicsRectItem* rectItem = nullptr;
|
||||
// QLabel* imgLabel = nullptr; // 删除
|
||||
QGraphicsPixmapItem* pixmapItem = nullptr;
|
||||
|
||||
@@ -220,7 +220,7 @@ private:
|
||||
}
|
||||
|
||||
void deleteAllRect() {
|
||||
if (!rectGroup)
|
||||
/*if (!rectGroup)
|
||||
return;
|
||||
|
||||
for (QGraphicsItem* item : rectGroup->childItems()) {
|
||||
@@ -230,7 +230,7 @@ private:
|
||||
scene->removeItem(rect);
|
||||
delete rect;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ int main(int argc, char* argv[])
|
||||
qRegisterMetaType<cv::Mat>("mat");
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w(&_core._appConfig,&bridge);
|
||||
MainWindow w(&_core._appConfig,&bridge, _core._appConfig.settingJson);
|
||||
connectSignalAndSlot(&_core, &w, &bridge); // 连接信号和槽
|
||||
w.show();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
_triggerManager->sendFinsMsg("write_short_D9405_-100");//开始检测信号
|
||||
/////////数据初始化////////
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, -1, snPos, false, true, -1);
|
||||
std::shared_ptr <detData> data = _detDataManager->insertDetData("Camera2D", sn, 0);
|
||||
std::shared_ptr <detData> data = _detDataManager->createDetData("Camera2D", sn, 0);
|
||||
data->triggerPtr = _triggerManager;//设置fins指针
|
||||
//data->_summaryData = _summaryData;//设置汇总数据指针
|
||||
data->imgAmountMin = 1;//最小图片数量
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
/////////数据初始化////////
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray,-1, snPos, false, true, -1);
|
||||
//sn = "123";
|
||||
std::shared_ptr <detData> data = _detDataManager->insertDetData("Camera3D", sn, 0);
|
||||
std::shared_ptr <detData> data = _detDataManager->createDetData("Camera3D", sn, 0);
|
||||
data->triggerPtr = _triggerManager;//设置fins指针
|
||||
//data->_summaryData = _summaryData;//设置汇总数据指针
|
||||
//data->imgAmountMin = 2;//最小图片数量
|
||||
|
||||
@@ -59,20 +59,14 @@ public:
|
||||
_triggerManager->writeShort({ "D9200_0","D9201_1","D9202_1" });
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->insertDetData("2.5D-H-1",sn, 3,
|
||||
_detDataManager->createDetData("2.5D-H-1",sn, 3,
|
||||
([this](std::shared_ptr <detData>data) {
|
||||
HouDuan12ResultHandle(data);
|
||||
}), processAlgo);
|
||||
|
||||
}), processAlgo, _25DCamera_1->config.oriSaveFormat);
|
||||
_25DCamera_1->captureImage(data);
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("2.5D-1 后段检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道1 SN:" << sn << "检测开始" << std::endl;
|
||||
////////拍照////////////////
|
||||
_25DCamera_1->captureImage(data);
|
||||
//data->oriImgs.push_back(cv::imread("D:/952Code/2025-06-04-1752578989220/2.5D-H-1_2025-06-04-1752578989220__17-41-08-45_Count0.bmp", -1));
|
||||
//data->oriImgs.push_back(cv::imread("D:/952Code/2025-06-04-1752578989220/2.5D-H-1_2025-06-04-1752578989220__17-41-08-45_Count1.bmp", -1));
|
||||
//data->oriImgs.push_back(cv::imread("D:/952Code/2025-06-04-1752578989220/2.5D-H-1_2025-06-04-1752578989220__17-41-08-45_Count2.bmp", -1));
|
||||
//data->imgSaveFileParameter.push_back(sn);
|
||||
//data->imgSaveFileParameter.push_back(_core._detGlobalData.productTypeStr);
|
||||
if(houduan1SecondTime == false)
|
||||
data->resultImgShowSet.push_back(new showImgPack("后段1-1", "结果图"));
|
||||
else
|
||||
@@ -88,16 +82,13 @@ public:
|
||||
_triggerManager->writeShort({"D9600_0","D9601_1","D9602_1"});
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->insertDetData("2.5D-H-2", sn, 3,
|
||||
_detDataManager->createDetData("2.5D-H-2", sn, 3,
|
||||
[this](std::shared_ptr <detData>data) {
|
||||
HouDuan12ResultHandle(data);
|
||||
}, processAlgo);
|
||||
|
||||
}, processAlgo, _25DCamera_2->config.oriSaveFormat);
|
||||
_25DCamera_2->captureImage(data);
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("2.5D-2 后段检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道2 SN:" << sn << "检测开始" << std::endl;
|
||||
_25DCamera_2->captureImage(data);
|
||||
data->imgSaveNameParameter.push_back(sn);
|
||||
//data->imgSaveFileParameter.push_back(_core._detGlobalData.productTypeStr);
|
||||
if (houduan2SecondTime == false)
|
||||
data->resultImgShowSet.push_back(new showImgPack("后段2-1", "结果图"));
|
||||
else
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
#include <triggerManager.h>
|
||||
#include <cameraManager.h>
|
||||
#include <missonBase.hpp>
|
||||
#include <summaryData.h>
|
||||
//#include <sql/qSqlBase.hpp>
|
||||
#include <qtBridge.h>
|
||||
#include <hdevengine/HDevEngineCpp.h>
|
||||
#include <EVE_952_15_H_Algo.hpp>
|
||||
|
||||
struct M952_15_H_summaryData
|
||||
{
|
||||
QString LT_Distance = "-1";
|
||||
QString RT_Distance = "-1";
|
||||
QString LD_Distance = "-1";
|
||||
QString RD_Distance = "-1";
|
||||
QString L_Duiqidu = "-1";
|
||||
QString R_Duiqidu = "-1";
|
||||
};
|
||||
class M952_15_H : public mission {
|
||||
public:
|
||||
summaryData<M952_15_H_summaryData> _summaryData;
|
||||
bool init(cameraManager* _cameraManagerPtr,
|
||||
triggerManager* _triggerManagerPtr,
|
||||
detDataManager* _detDataManagerPtr,
|
||||
detThreadManager* _threadManagerPtr,
|
||||
SQLiteDB* _SQLiteDB, qtFuncBridge* bridgeIn) {
|
||||
bridge = bridgeIn;
|
||||
_cameraManager = _cameraManagerPtr;
|
||||
_triggerManager = _triggerManagerPtr;
|
||||
_detDataManager = _detDataManagerPtr;
|
||||
_threadManager = _threadManagerPtr;
|
||||
|
||||
_25DCamera_1 = _cameraManager->getCamera("25D-1");
|
||||
if (_25DCamera_1 == nullptr) {
|
||||
std::cout << "camera ->> 25D-1 not found" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_25DCamera_2 = _cameraManager->getCamera("25D-2");
|
||||
if (_25DCamera_2 == nullptr){
|
||||
std::cout << "camera ->> 25D-2 not found" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_triggerManager->registerCallback(9200, 1, [this](QByteArray& byteArray) {HouDuan1(byteArray); }, "25D-1拍照触发");
|
||||
_triggerManager->registerCallback(9600, 1, [this](QByteArray& byteArray) {HouDuan2(byteArray); }, "25D-2拍照触发");
|
||||
|
||||
_triggerManager->registerCallback(9400, 1, [this](QByteArray& byteArray) {sumRequest1(byteArray); }, "25D-1结果获取触发");
|
||||
_triggerManager->registerCallback(9800, 1, [this](QByteArray& byteArray) {sumRequest2(byteArray); }, "25D-2结果获取触发");
|
||||
HDevEngineCpp::HDevEngine myEngine;
|
||||
myEngine.SetProcedurePath("./halconAlgoFiles/AlgoLibrary_952.hdpl");
|
||||
return true;
|
||||
}
|
||||
//9200 1
|
||||
bool houduan1SecondTime = false;
|
||||
void HouDuan1(QByteArray& byteArray){
|
||||
int snPos = 9300;
|
||||
_triggerManager->writeShort({ "D9200_0","D9201_1","D9202_1" });
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->insertDetData("2.5D-H-1",sn, 3,
|
||||
([this](std::shared_ptr <detData>data) {
|
||||
HouDuan12ResultHandle(data);
|
||||
}), processAlgo);
|
||||
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("2.5D-1 后段检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道1 SN:" << sn << "检测开始" << std::endl;
|
||||
////////拍照////////////////
|
||||
_25DCamera_1->captureImage(data);
|
||||
//data->oriImgs.push_back(cv::imread("D:/952Code/2025-06-04-1752578989220/2.5D-H-1_2025-06-04-1752578989220__17-41-08-45_Count0.bmp", -1));
|
||||
//data->oriImgs.push_back(cv::imread("D:/952Code/2025-06-04-1752578989220/2.5D-H-1_2025-06-04-1752578989220__17-41-08-45_Count1.bmp", -1));
|
||||
//data->oriImgs.push_back(cv::imread("D:/952Code/2025-06-04-1752578989220/2.5D-H-1_2025-06-04-1752578989220__17-41-08-45_Count2.bmp", -1));
|
||||
//data->imgSaveFileParameter.push_back(sn);
|
||||
//data->imgSaveFileParameter.push_back(_core._detGlobalData.productTypeStr);
|
||||
if(houduan1SecondTime == false)
|
||||
data->resultImgShowSet.push_back(new showImgPack("后段1-1", "结果图"));
|
||||
else
|
||||
data->resultImgShowSet.push_back(new showImgPack("后段1-2", "结果图"));
|
||||
houduan1SecondTime = !houduan1SecondTime;
|
||||
_threadManager->addTask(data);
|
||||
}
|
||||
|
||||
//9600 1
|
||||
bool houduan2SecondTime = false;
|
||||
void HouDuan2(QByteArray& byteArray){
|
||||
int snPos = 9700;
|
||||
_triggerManager->writeShort({"D9600_0","D9601_1","D9602_1"});
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->insertDetData("2.5D-H-2", sn, 3,
|
||||
[this](std::shared_ptr <detData>data) {
|
||||
HouDuan12ResultHandle(data);
|
||||
}, processAlgo);
|
||||
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("2.5D-2 后段检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道2 SN:" << sn << "检测开始" << std::endl;
|
||||
_25DCamera_2->captureImage(data);
|
||||
data->imgSaveNameParameter.push_back(sn);
|
||||
//data->imgSaveFileParameter.push_back(_core._detGlobalData.productTypeStr);
|
||||
if (houduan2SecondTime == false)
|
||||
data->resultImgShowSet.push_back(new showImgPack("后段2-1", "结果图"));
|
||||
else
|
||||
data->resultImgShowSet.push_back(new showImgPack("后段2-2", "结果图"));
|
||||
houduan2SecondTime = !houduan2SecondTime;
|
||||
_threadManager->addTask(data);
|
||||
}
|
||||
|
||||
void HouDuan12ResultHandle(std::shared_ptr <detData>data){
|
||||
//发送图片
|
||||
if (data->resultImgs.size() > 0){
|
||||
for (int i = 0; i < data->resultImgs.size() && i < data->resultImgShowSet.size(); i++){
|
||||
showImgPack* pack = data->resultImgShowSet[std::min(i, (int)data->resultImgShowSet.size() - 1)];
|
||||
QPixmap pixmap = cvMatToQPixMap(data->resultImgs[i]);
|
||||
pack->img = pixmap;
|
||||
emit bridge->displayWidget_sendImg(pack);
|
||||
pixmap = QPixmap();
|
||||
}
|
||||
}
|
||||
//结果数据保存
|
||||
if (data->resultData.size() > 0){
|
||||
std::string sn = data->SNcode;
|
||||
try {
|
||||
M952_15_H_summaryData* dataPtr = _summaryData.get(sn);
|
||||
dataPtr->LT_Distance = data->resultData["LT_Distance"].toString();
|
||||
dataPtr->RT_Distance = data->resultData["RT_Distance"].toString();
|
||||
dataPtr->LD_Distance = data->resultData["LD_Distance"].toString();
|
||||
dataPtr->RD_Distance = data->resultData["RD_Distance"].toString();
|
||||
dataPtr->L_Duiqidu = data->resultData["L_Duiqidu"].toString();
|
||||
dataPtr->R_Duiqidu = data->resultData["R_Duiqidu"].toString();
|
||||
|
||||
if (data->cameraKeyName == "2.5D-H-1") {
|
||||
emit bridge->summaryData_addData("后段1-左上留白", data->resultData["LT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段1-右上留白", data->resultData["RT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段1-左下留白", data->resultData["LD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段1-右下留白", data->resultData["RD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段1-左对齐度", data->resultData["L_Duiqidu"].toDouble());
|
||||
emit bridge->summaryData_addData("后段1-右对齐度", data->resultData["R_Duiqidu"].toDouble());
|
||||
}
|
||||
else{
|
||||
emit bridge->summaryData_addData("后段2-左上留白", data->resultData["LT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段2-右上留白", data->resultData["RT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段2-左下留白", data->resultData["LD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段2-右下留白", data->resultData["RD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("后段2-左对齐度", data->resultData["L_Duiqidu"].toDouble());
|
||||
emit bridge->summaryData_addData("后段2-右对齐度", data->resultData["R_Duiqidu"].toDouble());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (...) {
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("后段检测结果数据异常 SN:") << QString::fromStdString(data->SNcode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("后段检测结果数据为空 SN:") << QString::fromStdString(data->SNcode);
|
||||
}
|
||||
std::cout << "SN:" << data->SNcode << "检测结束 结果获取完成" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//9400 1 Summary1
|
||||
void sumRequest1(QByteArray& byteArray)
|
||||
{
|
||||
_triggerManager->sendFinsMsg("write_short_D9400_0");
|
||||
_triggerManager->sendFinsMsg("write_short_D9402_1");
|
||||
_triggerManager->sendFinsMsg("write_short_D9404_1");
|
||||
int snPos = 9500;
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
M952_15_H_summaryData* dataPtr = _summaryData.get(sn);
|
||||
_triggerManager->sendFinsMsg("write_float_D9410_"+ dataPtr->RT_Distance);//右上留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9412_" + dataPtr->RD_Distance);//右下留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9414_" + dataPtr->R_Duiqidu);//右对其度
|
||||
|
||||
_triggerManager->sendFinsMsg("write_float_D9436_" + dataPtr->RT_Distance);//左上留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9438_" + dataPtr->RD_Distance);//左下留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9440_" + dataPtr->R_Duiqidu);//左对其度
|
||||
std::cout << "通道1 SN:" << sn << " 发送结果" << std::endl;//:\n左留白->" << dataPtr->leftLiuBai.toStdString() << "\n右留白->" << dataPtr->rightLiuBai.toStdString() << "\n对其度->" << dataPtr->duiqidu.toStdString()<<std::endl;
|
||||
_summaryData.remove(sn);
|
||||
}
|
||||
//9800 1 Summary1
|
||||
void sumRequest2(QByteArray& byteArray)
|
||||
{
|
||||
_triggerManager->sendFinsMsg("write_short_D9800_0");
|
||||
_triggerManager->sendFinsMsg("write_short_D9802_1");
|
||||
_triggerManager->sendFinsMsg("write_short_D9804_1");
|
||||
int snPos = 9900;
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
M952_15_H_summaryData* dataPtr = _summaryData.get(sn);
|
||||
_triggerManager->sendFinsMsg("write_float_D9810_" + dataPtr->RT_Distance);//右上留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9812_" + dataPtr->RD_Distance);//右下留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9814_" + dataPtr->R_Duiqidu);//右对其度
|
||||
|
||||
_triggerManager->sendFinsMsg("write_float_D9836_" + dataPtr->RT_Distance);//左上留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9838_" + dataPtr->RD_Distance);//左下留白
|
||||
_triggerManager->sendFinsMsg("write_float_D9840_" + dataPtr->R_Duiqidu);//左对其度
|
||||
std::cout << "通道2 SN:" << sn << " 获取结果"<<std::endl;//:\n左留白->" << dataPtr->leftLiuBai.toStdString() << "\n右留白->" << dataPtr->rightLiuBai.toStdString() << "\n对其度->" << dataPtr->duiqidu.toStdString() << std::endl;
|
||||
_summaryData.remove(sn);
|
||||
}
|
||||
static bool processAlgo(std::shared_ptr <detData> data, handleAiModelManager* _handleAiModelManager)
|
||||
{
|
||||
try
|
||||
{
|
||||
data->algoStartTime = std::chrono::high_resolution_clock::now();
|
||||
_952_15_H_Algo(data);
|
||||
data->algoEndTime = std::chrono::high_resolution_clock::now();
|
||||
return true;
|
||||
}
|
||||
catch (HDevEngineCpp::HDevEngineException& ex) {
|
||||
std::cerr << "HDevEngineException: " << ex.Message() << std::endl;
|
||||
qDebug() << "HDevEngineException: " << ex.Message();
|
||||
}
|
||||
catch (HException& ex) {
|
||||
// 捕获Halcon异常
|
||||
std::cerr << "Halcon Exception Caught!" << std::endl;
|
||||
std::cerr << "Error Code: " << ex.ErrorCode() << std::endl;
|
||||
std::cerr << "Error Message: " << ex.ErrorMessage() << std::endl;
|
||||
|
||||
qDebug() << "Halcon Exception Caught!";
|
||||
qDebug() << "Error Code: " << ex.ErrorCode();
|
||||
qDebug() << "Error Message: " << ex.ErrorMessage();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << "Caught exception: " << e.what() << std::endl;
|
||||
qDebug() << "Caught exception: " << e.what();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
camera* _25DCamera_1 = nullptr, * _25DCamera_2 = nullptr;
|
||||
qtFuncBridge* bridge;
|
||||
cameraManager* _cameraManager;
|
||||
triggerManager* _triggerManager;
|
||||
detDataManager* _detDataManager;
|
||||
detThreadManager* _threadManager;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#include <952_15_H_25D.h>
|
||||
#include <952_15_Q_25D.h>
|
||||
|
||||
mission* createMission() {
|
||||
return new M952_15_H();
|
||||
return new M952_15_Q();
|
||||
}
|
||||
void destroyMission(mission* _mission) {
|
||||
delete _mission;
|
||||
@@ -0,0 +1,191 @@
|
||||
#include <triggerManager.h>
|
||||
#include <cameraManager.h>
|
||||
#include <missonBase.hpp>
|
||||
#include <summaryData.h>
|
||||
//#include <sql/qSqlBase.hpp>
|
||||
#include <qtBridge.h>
|
||||
#include <hdevengine/HDevEngineCpp.h>
|
||||
|
||||
struct M952_15_Q_summaryData
|
||||
{
|
||||
QString LT_Distance = "-1";
|
||||
QString RT_Distance = "-1";
|
||||
QString LD_Distance = "-1";
|
||||
QString RD_Distance = "-1";
|
||||
QString L_Duiqidu = "-1";
|
||||
QString R_Duiqidu = "-1";
|
||||
};
|
||||
class M952_15_Q : public mission {
|
||||
public:
|
||||
summaryData<M952_15_Q_summaryData> _summaryData;
|
||||
bool init(cameraManager* _cameraManagerPtr,
|
||||
triggerManager* _triggerManagerPtr,
|
||||
detDataManager* _detDataManagerPtr,
|
||||
detThreadManager* _threadManagerPtr,
|
||||
nlohmann::json& _missionJson,
|
||||
SQLiteDB* _SQLiteDB, qtFuncBridge* bridgeIn) {
|
||||
bridge = bridgeIn;
|
||||
_cameraManager = _cameraManagerPtr;
|
||||
_triggerManager = _triggerManagerPtr;
|
||||
_detDataManager = _detDataManagerPtr;
|
||||
_threadManager = _threadManagerPtr;
|
||||
|
||||
_25DCamera_1 = _cameraManager->getCamera("25D-1");
|
||||
if (_25DCamera_1 == nullptr) {
|
||||
std::cout << "camera ->> 25D-1 not found" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_25DCamera_2 = _cameraManager->getCamera("25D-2");
|
||||
if (_25DCamera_2 == nullptr){
|
||||
std::cout << "camera ->> 25D-2 not found" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_triggerManager->registerCallback(8000, 1, [this](QByteArray& byteArray) {qianduan1(byteArray); }, "25D-1拍照触发");
|
||||
_triggerManager->registerCallback(8050, 1, [this](QByteArray& byteArray) {qianduan2(byteArray); }, "25D-2拍照触发");
|
||||
|
||||
_triggerManager->registerCallback(8040, 1, [this](QByteArray& byteArray) {sumRequest1(byteArray); }, "25D-1结果获取触发");
|
||||
_triggerManager->registerCallback(8090, 1, [this](QByteArray& byteArray) {sumRequest2(byteArray); }, "25D-2结果获取触发");
|
||||
HDevEngineCpp::HDevEngine myEngine;
|
||||
myEngine.SetProcedurePath("./halconAlgoFiles/AlgoLibrary_952.hdpl");
|
||||
return true;
|
||||
}
|
||||
//9200 1
|
||||
bool qianduan1SecondTime = false;
|
||||
void qianduan1(QByteArray& byteArray){
|
||||
int snPos = 8100;
|
||||
_triggerManager->writeShort({ "D8000_0","D8001_1","D8002_1" });
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->createDetData("2.5D-Q-1",sn, 3,
|
||||
([this](std::shared_ptr <detData>data) {
|
||||
qianduan12ResultHandle(data);
|
||||
}), processAlgo, _25DCamera_1->config.oriSaveFormat);
|
||||
_25DCamera_1->captureImage(data);
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("2.5D-1 前段检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道1 SN:" << sn << "检测开始" << std::endl;
|
||||
////////拍照////////////////
|
||||
if(qianduan1SecondTime == false)
|
||||
data->resultImgShowSet.push_back(new showImgPack("前段1-1", "结果图"));
|
||||
else
|
||||
data->resultImgShowSet.push_back(new showImgPack("前段1-2", "结果图"));
|
||||
qianduan1SecondTime = !qianduan1SecondTime;
|
||||
_threadManager->addTask(data);
|
||||
}
|
||||
|
||||
//9600 1
|
||||
bool qianduan2SecondTime = false;
|
||||
void qianduan2(QByteArray& byteArray){
|
||||
int snPos = 8600;
|
||||
_triggerManager->writeShort({"D8050_0","D8051_1","D8052_1"});
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->createDetData("2.5D-Q-2", sn, 3,
|
||||
[this](std::shared_ptr <detData>data) {
|
||||
qianduan12ResultHandle(data);
|
||||
}, processAlgo, _25DCamera_2->config.oriSaveFormat);
|
||||
_25DCamera_2->captureImage(data);
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("2.5D-2 前段检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道2 SN:" << sn << "检测开始" << std::endl;
|
||||
if (qianduan2SecondTime == false)
|
||||
data->resultImgShowSet.push_back(new showImgPack("前段2-1", "结果图"));
|
||||
else
|
||||
data->resultImgShowSet.push_back(new showImgPack("前段2-2", "结果图"));
|
||||
qianduan2SecondTime = !qianduan2SecondTime;
|
||||
_threadManager->addTask(data);
|
||||
}
|
||||
|
||||
void qianduan12ResultHandle(std::shared_ptr <detData>data){
|
||||
//发送图片
|
||||
if (data->resultImgs.size() > 0){
|
||||
for (int i = 0; i < data->resultImgs.size() && i < data->resultImgShowSet.size(); i++){
|
||||
showImgPack* pack = data->resultImgShowSet[std::min(i, (int)data->resultImgShowSet.size() - 1)];
|
||||
QPixmap pixmap = cvMatToQPixMap(data->resultImgs[i]);
|
||||
pack->img = pixmap;
|
||||
emit bridge->displayWidget_sendImg(pack);
|
||||
pixmap = QPixmap();
|
||||
}
|
||||
}
|
||||
//结果数据保存
|
||||
if (data->resultData.size() > 0){
|
||||
std::string sn = data->SNcode;
|
||||
try {
|
||||
M952_15_Q_summaryData* dataPtr = _summaryData.get(sn);
|
||||
dataPtr->LT_Distance = data->resultData["LT_Distance"].toString();
|
||||
dataPtr->RT_Distance = data->resultData["RT_Distance"].toString();
|
||||
dataPtr->LD_Distance = data->resultData["LD_Distance"].toString();
|
||||
dataPtr->RD_Distance = data->resultData["RD_Distance"].toString();
|
||||
dataPtr->L_Duiqidu = data->resultData["L_Duiqidu"].toString();
|
||||
dataPtr->R_Duiqidu = data->resultData["R_Duiqidu"].toString();
|
||||
|
||||
if (data->cameraKeyName == "2.5D-Q-1") {
|
||||
emit bridge->summaryData_addData("前段1-左上留白", data->resultData["LT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段1-右上留白", data->resultData["RT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段1-左下留白", data->resultData["LD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段1-右下留白", data->resultData["RD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段1-左对齐度", data->resultData["L_Duiqidu"].toDouble());
|
||||
emit bridge->summaryData_addData("前段1-右对齐度", data->resultData["R_Duiqidu"].toDouble());
|
||||
}
|
||||
else{
|
||||
emit bridge->summaryData_addData("前段2-左上留白", data->resultData["LT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段2-右上留白", data->resultData["RT_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段2-左下留白", data->resultData["LD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段2-右下留白", data->resultData["RD_Distance"].toDouble());
|
||||
emit bridge->summaryData_addData("前段2-左对齐度", data->resultData["L_Duiqidu"].toDouble());
|
||||
emit bridge->summaryData_addData("前段2-右对齐度", data->resultData["R_Duiqidu"].toDouble());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (...) {
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("前段检测结果数据异常 SN:") << QString::fromStdString(data->SNcode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("前段检测结果数据为空 SN:") << QString::fromStdString(data->SNcode);
|
||||
}
|
||||
std::cout << "SN:" << data->SNcode << "检测结束 结果获取完成" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//9400 1 Summary1
|
||||
void sumRequest1(QByteArray& byteArray)
|
||||
{
|
||||
_triggerManager->writeShort("D8040_0");
|
||||
int snPos = 8500;
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
M952_15_Q_summaryData* dataPtr = _summaryData.get(sn);
|
||||
_summaryData.remove(sn);
|
||||
}
|
||||
//9800 1 Summary1
|
||||
void sumRequest2(QByteArray& byteArray)
|
||||
{
|
||||
_triggerManager->writeShort("D8090_0");
|
||||
int snPos = 9000;
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
M952_15_Q_summaryData* dataPtr = _summaryData.get(sn);
|
||||
_summaryData.remove(sn);
|
||||
}
|
||||
static bool processAlgo(std::shared_ptr <detData> data, handleAiModelManager* _handleAiModelManager)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
camera* _25DCamera_1 = nullptr, * _25DCamera_2 = nullptr;
|
||||
qtFuncBridge* bridge;
|
||||
cameraManager* _cameraManager;
|
||||
triggerManager* _triggerManager;
|
||||
detDataManager* _detDataManager;
|
||||
detThreadManager* _threadManager;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
@@ -1,110 +0,0 @@
|
||||
#include <detData.h>
|
||||
#include <simpleAlgo.h>
|
||||
#include <hdevengine/HDevEngineCpp.h>
|
||||
#include <opencvPaintAlgo.hpp>
|
||||
using namespace HDevEngineCpp;
|
||||
|
||||
static void _952_15_H_Algo(std::shared_ptr <detData> data)
|
||||
{
|
||||
qDebug() << "SN" << QString::fromStdString(data->SNcode)<< "algo start";
|
||||
HDevEngineCpp::HDevProcedure proc("Cal_LouBai_Distance");
|
||||
HDevProcedureCall procedureCall(proc);
|
||||
|
||||
///////////////////取图//处理//////////////////
|
||||
if (data->oriImgs.size() != 3 )
|
||||
{
|
||||
qCritical() << "图片数量不满足要求:" << data->oriImgs.size();
|
||||
return;
|
||||
}
|
||||
|
||||
cv::Mat Paint;
|
||||
clock_t start, finish;
|
||||
start = clock();
|
||||
|
||||
cv::Mat src1 = data->oriImgs[1];
|
||||
cv::Mat src2 = data->oriImgs[0];
|
||||
src1.copyTo(Paint);
|
||||
|
||||
if (Paint.channels() != 3)
|
||||
cv::cvtColor(Paint, Paint, cv::COLOR_GRAY2BGR);
|
||||
|
||||
HObject in_Image1 = MatToHObject(src1);
|
||||
HObject in_Image2 = MatToHObject(src2);
|
||||
procedureCall.SetInputIconicParamObject("in_Image1", in_Image1);
|
||||
procedureCall.SetInputIconicParamObject("in_Image2", in_Image2);
|
||||
procedureCall.SetInputCtrlParamTuple("in_xResolution", HTuple(0.0323938));
|
||||
procedureCall.SetInputCtrlParamTuple("in_yResolution", HTuple(0.0366128));
|
||||
procedureCall.Execute();
|
||||
|
||||
HTuple out_Distance, out_ResultRows, out_ResultCols, out_Flag, out_LinePonit;
|
||||
|
||||
out_Distance = procedureCall.GetOutputCtrlParamTuple("out_Distance");
|
||||
//out_RightDistance = procedureCall.GetOutputCtrlParamTuple("out_RightDistance");
|
||||
out_ResultRows = procedureCall.GetOutputCtrlParamTuple("out_ResultRows");
|
||||
out_ResultCols = procedureCall.GetOutputCtrlParamTuple("out_ResultCols");
|
||||
|
||||
//out_Angle = procedureCall.GetOutputCtrlParamTuple("out_Angle");
|
||||
out_LinePonit = procedureCall.GetOutputCtrlParamTuple("out_LinePonit");
|
||||
|
||||
out_Flag = procedureCall.GetOutputCtrlParamTuple("out_Flag");
|
||||
|
||||
int algoFlag = out_Flag.D();
|
||||
double LT_Distance = -1, RT_Distance = -1, LD_Distance = -1, RD_Distance = -1, L_Duiqidu = -1 ,R_Duiqidu = -1;
|
||||
if (algoFlag == 1) // 算法OK
|
||||
{
|
||||
LT_Distance = out_Distance[0].D() + 0.86;//左上
|
||||
putTextZH(Paint, "左上留白:" + std::to_string(LT_Distance), cv::Point(100, 100), 150, cv::Scalar(0, 255, 0));
|
||||
|
||||
RT_Distance = out_Distance[1].D() + 0.52;//右上
|
||||
putTextZH(Paint, "右上留白:" + std::to_string(RT_Distance), cv::Point(100, 250), 150, cv::Scalar(0, 255, 0));
|
||||
|
||||
LD_Distance = out_Distance[2].D() + 0.86;//左下
|
||||
putTextZH(Paint, "左下留白:" + std::to_string(LD_Distance), cv::Point(100, 400), 150, cv::Scalar(0, 255, 0));
|
||||
|
||||
RD_Distance = out_Distance[3].D() + 0.52;//右下
|
||||
putTextZH(Paint, "右下留白:" + std::to_string(RD_Distance), cv::Point(100, 550), 150, cv::Scalar(0, 255, 0));
|
||||
|
||||
int outPointRowsLength = out_ResultRows.Length();
|
||||
for (int i = 0; i < outPointRowsLength; i++)
|
||||
Cross(Paint,
|
||||
cv::Point(out_ResultCols[i].D(), out_ResultRows[i].D()),
|
||||
3, 2, cv::Scalar(0, 0, 255));
|
||||
|
||||
//duiqidu = out_Angle.D();
|
||||
L_Duiqidu = std::abs(LT_Distance - LD_Distance);
|
||||
putTextZH(Paint, "左对齐度:" + std::to_string(L_Duiqidu), cv::Point(100, 700), 150, cv::Scalar(0, 255, 0));
|
||||
R_Duiqidu = std::abs(RT_Distance - RD_Distance);
|
||||
putTextZH(Paint, "右对齐度:" + std::to_string(R_Duiqidu), cv::Point(100, 850), 150, cv::Scalar(0, 255, 0));
|
||||
int out_LinePonitLength = out_LinePonit.Length() / 4;
|
||||
for (int i = 0; i < out_LinePonitLength; i++)
|
||||
line(Paint,
|
||||
cv::Point(out_LinePonit[i * 4 + 1].D(), out_LinePonit[i * 4].D()),
|
||||
cv::Point(out_LinePonit[i * 4 + 3].D(), out_LinePonit[i * 4 + 2].D()),
|
||||
cv::Scalar(0, 0, 255) , 3);
|
||||
|
||||
data->halconOK = true;
|
||||
}
|
||||
else // 算法异常
|
||||
{
|
||||
putTextZH(Paint, "算法异常",
|
||||
cv::Point(100, 100), 300 , cv::Scalar(0, 0, 255));
|
||||
|
||||
data->halconOK = false;
|
||||
}
|
||||
data->resultImgs.push_back(Paint);
|
||||
|
||||
|
||||
//data->resultImgs.push_back(Paint);
|
||||
// data->sqlVec.push_back({ "Gluewidth",std::to_string(Gluewidth) });
|
||||
// data->sqlVec.push_back({ "_2dResult",std::to_string(result) });
|
||||
// qDebug() << "[Debug]2D Data:" << "hv_out_Gluewidth ::" << QString::number(Gluewidth) << ",Result" << QString::number(result);
|
||||
data->resultData.insert(std::make_pair("LT_Distance", LT_Distance));
|
||||
data->resultData.insert(std::make_pair("RT_Distance", RT_Distance));
|
||||
data->resultData.insert(std::make_pair("LD_Distance", LD_Distance));
|
||||
data->resultData.insert(std::make_pair("RD_Distance", RD_Distance));
|
||||
data->resultData.insert(std::make_pair("L_Duiqidu", L_Duiqidu));
|
||||
data->resultData.insert(std::make_pair("R_Duiqidu", R_Duiqidu));
|
||||
finish = clock();
|
||||
qDebug() << "[Debug]2D useTime:" << finish - start << "ms";
|
||||
}
|
||||
#pragma once
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#include <952_15_Q_2D3D_1.h>
|
||||
#include <952_15_Q_2D3D.h>
|
||||
|
||||
mission* createMission() {
|
||||
return new _952_15_Q_2D3D_1();
|
||||
+19
-56
@@ -2,7 +2,6 @@
|
||||
#include <cameraManager.h>
|
||||
#include <missonBase.hpp>
|
||||
#include <summaryData.h>
|
||||
//#include <sql/qSqlBase.hpp>
|
||||
#include <qtBridge.h>
|
||||
#include <hdevengine/HDevEngineCpp.h>
|
||||
//#include <952HouDuan/EVE_952_15_H_Algo.hpp>
|
||||
@@ -110,68 +109,59 @@ public:
|
||||
|
||||
}
|
||||
//8010 1
|
||||
bool Qian_2D_P_SecondTime = false;
|
||||
void Qian_2D_P(QByteArray& byteArray){
|
||||
int snPos = _2D_P_snPos;
|
||||
_triggerManager->writeShort(_2D_P_triggerReply);
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->insertDetData("Qian_2D_P",sn, 3,
|
||||
_detDataManager->createDetData("Qian_2D_P",sn, 3,
|
||||
([this](std::shared_ptr <detData>data) {
|
||||
HouDuan12ResultHandle(data);
|
||||
}), processAlgo);
|
||||
|
||||
}), processAlgo, _2DCamera_P->config.oriSaveFormat);
|
||||
_2DCamera_P->captureImage(data);
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("_2DCamera_P 检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道1 SN:" << sn << "检测开始" << std::endl;
|
||||
////////拍照////////////////
|
||||
_2DCamera_P->captureImage(data);
|
||||
data->oriFormat = _2DCamera_P->_cameraStruct.oriSaveFormat;
|
||||
//data->imgSaveFileParameter.push_back(sn);
|
||||
//data->imgSaveFileParameter.push_back(_core._detGlobalData.productTypeStr);
|
||||
data->resultImgShowSet.push_back(new showImgPack(_2D_P_viewName, "结果图"));
|
||||
data->resultImgShowSet.push_back(new showImgPack(_2D_P_viewName + QString::number(Qian_2D_P_SecondTime + 1), "结果图"));
|
||||
Qian_2D_P_SecondTime = !Qian_2D_P_SecondTime;
|
||||
_threadManager->addTask(data);
|
||||
}
|
||||
|
||||
//8020 1
|
||||
bool Qian_2D_N_SecondTime = false;
|
||||
void Qian_2D_N(QByteArray& byteArray) {
|
||||
int snPos = _2D_N_snPos;
|
||||
_triggerManager->writeShort(_2D_N_triggerReply);
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->insertDetData("Qian_2D_N", sn, 1,
|
||||
_detDataManager->createDetData("Qian_2D_N", sn, 1,
|
||||
([this](std::shared_ptr <detData>data) {
|
||||
HouDuan12ResultHandle(data);
|
||||
}), processAlgo);
|
||||
|
||||
}), processAlgo, _2DCamera_N->config.oriSaveFormat);
|
||||
_2DCamera_N->captureImage(data);
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("_2DCamera_P 检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道1 SN:" << sn << "检测开始" << std::endl;
|
||||
////////拍照////////////////
|
||||
_2DCamera_N->captureImage(data);
|
||||
data->oriFormat = _2DCamera_N->_cameraStruct.oriSaveFormat;
|
||||
//data->imgSaveFileParameter.push_back(sn);
|
||||
//data->imgSaveFileParameter.push_back(_core._detGlobalData.productTypeStr);
|
||||
data->resultImgShowSet.push_back(new showImgPack(_2D_N_viewName, "结果图"));
|
||||
data->resultImgShowSet.push_back(new showImgPack(_2D_N_viewName + QString::number(Qian_2D_N_SecondTime + 1), "结果图"));
|
||||
Qian_2D_N_SecondTime = !Qian_2D_N_SecondTime;
|
||||
_threadManager->addTask(data);
|
||||
}
|
||||
|
||||
//8030 1
|
||||
bool Qian_3D_1_SecondTime = false;
|
||||
void Qian_3D_1(QByteArray& byteArray) {
|
||||
int snPos = _3D_snPos;
|
||||
_triggerManager->writeShort(_3D_triggerReply);
|
||||
std::string sn = _triggerManager->readSnFromQByteArray(byteArray, snPos, false, false, -1);
|
||||
std::shared_ptr <detData> data =
|
||||
_detDataManager->insertDetData("Qian_3D", sn, 2,
|
||||
_detDataManager->createDetData("Qian_3D", sn, 2,
|
||||
([this](std::shared_ptr <detData>data) {
|
||||
HouDuan12ResultHandle(data);
|
||||
}), processAlgo);
|
||||
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("_2DCamera_P 检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道1 SN:" << sn << "检测开始" << std::endl;
|
||||
////////拍照////////////////
|
||||
}), processAlgo, _3DCamera_1->config.oriSaveFormat);
|
||||
_3DCamera_1->captureImage(data);
|
||||
data->oriFormat = _3DCamera_1->_cameraStruct.oriSaveFormat;
|
||||
//data->imgSaveFileParameter.push_back(sn);
|
||||
//data->imgSaveFileParameter.push_back(_core._detGlobalData.productTypeStr);
|
||||
data->resultImgShowSet.push_back(new showImgPack(_3D_P_viewName, "结果图"));
|
||||
qDebug() << "[ Station 10 ] " << QString::fromUtf8("_2DCamera_P 检测开始 timeCode :") << data->timeCode << data->timeCode << "SN" << QString::fromStdString(sn);;
|
||||
std::cout << "通道1 SN:" << sn << "检测开始" << std::endl;
|
||||
data->resultImgShowSet.push_back(new showImgPack(_3D_P_viewName + QString::number(Qian_3D_1_SecondTime + 1), "结果图"));
|
||||
Qian_3D_1_SecondTime = !Qian_3D_1_SecondTime;
|
||||
_threadManager->addTask(data);
|
||||
}
|
||||
|
||||
@@ -248,33 +238,6 @@ public:
|
||||
cv::putText(testImg, "result test", cv::Point(200, 200),
|
||||
1, 10,cv::Scalar(0,255,0),4);
|
||||
data->resultImgs.push_back(testImg);
|
||||
//try
|
||||
//{
|
||||
// data->algoStartTime = std::chrono::high_resolution_clock::now();
|
||||
// _952_15_H_Algo(data);
|
||||
// data->algoEndTime = std::chrono::high_resolution_clock::now();
|
||||
// return true;
|
||||
//}
|
||||
//catch (HDevEngineCpp::HDevEngineException& ex) {
|
||||
// std::cerr << "HDevEngineException: " << ex.Message() << std::endl;
|
||||
// qDebug() << "HDevEngineException: " << ex.Message();
|
||||
//}
|
||||
//catch (HException& ex) {
|
||||
// // 捕获Halcon异常
|
||||
// std::cerr << "Halcon Exception Caught!" << std::endl;
|
||||
// std::cerr << "Error Code: " << ex.ErrorCode() << std::endl;
|
||||
// std::cerr << "Error Message: " << ex.ErrorMessage() << std::endl;
|
||||
|
||||
// qDebug() << "Halcon Exception Caught!";
|
||||
// qDebug() << "Error Code: " << ex.ErrorCode();
|
||||
// qDebug() << "Error Message: " << ex.ErrorMessage();
|
||||
//}
|
||||
//catch (const std::exception& e)
|
||||
//{
|
||||
// std::cerr << "Caught exception: " << e.what() << std::endl;
|
||||
// qDebug() << "Caught exception: " << e.what();
|
||||
// return false;
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user