backup
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# 获取获取当前目录名
|
||||
get_filename_component(CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model start : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
|
||||
set(DLL_NAMES "opencv" "halcon" "halconAlgo" "myTools" "handdleAI")
|
||||
foreach(child ${DLL_NAMES})
|
||||
LIST(APPEND ENV_INCLUDE ${${child}_include})
|
||||
LIST(APPEND ENV_LIB ${${child}_lib})
|
||||
LIST(APPEND ENV_TARGET ${${child}_target_link})
|
||||
endforeach()
|
||||
message(" ENV_INCLUDE : " ${ENV_INCLUDE} )
|
||||
message(" ENV_LIB : " ${ENV_LIB} )
|
||||
message(" ENV_TARGET : " ${ENV_TARGET} )
|
||||
include_directories(
|
||||
|
||||
${ENV_INCLUDE}
|
||||
)
|
||||
|
||||
link_directories (
|
||||
${ENV_LIB}
|
||||
|
||||
)
|
||||
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
FILE(GLOB HEAD_FILES "./*.h" )
|
||||
FILE(GLOB SRC_FILES "./*.cpp")
|
||||
FILE(GLOB UI_FILES "./*.ui")
|
||||
|
||||
|
||||
#find_package(Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS network REQUIRED)
|
||||
add_library(${CURRENT_FOLDER} SHARED
|
||||
${HEAD_FILES}
|
||||
${SRC_FILES}
|
||||
${UI_FILES}
|
||||
)
|
||||
|
||||
|
||||
|
||||
set_target_properties(${CURRENT_FOLDER} PROPERTIES LINKER_LANGUAGE C
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
|
||||
)
|
||||
|
||||
|
||||
target_link_libraries(${CURRENT_FOLDER} PRIVATE
|
||||
${ENV_TARGET}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
)
|
||||
|
||||
|
||||
# target_compile_definitions(${CURRENT_FOLDER} PRIVATE HD_AIDEMO_MODULE_LIBRARY)
|
||||
|
||||
|
||||
|
||||
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model end : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,114 @@
|
||||
#ifndef Hd_AI_algo_fangBaoFa_H
|
||||
#define Hd_AI_algo_fangBaoFa_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <atlstr.h>
|
||||
#include <chrono>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include <qqueue.h>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <halconcpp/HalconCpp.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "imgproc/imgproc_c.h"
|
||||
#include "base.h"
|
||||
#include "handleAI.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
|
||||
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct;
|
||||
//{
|
||||
// cv::Mat out_Mat;
|
||||
// std::string saveKey; //关键字,用于LOG日志
|
||||
// std::string savePath; //保存路径
|
||||
//};
|
||||
|
||||
//初始化流程(一次):Hd_AI_algo_fangBaoFa,initParas
|
||||
//运行流程:writeData主线程把数据传过来,run,readData此线程把数据传主线程
|
||||
class Hd_AI_algo_fangBaoFa :public Base
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Hd_AI_algo_fangBaoFa();
|
||||
virtual ~Hd_AI_algo_fangBaoFa();
|
||||
//从类中读数据到实例对象
|
||||
bool readData(std::vector<cv::Mat>&,QByteArray&);
|
||||
//实例对象把数据写入到类
|
||||
bool writeData(std::vector<cv::Mat>&, QByteArray&);
|
||||
bool initParas(QByteArray&);
|
||||
//运行(Logic_taskthread.cpp)
|
||||
bool run();
|
||||
//线程状态
|
||||
bool checkStatus();// { return true; };
|
||||
|
||||
bool encodeResultValue(QVector<std::string> append_value,QByteArray &resultByte);
|
||||
bool decodeAiValue(QByteArray byte,QVector<QByteArray> &vec_ret);
|
||||
//---------检测流程,根据实际项目修改---------
|
||||
bool AIdetect(cv::Mat img2D, QString saveKey, QString Dir2D, QString SN, QString DataTime);
|
||||
//handdleAI::pSegmentation* seg_hanHouDingWei;
|
||||
private:
|
||||
int allNum = 0;
|
||||
int StationNo=0;
|
||||
int img2D = 2;
|
||||
|
||||
bool moduleStatus = true;
|
||||
|
||||
//输入图片队列
|
||||
QQueue<cv::Mat> HikMat;
|
||||
//输入关键字队列
|
||||
QString saveKey="saveKey";
|
||||
//结果路径文件夹队列
|
||||
QString Dir2D="Dir2D";
|
||||
//产品SN队列
|
||||
QString SN="SN";
|
||||
//产品时间戳队列
|
||||
QString DateTime1="DateTime1";
|
||||
|
||||
int paramNum;
|
||||
|
||||
//是否使用线程检测方式
|
||||
bool ifThreadRunDetect = false;
|
||||
//检测结果图
|
||||
std::vector<cv::Mat> resMat;
|
||||
//检测结果
|
||||
bool resIfNg = false;
|
||||
|
||||
QQueue<QByteArray> resByte;
|
||||
|
||||
//检测线程
|
||||
void detectThread();
|
||||
//存图线程
|
||||
void saveImgThread();
|
||||
|
||||
//保存图片队列
|
||||
QQueue<saveImgStruct> saveStruct;
|
||||
|
||||
//判断文件夹是否存在,不存在则创建
|
||||
void isDirExist(QString fullDirName);
|
||||
|
||||
//存图加入队列
|
||||
void addImgToSaveStruct(cv::Mat img2D, QString saveKey, QString savePath);
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Q_DECL_EXPORT Hd_AI_algo_fangBaoFa * create();
|
||||
Q_DECL_EXPORT void destory(Hd_AI_algo_fangBaoFa * ptr);
|
||||
}
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct
|
||||
{
|
||||
cv::Mat out_Mat;
|
||||
std::string saveKey; //关键字,用于LOG日志
|
||||
std::string savePath; //保存路径
|
||||
};
|
||||
#endif // Hd_AI_927_2D_module_H
|
||||
@@ -0,0 +1,69 @@
|
||||
#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
|
||||
@@ -0,0 +1,71 @@
|
||||
# 获取获取当前目录名
|
||||
get_filename_component(CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model start : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
|
||||
set(DLL_NAMES "opencv" "halcon" "halconAlgo" "myTools" "handdleAI")
|
||||
foreach(child ${DLL_NAMES})
|
||||
LIST(APPEND ENV_INCLUDE ${${child}_include})
|
||||
LIST(APPEND ENV_LIB ${${child}_lib})
|
||||
LIST(APPEND ENV_TARGET ${${child}_target_link})
|
||||
endforeach()
|
||||
message(" ENV_INCLUDE : " ${ENV_INCLUDE} )
|
||||
message(" ENV_LIB : " ${ENV_LIB} )
|
||||
message(" ENV_TARGET : " ${ENV_TARGET} )
|
||||
include_directories(
|
||||
|
||||
${ENV_INCLUDE}
|
||||
)
|
||||
|
||||
link_directories (
|
||||
${ENV_LIB}
|
||||
|
||||
)
|
||||
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
FILE(GLOB HEAD_FILES "./*.h" )
|
||||
FILE(GLOB SRC_FILES "./*.cpp")
|
||||
FILE(GLOB UI_FILES "./*.ui")
|
||||
|
||||
|
||||
#find_package(Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS network REQUIRED)
|
||||
add_library(${CURRENT_FOLDER} SHARED
|
||||
${HEAD_FILES}
|
||||
${SRC_FILES}
|
||||
${UI_FILES}
|
||||
)
|
||||
|
||||
|
||||
|
||||
set_target_properties(${CURRENT_FOLDER} PROPERTIES LINKER_LANGUAGE C
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
|
||||
)
|
||||
|
||||
|
||||
target_link_libraries(${CURRENT_FOLDER} PRIVATE
|
||||
${ENV_TARGET}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
)
|
||||
|
||||
|
||||
# target_compile_definitions(${CURRENT_FOLDER} PRIVATE HD_AIDEMO_MODULE_LIBRARY)
|
||||
|
||||
|
||||
|
||||
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model end : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,113 @@
|
||||
#ifndef Hd_AI_algo_jiZhuCeLiangMain_H
|
||||
#define Hd_AI_algo_jiZhuCeLiangMain_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <atlstr.h>
|
||||
#include <chrono>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include <qqueue.h>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <halconcpp/HalconCpp.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "imgproc/imgproc_c.h"
|
||||
#include "base.h"
|
||||
#include "handleAI.h"
|
||||
#include <unionCal.h>
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct;
|
||||
//{
|
||||
// cv::Mat out_Mat;
|
||||
// std::string saveKey; //关键字,用于LOG日志
|
||||
// std::string savePath; //保存路径
|
||||
//};
|
||||
|
||||
//初始化流程(一次):Hd_AI_algo_jiZhuCeLiangMain,initParas
|
||||
//运行流程:writeData主线程把数据传过来,run,readData此线程把数据传主线程
|
||||
class Hd_AI_algo_jiZhuCeLiangMain :public Base
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Hd_AI_algo_jiZhuCeLiangMain();
|
||||
virtual ~Hd_AI_algo_jiZhuCeLiangMain();
|
||||
//从类中读数据到实例对象
|
||||
bool readData(std::vector<cv::Mat>&,QByteArray&);
|
||||
//实例对象把数据写入到类
|
||||
bool writeData(std::vector<cv::Mat>&, QByteArray&);
|
||||
bool initParas(QByteArray&);
|
||||
//运行(Logic_taskthread.cpp)
|
||||
bool run();
|
||||
//线程状态
|
||||
bool checkStatus();// { return true; };
|
||||
|
||||
bool encodeResultValue(QVector<std::string> append_value,QByteArray &resultByte);
|
||||
bool decodeAiValue(QByteArray byte,QVector<QByteArray> &vec_ret);
|
||||
//---------检测流程,根据实际项目修改---------
|
||||
bool AIdetect(cv::Mat img2D, QString saveKey, QString Dir2D, QString SN, QString DataTime);
|
||||
|
||||
private:
|
||||
int allNum = 0;
|
||||
int StationNo=0;
|
||||
int img2D = 2;
|
||||
|
||||
bool moduleStatus = true;
|
||||
|
||||
//输入图片队列
|
||||
QQueue<cv::Mat> HikMat;
|
||||
//输入关键字队列
|
||||
QString saveKey="saveKey";
|
||||
//结果路径文件夹队列
|
||||
QString Dir2D="Dir2D";
|
||||
//产品SN队列
|
||||
QString SN="SN";
|
||||
//产品时间戳队列
|
||||
QString DateTime1="DateTime1";
|
||||
|
||||
int paramNum;
|
||||
|
||||
//是否使用线程检测方式
|
||||
bool ifThreadRunDetect = false;
|
||||
//检测结果图
|
||||
std::vector<cv::Mat> resMat;
|
||||
//检测结果
|
||||
bool resIfNg = false;
|
||||
|
||||
QQueue<QByteArray> resByte;
|
||||
|
||||
//检测线程
|
||||
void detectThread();
|
||||
//存图线程
|
||||
void saveImgThread();
|
||||
|
||||
//保存图片队列
|
||||
QQueue<saveImgStruct> saveStruct;
|
||||
|
||||
//判断文件夹是否存在,不存在则创建
|
||||
void isDirExist(QString fullDirName);
|
||||
|
||||
//存图加入队列
|
||||
void addImgToSaveStruct(cv::Mat img2D, QString saveKey, QString savePath);
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Q_DECL_EXPORT Hd_AI_algo_jiZhuCeLiangMain * create();
|
||||
Q_DECL_EXPORT void destory(Hd_AI_algo_jiZhuCeLiangMain * ptr);
|
||||
}
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct
|
||||
{
|
||||
cv::Mat out_Mat;
|
||||
std::string saveKey; //关键字,用于LOG日志
|
||||
std::string savePath; //保存路径
|
||||
};
|
||||
#endif // Hd_AI_927_2D_module_H
|
||||
@@ -0,0 +1,69 @@
|
||||
#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
|
||||
@@ -0,0 +1,59 @@
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include "unionCal.h"
|
||||
// 全局变量,用于指向 unionCalculate 实例的指针
|
||||
unionCalculate* g_unionCalculate = nullptr;
|
||||
HANDLE hMapFile;
|
||||
unionCalculate** sharedUnionCalculatePtr = nullptr;
|
||||
|
||||
// 创建或获取共享内存,用于存储指向 unionCalculate 类实例的指针
|
||||
extern "C" __declspec(dllexport) void initSharedMemory() {
|
||||
// 创建共享内存对象,存储 unionCalculate* 指针
|
||||
hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(unionCalculate*), "unionCalculatePtr");
|
||||
|
||||
if (hMapFile == NULL) {
|
||||
std::cerr << "Could not create file mapping object (" << GetLastError() << ")" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// 将共享内存映射到当前进程的地址空间
|
||||
sharedUnionCalculatePtr = (unionCalculate**)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(unionCalculate*));
|
||||
|
||||
if (sharedUnionCalculatePtr == NULL) {
|
||||
std::cerr << "Could not map view of file (" << GetLastError() << ")" << std::endl;
|
||||
CloseHandle(hMapFile);
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果指针为空,创建一个新的 unionCalculate 实例并保存
|
||||
if (*sharedUnionCalculatePtr == nullptr) {
|
||||
g_unionCalculate = new unionCalculate();
|
||||
*sharedUnionCalculatePtr = g_unionCalculate; // 存储指针到共享内存
|
||||
std::cout << "Created new unionCalculate instance." << std::endl;
|
||||
}
|
||||
else {
|
||||
// 如果已经存在,直接使用
|
||||
g_unionCalculate = *sharedUnionCalculatePtr;
|
||||
std::cout << "Using existing unionCalculate instance." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// 释放共享内存
|
||||
extern "C" __declspec(dllexport) void releaseSharedMemory() {
|
||||
if (g_unionCalculate) {
|
||||
delete g_unionCalculate;
|
||||
}
|
||||
|
||||
if (sharedUnionCalculatePtr) {
|
||||
UnmapViewOfFile(sharedUnionCalculatePtr);
|
||||
}
|
||||
|
||||
if (hMapFile) {
|
||||
CloseHandle(hMapFile);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取指向 unionCalculate 实例的指针
|
||||
extern "C" __declspec(dllexport) unionCalculate* getUnionCalculateInstance() {
|
||||
return g_unionCalculate;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
# 获取获取当前目录名
|
||||
get_filename_component(CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model start : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
|
||||
set(DLL_NAMES "opencv" "halcon" "halconAlgo" "myTools" "handdleAI")
|
||||
foreach(child ${DLL_NAMES})
|
||||
LIST(APPEND ENV_INCLUDE ${${child}_include})
|
||||
LIST(APPEND ENV_LIB ${${child}_lib})
|
||||
LIST(APPEND ENV_TARGET ${${child}_target_link})
|
||||
endforeach()
|
||||
message(" ENV_INCLUDE : " ${ENV_INCLUDE} )
|
||||
message(" ENV_LIB : " ${ENV_LIB} )
|
||||
message(" ENV_TARGET : " ${ENV_TARGET} )
|
||||
include_directories(
|
||||
|
||||
${ENV_INCLUDE}
|
||||
)
|
||||
|
||||
link_directories (
|
||||
${ENV_LIB}
|
||||
|
||||
)
|
||||
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
FILE(GLOB HEAD_FILES "./*.h" )
|
||||
FILE(GLOB SRC_FILES "./*.cpp")
|
||||
FILE(GLOB UI_FILES "./*.ui")
|
||||
|
||||
|
||||
#find_package(Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS network REQUIRED)
|
||||
add_library(${CURRENT_FOLDER} SHARED
|
||||
${HEAD_FILES}
|
||||
${SRC_FILES}
|
||||
${UI_FILES}
|
||||
)
|
||||
|
||||
|
||||
|
||||
set_target_properties(${CURRENT_FOLDER} PROPERTIES LINKER_LANGUAGE C
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
|
||||
)
|
||||
|
||||
|
||||
target_link_libraries(${CURRENT_FOLDER} PRIVATE
|
||||
${ENV_TARGET}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
)
|
||||
|
||||
|
||||
# target_compile_definitions(${CURRENT_FOLDER} PRIVATE HD_AIDEMO_MODULE_LIBRARY)
|
||||
|
||||
|
||||
|
||||
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model end : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,114 @@
|
||||
#ifndef Hd_AI_algo_jiZhuCeLiangSub_H
|
||||
#define Hd_AI_algo_jiZhuCeLiangSub_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <atlstr.h>
|
||||
#include <chrono>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include <qqueue.h>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <halconcpp/HalconCpp.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "imgproc/imgproc_c.h"
|
||||
#include "base.h"
|
||||
#include "handleAI.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
|
||||
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct;
|
||||
//{
|
||||
// cv::Mat out_Mat;
|
||||
// std::string saveKey; //关键字,用于LOG日志
|
||||
// std::string savePath; //保存路径
|
||||
//};
|
||||
|
||||
//初始化流程(一次):Hd_AI_algo_jiZhuCeLiangSub,initParas
|
||||
//运行流程:writeData主线程把数据传过来,run,readData此线程把数据传主线程
|
||||
class Hd_AI_algo_jiZhuCeLiangSub :public Base
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Hd_AI_algo_jiZhuCeLiangSub();
|
||||
virtual ~Hd_AI_algo_jiZhuCeLiangSub();
|
||||
//从类中读数据到实例对象
|
||||
bool readData(std::vector<cv::Mat>&,QByteArray&);
|
||||
//实例对象把数据写入到类
|
||||
bool writeData(std::vector<cv::Mat>&, QByteArray&);
|
||||
bool initParas(QByteArray&);
|
||||
//运行(Logic_taskthread.cpp)
|
||||
bool run();
|
||||
//线程状态
|
||||
bool checkStatus();// { return true; };
|
||||
|
||||
bool encodeResultValue(QVector<std::string> append_value,QByteArray &resultByte);
|
||||
bool decodeAiValue(QByteArray byte,QVector<QByteArray> &vec_ret);
|
||||
//---------检测流程,根据实际项目修改---------
|
||||
bool AIdetect(cv::Mat img2D, QString saveKey, QString Dir2D, QString SN, QString DataTime);
|
||||
|
||||
private:
|
||||
int allNum = 0;
|
||||
int StationNo=0;
|
||||
int img2D = 2;
|
||||
|
||||
bool moduleStatus = true;
|
||||
|
||||
//输入图片队列
|
||||
QQueue<cv::Mat> HikMat;
|
||||
//输入关键字队列
|
||||
QString saveKey="saveKey";
|
||||
//结果路径文件夹队列
|
||||
QString Dir2D="Dir2D";
|
||||
//产品SN队列
|
||||
QString SN="SN";
|
||||
//产品时间戳队列
|
||||
QString DateTime1="DateTime1";
|
||||
|
||||
int paramNum;
|
||||
|
||||
//是否使用线程检测方式
|
||||
bool ifThreadRunDetect = false;
|
||||
//检测结果图
|
||||
std::vector<cv::Mat> resMat;
|
||||
//检测结果
|
||||
bool resIfNg = false;
|
||||
|
||||
QQueue<QByteArray> resByte;
|
||||
|
||||
//检测线程
|
||||
void detectThread();
|
||||
//存图线程
|
||||
void saveImgThread();
|
||||
|
||||
//保存图片队列
|
||||
QQueue<saveImgStruct> saveStruct;
|
||||
|
||||
//判断文件夹是否存在,不存在则创建
|
||||
void isDirExist(QString fullDirName);
|
||||
|
||||
//存图加入队列
|
||||
void addImgToSaveStruct(cv::Mat img2D, QString saveKey, QString savePath);
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Q_DECL_EXPORT Hd_AI_algo_jiZhuCeLiangSub * create();
|
||||
Q_DECL_EXPORT void destory(Hd_AI_algo_jiZhuCeLiangSub * ptr);
|
||||
}
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct
|
||||
{
|
||||
cv::Mat out_Mat;
|
||||
std::string saveKey; //关键字,用于LOG日志
|
||||
std::string savePath; //保存路径
|
||||
};
|
||||
#endif // Hd_AI_927_2D_module_H
|
||||
@@ -0,0 +1,69 @@
|
||||
#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
|
||||
@@ -0,0 +1,41 @@
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <unionCal.h>// 包含unionCalculate类的定义
|
||||
|
||||
// 全局变量
|
||||
HANDLE hMapFile;
|
||||
unionCalculate** sharedUnionCalculatePtr = nullptr;
|
||||
|
||||
// 导出函数:获取 unionCalculate 实例并启动线程
|
||||
extern "C" __declspec(dllexport) void initSharedMemory() {
|
||||
// 打开现有的共享内存
|
||||
hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, "unionCalculatePtr");
|
||||
|
||||
if (hMapFile == NULL) {
|
||||
std::cerr << "Could not open file mapping object (" << GetLastError() << ")" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
sharedUnionCalculatePtr = (unionCalculate**)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(unionCalculate*));
|
||||
|
||||
if (sharedUnionCalculatePtr == NULL) {
|
||||
std::cerr << "Could not map view of file (" << GetLastError() << ")" << std::endl;
|
||||
CloseHandle(hMapFile);
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "DLL B: Acquired unionCalculate instance" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
// 导出函数:停止线程并释放共享内存
|
||||
extern "C" __declspec(dllexport) void ReleaseSharedMemory() {
|
||||
|
||||
if (sharedUnionCalculatePtr) {
|
||||
UnmapViewOfFile(sharedUnionCalculatePtr);
|
||||
}
|
||||
if (hMapFile) {
|
||||
CloseHandle(hMapFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
# 获取获取当前目录名
|
||||
get_filename_component(CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model start : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
|
||||
set(DLL_NAMES "opencv" "halcon" "halconAlgo" "myTools" "handdleAI")
|
||||
foreach(child ${DLL_NAMES})
|
||||
LIST(APPEND ENV_INCLUDE ${${child}_include})
|
||||
LIST(APPEND ENV_LIB ${${child}_lib})
|
||||
LIST(APPEND ENV_TARGET ${${child}_target_link})
|
||||
endforeach()
|
||||
message(" ENV_INCLUDE : " ${ENV_INCLUDE} )
|
||||
message(" ENV_LIB : " ${ENV_LIB} )
|
||||
message(" ENV_TARGET : " ${ENV_TARGET} )
|
||||
include_directories(
|
||||
|
||||
${ENV_INCLUDE}
|
||||
)
|
||||
|
||||
link_directories (
|
||||
${ENV_LIB}
|
||||
|
||||
)
|
||||
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
FILE(GLOB HEAD_FILES "./*.h" )
|
||||
FILE(GLOB SRC_FILES "./*.cpp")
|
||||
FILE(GLOB UI_FILES "./*.ui")
|
||||
|
||||
|
||||
#find_package(Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS network REQUIRED)
|
||||
add_library(${CURRENT_FOLDER} SHARED
|
||||
${HEAD_FILES}
|
||||
${SRC_FILES}
|
||||
${UI_FILES}
|
||||
)
|
||||
|
||||
|
||||
|
||||
set_target_properties(${CURRENT_FOLDER} PROPERTIES LINKER_LANGUAGE C
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
|
||||
)
|
||||
|
||||
|
||||
target_link_libraries(${CURRENT_FOLDER} PRIVATE
|
||||
${ENV_TARGET}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
)
|
||||
|
||||
|
||||
# target_compile_definitions(${CURRENT_FOLDER} PRIVATE HD_AIDEMO_MODULE_LIBRARY)
|
||||
|
||||
|
||||
|
||||
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model end : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,114 @@
|
||||
#ifndef Hd_AI_algo_maJiaReRong_H
|
||||
#define Hd_AI_algo_maJiaReRong_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <atlstr.h>
|
||||
#include <chrono>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include <qqueue.h>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <halconcpp/HalconCpp.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "imgproc/imgproc_c.h"
|
||||
#include "base.h"
|
||||
#include "handleAI.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
|
||||
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct;
|
||||
//{
|
||||
// cv::Mat out_Mat;
|
||||
// std::string saveKey; //关键字,用于LOG日志
|
||||
// std::string savePath; //保存路径
|
||||
//};
|
||||
|
||||
//初始化流程(一次):Hd_AI_algo_maJiaReRong,initParas
|
||||
//运行流程:writeData主线程把数据传过来,run,readData此线程把数据传主线程
|
||||
class Hd_AI_algo_maJiaReRong :public Base
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Hd_AI_algo_maJiaReRong();
|
||||
virtual ~Hd_AI_algo_maJiaReRong();
|
||||
//从类中读数据到实例对象
|
||||
bool readData(std::vector<cv::Mat>&,QByteArray&);
|
||||
//实例对象把数据写入到类
|
||||
bool writeData(std::vector<cv::Mat>&, QByteArray&);
|
||||
bool initParas(QByteArray&);
|
||||
//运行(Logic_taskthread.cpp)
|
||||
bool run();
|
||||
//线程状态
|
||||
bool checkStatus();// { return true; };
|
||||
|
||||
bool encodeResultValue(QVector<std::string> append_value,QByteArray &resultByte);
|
||||
bool decodeAiValue(QByteArray byte,QVector<QByteArray> &vec_ret);
|
||||
//---------检测流程,根据实际项目修改---------
|
||||
bool AIdetect(cv::Mat img2D, QString saveKey, QString Dir2D, QString SN, QString DataTime);
|
||||
//handdleAI::pSegmentation* seg_hanHouDingWei;
|
||||
private:
|
||||
int allNum = 0;
|
||||
int StationNo=0;
|
||||
int img2D = 2;
|
||||
|
||||
bool moduleStatus = true;
|
||||
|
||||
//输入图片队列
|
||||
QQueue<cv::Mat> HikMat;
|
||||
//输入关键字队列
|
||||
QString saveKey="saveKey";
|
||||
//结果路径文件夹队列
|
||||
QString Dir2D="Dir2D";
|
||||
//产品SN队列
|
||||
QString SN="SN";
|
||||
//产品时间戳队列
|
||||
QString DateTime1="DateTime1";
|
||||
|
||||
int paramNum;
|
||||
|
||||
//是否使用线程检测方式
|
||||
bool ifThreadRunDetect = false;
|
||||
//检测结果图
|
||||
std::vector<cv::Mat> resMat;
|
||||
//检测结果
|
||||
bool resIfNg = false;
|
||||
|
||||
QQueue<QByteArray> resByte;
|
||||
|
||||
//检测线程
|
||||
void detectThread();
|
||||
//存图线程
|
||||
void saveImgThread();
|
||||
|
||||
//保存图片队列
|
||||
QQueue<saveImgStruct> saveStruct;
|
||||
|
||||
//判断文件夹是否存在,不存在则创建
|
||||
void isDirExist(QString fullDirName);
|
||||
|
||||
//存图加入队列
|
||||
void addImgToSaveStruct(cv::Mat img2D, QString saveKey, QString savePath);
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Q_DECL_EXPORT Hd_AI_algo_maJiaReRong * create();
|
||||
Q_DECL_EXPORT void destory(Hd_AI_algo_maJiaReRong * ptr);
|
||||
}
|
||||
//保存图片的结构体
|
||||
struct saveImgStruct
|
||||
{
|
||||
cv::Mat out_Mat;
|
||||
std::string saveKey; //关键字,用于LOG日志
|
||||
std::string savePath; //保存路径
|
||||
};
|
||||
#endif // Hd_AI_927_2D_module_H
|
||||
@@ -0,0 +1,69 @@
|
||||
#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
|
||||
@@ -18,10 +18,10 @@ void HSnData::addSnVector(QVector<QString> snVec)
|
||||
QVector<QString> vec_str = queue_vector_sn.last();
|
||||
if (!vec_str.isEmpty())
|
||||
{
|
||||
if (!vec_str[0].contains(snVec[0])) //demo流程重入检查也可以
|
||||
{
|
||||
queue_vector_sn.append(snVec);
|
||||
}
|
||||
//if (!vec_str[0].contains(snVec[0])) //demo流程重入检查也可以
|
||||
//{
|
||||
// queue_vector_sn.append(snVec);
|
||||
//}
|
||||
/*else
|
||||
std::cout << "HSnData::addSnVector err" << std::endl;*/
|
||||
}
|
||||
|
||||
+2
-2
@@ -127,8 +127,8 @@ if(ON)
|
||||
else()
|
||||
SET( ${child}_target_link "opencv_world410" )
|
||||
endif()
|
||||
elseif(${child} MATCHES "3DAI")
|
||||
SET( ${child}_target_link "cosmeticAlg" )
|
||||
elseif(${child} MATCHES "halconAlgo")
|
||||
SET( ${child}_target_link "Inspection" )
|
||||
elseif(${child} MATCHES "basler")
|
||||
SET( ${child}_target_link
|
||||
"GCBase_MD_VC141_v3_1_Basler_pylon"
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
+375
@@ -0,0 +1,375 @@
|
||||
#pragma once
|
||||
#include<halconcpp/HalconCpp.h>
|
||||
#include<halconcpp/HDevThread.h>
|
||||
#include<Halcon.h>
|
||||
|
||||
//#include <opencv2/opencv.hpp>
|
||||
//#include <opencv2/imgcodecs/imgcodecs.hpp>
|
||||
|
||||
using namespace HalconCpp;
|
||||
|
||||
#if 1 后端调用函数
|
||||
|
||||
/*
|
||||
ho_Image:输入原图
|
||||
hv_out_Value:输出检测结果 1为铝,2为铜
|
||||
hv_Make:算法执行状态-1为算法NG,1为算法ok
|
||||
极性检测函数
|
||||
预焊三协机台
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_1_Polarity_detection(HObject ho_Image, HTuple* hv_out_Value, HTuple* hv_Make);
|
||||
|
||||
/*
|
||||
* ho_Image:输入图片(原图)
|
||||
* hv_NinePointDocument:九点文件的路径
|
||||
* hv_SetNumber:设置胶钉的最小个数
|
||||
* hv_Circle_Point:输出放钉孔的圆心x,圆心y,半径。数组形式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行
|
||||
*hv_Out_Roboot1:吸嘴1-> 吸嘴编号,x绝对坐标,y绝对坐标
|
||||
* hv_Out_Roboot2:吸嘴2->吸嘴编号,x绝对坐标,y绝对坐标
|
||||
* hv_Out_Roboot3:吸嘴3->吸嘴编号,x绝对坐标,y绝对坐标
|
||||
* 机器人引导函数
|
||||
* 三协机台
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_BootTheMachine(HObject ho_Image, HTuple hv_NinePointDocument, HTuple hv_SetNumber,
|
||||
HTuple* hv_Circle_Point, HTuple* hv_Make, HTuple* hv_Out_Roboot1, HTuple* hv_Out_Roboot2,HTuple* hv_Out_Roboot3, HTuple* hv_StartRun);
|
||||
|
||||
/*
|
||||
*ho_Image:输入图片(原图)
|
||||
* hv_Pix:像素精度
|
||||
* hv_out_line:输出直线坐标
|
||||
* hv_distance:输出测量值 ->高,宽。数组形式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行
|
||||
* 铜极耳裁剪测量函数
|
||||
* 三协预焊机台
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall cs_628_jier_T(HObject ho_Image, HTuple hv_Pix, HTuple* hv_out_line, HTuple* hv_out_Soldering_line,
|
||||
HTuple* hv_distance, HTuple* hv_Make);
|
||||
|
||||
/*
|
||||
*ho_Image:输入图片(原图)
|
||||
* hv_Pix:像素精度
|
||||
* hv_out_line:输出直线坐标
|
||||
* hv_distance:输出测量值 ->高,宽。数组形式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行
|
||||
* 铝极耳裁剪测量函数
|
||||
* 三协预焊机台
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall cs_628_jier_L(HObject ho_Image, HTuple hv_Pix, HTuple* hv_out_line, HTuple* hv_distance,
|
||||
HTuple* hv_Make);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ho_Image:输入图片(原图)
|
||||
* hv_model:赋值为1时是基准标定模式,0为正常检测模式
|
||||
* hv_BenchmarkFile:基准标定文件的路径
|
||||
* hv_NinePointDocument:九点文件的路径
|
||||
*hv_CameraNumber:上钉相机编号
|
||||
* hv_out_Cirle:输出放钉孔的圆心x,圆心y,半径。数组形式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行,输出为2为基准标定成功
|
||||
* hv_offset_x:x轴方向上相对于基准位置的偏差
|
||||
* hv_offset_y:y轴方向上相对于基准位置的偏差
|
||||
* 打钉钉引导函数
|
||||
* 三协的机台
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_NailingPosition(HObject ho_Image, HTuple hv_model, HTuple hv_BenchmarkFile,
|
||||
HTuple hv_NinePointDocument, HTuple hv_CameraNumber, HTuple* hv_out_Cirle, HTuple* hv_Make,
|
||||
HTuple* hv_offset_x, HTuple* hv_offset_y);
|
||||
|
||||
|
||||
/*
|
||||
ho_Image:输入原图
|
||||
hv_out_Value:输出检测结果[1,1] .1为铝,[2,2] 2为铜
|
||||
hv_Make:算法执行状态-1为算法NG,1为算法ok
|
||||
极性检测函数
|
||||
终焊三协机台
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_2_Polarity_detection(HObject ho_Image, HTuple* hv_out_Value, HTuple* hv_Make);
|
||||
|
||||
/*
|
||||
* ho_Image_L:输入图片铝
|
||||
* ho_Image_T:输入图片铜
|
||||
* hv_Pix_T:铜极像素精度
|
||||
* hv_Pix_L:铝极像素精度
|
||||
* hv_Out_Vale_L:输出铝极测量值包括两个值
|
||||
* hv_Out_Line_L:输出铝极划线坐标
|
||||
* hv_Out_Vale_T:输出铝极测量值包括两个值
|
||||
* hv_Out_Line_T:输出铜极极划线坐标
|
||||
* hv_Out_extremum_Value:输出两极之间的距离
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行
|
||||
* 预焊焊前测量函数
|
||||
* 三协的机台
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_2_BeforeWelding_Distnce(HObject ho_Image_L, HObject ho_Image_T, HTuple hv_Pix_T,
|
||||
HTuple hv_Pix_L, HTuple* hv_Out_Vale_L, HTuple* hv_Out_Line_L, HTuple* hv_Out_Vale_T,
|
||||
HTuple* hv_Out_Line_T, HTuple* hv_Out_extremum_Value, HTuple* hv_Makes);
|
||||
|
||||
/*
|
||||
* ho_Image :输入图片铝极
|
||||
* ho_ImageSeg :输入图片seg图(二值图)
|
||||
* hv_Pix : 铝极像素精度
|
||||
* hv_Out_TopLeft_Line : 左上输出线的端点坐标
|
||||
* hv_Out_TopLeft_Value :左上输出的测量值(2个值)
|
||||
* hv_Out_TopRight_Line :右上输出线的端点坐标
|
||||
* hv_Out_TopRight_Value :右上输出的测量值(2个值)
|
||||
* hv_Out_BottomLeft_Line :左下输出线的端点坐标
|
||||
* hv_Out_BottomLeft_Value :左下输出的测量值(2个值)
|
||||
** hv_Out_BottomRight_Line :右下输出线的端点坐标
|
||||
* hv_Out_BottomRight_Value :右下输出的测量值(2个值)
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行
|
||||
* 预焊焊后测量铝极函数
|
||||
* 三协的机台
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_AfterWelding_Distance_L(HObject ho_Image, HObject ho_ImageSeg, HTuple hv_Pix,
|
||||
HTuple* hv_Out_TopLeft_Line, HTuple* hv_Out_TopLeft_Value, HTuple* hv_Out_TopRight_Line,
|
||||
HTuple* hv_Out_TopRight_Value, HTuple* hv_Out_BottomLeft_Line, HTuple* hv_Out_BottomLeft_Value,
|
||||
HTuple* hv_Out_BottomRight_Line, HTuple* hv_Out_BottomRight_Value, HTuple* hv_Make);
|
||||
|
||||
/*
|
||||
* ho_Image :输入图片铝极
|
||||
* ho_ImageSeg :输入图片seg图(二值图)
|
||||
* hv_Pix : 铝极像素精度
|
||||
* hv_Out_TopLeft_Line : 左上输出线的端点坐标
|
||||
* hv_Out_TopLeft_Value :左上输出的测量值(2个值)
|
||||
* hv_Out_TopRight_Line :右上输出线的端点坐标
|
||||
* hv_Out_TopRight_Value :右上输出的测量值(2个值)
|
||||
* hv_Out_BottomLeft_Line :左下输出线的端点坐标
|
||||
* hv_Out_BottomLeft_Value :左下输出的测量值(2个值)
|
||||
** hv_Out_BottomRight_Line :右下输出线的端点坐标
|
||||
* hv_Out_BottomRight_Value :右下输出的测量值(2个值)
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行
|
||||
* 预焊焊后测量铜极函数
|
||||
* 三协的机台
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_AfterWelding_Distance_T(HObject ho_Image, HObject ho_ImageSeg, HTuple hv_Pix,
|
||||
HTuple* hv_Out_TopLeft_Line, HTuple* hv_Out_TopLeft_Value, HTuple* hv_Out_TopRight_Line,
|
||||
HTuple* hv_Out_TopRight_Value, HTuple* hv_Out_BottomLeft_Line, HTuple* hv_Out_BottomLeft_Value,
|
||||
HTuple* hv_Out_BottomRight_Line, HTuple* hv_Out_BottomRight_Value, HTuple* hv_Make);
|
||||
|
||||
/*
|
||||
* ho_Image :输入图片
|
||||
* hv_Out_Rectangle : 输出矩形的两个顶点坐标
|
||||
* hv_Text :输出检测信息字符串格式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行
|
||||
*软连接热熔工位函数
|
||||
* 三协的机台
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_3_TopCoverMelted(HObject ho_Image, HTuple* hv_Out_Rectangle, HTuple* hv_Make,
|
||||
HTuple* hv_Text);
|
||||
|
||||
/*
|
||||
* ho_Image_L :输入图片(铝)
|
||||
* ho_Image_T :输入图片(铜)
|
||||
* hv_Pix_L :铝极相机像素精度
|
||||
* hv_Pix_T :铜极相机像素精度
|
||||
* hv_Out_Line_T :铜极输出线的端点坐标(需判断个数)
|
||||
* hv_Out_Point_T :铜极输出中心圆的中心坐标及半径
|
||||
* hv_Out_Chamfering_T :铜极输出倒角值
|
||||
* hv_Distances_T :铜极输出上下,左右距离
|
||||
* hv_Out_Line_L :铝极输出线的端点坐标(需判断个数)
|
||||
* hv_Out_Point_L :铝极输出中心圆的中心坐标及半径
|
||||
* hv_Out_Chamfering_L :铝极输出倒角值
|
||||
* hv_Distances_L :铝极输出上下,左右距离
|
||||
* hv_Out_InterpoleValue :输出两极柱之间距离
|
||||
* hv_Makes:输出-1为算法错误,输出1为算法正常执行
|
||||
*软连接极柱测量工位函数
|
||||
* 三协的机台
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_3_PoleDetections(HObject ho_Image_L, HObject ho_Image_T, HTuple hv_Pix_L,
|
||||
HTuple hv_Pix_T, HTuple* hv_Out_Line_T, HTuple* hv_Out_Point_T, HTuple* hv_Out_Chamfering_T,
|
||||
HTuple* hv_Distances_T, HTuple* hv_Out_Line_L, HTuple* hv_Out_Point_L, HTuple* hv_Out_Chamfering_L,
|
||||
HTuple* hv_Distances_L, HTuple* hv_Out_InterpoleValue, HTuple* hv_Makes);
|
||||
|
||||
/*
|
||||
* ho_Image :输入图片
|
||||
* hv_Pix :相机像素精度
|
||||
* hv_Distance_Value :间距测量值
|
||||
* hv_Out_Point :输出防爆阀中心点和二维码中心点距离
|
||||
* hv_Makes:输出-1为算法错误,输出1为算法正常执行
|
||||
*软连接防爆阀与二维码之间距离测量函数
|
||||
* 三协的机台
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_3_ExplosionProofValves(HObject ho_Image, HTuple hv_Pix, HTuple* hv_Distance_Value,
|
||||
HTuple* hv_Out_Point, HTuple* hv_Make);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ho_Image:输入图片(原图)
|
||||
* hv_model:赋值为1时是基准标定模式,0为正常检测模式
|
||||
* hv_BenchmarkFile:基准标定文件的路径
|
||||
* hv_NinePointDocument:九点文件的路径
|
||||
*hv_CameraNumber:上钉相机编号
|
||||
* hv_out_Cirle:输出放钉孔的圆心x,圆心y,半径。数组形式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行,输出为2为基准标定成功
|
||||
* hv_offset_x:x轴方向上相对于基准位置的偏差
|
||||
* hv_offset_y:y轴方向上相对于基准位置的偏差
|
||||
* 上钉引导函数
|
||||
* 赢合的机台
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_SealingNails(HObject ho_Image, HTuple hv_model, HTuple hv_BenchmarkFile,
|
||||
HTuple hv_NinePointDocument, HTuple hv_CameraNumber, HTuple* hv_out_Cirle, HTuple* hv_Make,
|
||||
HTuple* hv_offset_x, HTuple* hv_offset_y);
|
||||
|
||||
/*
|
||||
* ho_Image:输入图片(原图)
|
||||
* hv_model:赋值为1时是基准标定模式,0为正常检测模式
|
||||
* hv_BenchmarkFile:基准标定文件的路径
|
||||
* hv_NinePointDocument:九点文件的路径
|
||||
*hv_CameraNumber:预焊相机编号
|
||||
* hv_out_Cirle:输出放钉孔的圆心x,圆心y,半径。数组形式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行,输出为2为基准标定成功
|
||||
* hv_offset_x:x轴方向上相对于基准位置的偏差
|
||||
* hv_offset_y:y轴方向上相对于基准位置的偏差
|
||||
* hv_Text:输出报警信息包括(ok,无钉,翘钉,反钉)
|
||||
* 赢合机台
|
||||
* 预焊函数
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_yuhan(HObject ho_Image, HTuple hv_Model, HTuple hv_BenchmarkFile, HTuple hv_NinePointDocument,
|
||||
HTuple hv_CameraNumber, HTuple* hv_out_Cirle, HTuple* hv_Make, HTuple* hv_offset_x,
|
||||
HTuple* hv_offset_y, HTuple* hv_Text);
|
||||
|
||||
/*
|
||||
* ho_Image:输入图片(原图)
|
||||
* hv_model:赋值为1时是基准标定模式,0为正常检测模式
|
||||
* hv_BenchmarkFile:基准标定文件的路径
|
||||
* hv_NinePointDocument:九点文件的路径
|
||||
*hv_CameraNumber:预焊相机编号
|
||||
* hv_out_Cirle:输出放钉孔的圆心x,圆心y,半径。数组形式
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行,输出为2为基准标定成功
|
||||
* hv_offset_x:x轴方向上相对于基准位置的偏差
|
||||
* hv_offset_y:y轴方向上相对于基准位置的偏差
|
||||
* 终焊函数
|
||||
* 赢合的机台
|
||||
*/
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_FinalWelding(HObject ho_Image, HTuple hv_model, HTuple hv_BenchmarkFile,
|
||||
HTuple hv_NinePointDocument, HTuple hv_CameraNumber, HTuple* hv_out_Cirle, HTuple* hv_Make,
|
||||
HTuple* hv_offset_x, HTuple* hv_offset_y);
|
||||
|
||||
/*
|
||||
* ho_Image1:输入图片(原图)
|
||||
* ho_Image2:输入图片(原图)
|
||||
* ho_Image3:输入图片(原图)
|
||||
* ho_Image4:输入图片(原图)
|
||||
*ho_Out_Image1:输出图片1
|
||||
* ho_Out_image2:输出图片2
|
||||
* hv_Make:输出-1为算法错误,输出1为算法正常执行,输出为2为基准标定成功
|
||||
* hv_sacats:光源与光轴夹角
|
||||
* hv_Tilts:光源安装位置
|
||||
*/
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall _628_25D(HObject ho_Image1, HObject ho_Image2, HObject ho_Image3, HObject ho_Image4,
|
||||
HObject* ho_Out_Image1, HObject* ho_Out_image2, HTuple hv_sacats, HTuple hv_Tilts,
|
||||
HTuple* hv_Make);
|
||||
|
||||
//Function Name: Cal_Defect_Height
|
||||
//Author:
|
||||
//Description: 2D获取缺陷后, 基于特征点的位置关系, 建立2D和3D的映射关系.
|
||||
//Input: in_Image2: 密封钉区域的2D二值化的图像(bmp),,
|
||||
// in_Image3: 3D深度图像(tiff),
|
||||
// in_xResolution: x向精度(mm/pix)
|
||||
// in_yResolution: y向精度(mm/pix),
|
||||
// in_zResolution: Z向精度(mm/pix)
|
||||
// in_DefectLocation: 2d图像缺陷坐标点位置, 每四个一组,
|
||||
// in_DefectLocation[0]:缺陷外接矩形的X向坐标(pix)
|
||||
// in_DefectLocation[1]:缺陷外接矩形的y向坐标(pix)
|
||||
// in_DefectLocation[2]:缺陷外接矩形的宽度width(pix)
|
||||
// in_DefectLocation[3]:缺陷外接矩形的高度height(pix)
|
||||
// in_FilePath, 矩阵martix文件路径,
|
||||
// in_offsetValue, 位置补偿值,
|
||||
// in_offsetValue[0]: 左工位X向补偿值(pix)
|
||||
// in_offsetValue[1]: 左工位Y向补偿值(pix)
|
||||
// in_offsetValue[2]: 右工位X向补偿值(pix)
|
||||
// in_offsetValue[3]: 右工位Y向补偿值(pix)
|
||||
// in_HoffsetValue, 缺陷高度补偿值(正值,单位:mm)
|
||||
//output: out_Height: 缺陷的高度(mm),
|
||||
// out_Flag: 算法执行的标志位, 0: 算法执行异常 1:算法执行ok
|
||||
// 赢合机台
|
||||
//verion change log: XXX 2024-10-22 V1.1 Create new function
|
||||
|
||||
extern "C" __declspec(dllexport) void _stdcall Cal_Defect_Height(HObject ho_in_Image2, HObject ho_in_Image3, HTuple hv_in_xResolution,
|
||||
HTuple hv_in_yResolution, HTuple hv_in_zResolution, HTuple hv_in_DefectLocation,
|
||||
HTuple hv_in_FilePath, HTuple hv_in_OffsetValue, HTuple hv_in_HoffsetValue, HTuple* hv_out_Height,
|
||||
HTuple* hv_out_Angle, HTuple* hv_out_Flag);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if 1 halcon调用函数
|
||||
|
||||
void gen_arrow_contour_xld(HObject* ho_Arrow, HTuple hv_Row1, HTuple hv_Column1,
|
||||
HTuple hv_Row2, HTuple hv_Column2, HTuple hv_HeadLength, HTuple hv_HeadWidth);
|
||||
void Get_Rectangle2_Corner_new(HObject ho_Rectangle, HTuple* hv_out_Row, HTuple* hv_out_Col);
|
||||
|
||||
void pts_to_best_line(HObject* ho_Line, HTuple hv_Rows, HTuple hv_Cols, HTuple hv_ActiveNum,
|
||||
HTuple* hv_Row1, HTuple* hv_Column1, HTuple* hv_Row2, HTuple* hv_Column2);
|
||||
void rake(HObject ho_Image, HObject* ho_Regions, HTuple hv_Elements, HTuple hv_DetectHeight,
|
||||
HTuple hv_DetectWidth, HTuple hv_Sigma, HTuple hv_Threshold, HTuple hv_Transition,
|
||||
HTuple hv_Select, HTuple hv_Row1, HTuple hv_Column1, HTuple hv_Row2, HTuple hv_Column2,
|
||||
HTuple* hv_ResultRow, HTuple* hv_ResultColumn);
|
||||
|
||||
void pts_to_best_circle(HObject* ho_Circle, HTuple hv_Rows, HTuple hv_Cols, HTuple hv_ArcType,
|
||||
HTuple hv_ActiveNum, HTuple* hv_RowCenter, HTuple* hv_ColCenter, HTuple* hv_Radius,
|
||||
HTuple* hv_StartPhi, HTuple* hv_EndPhi, HTuple* hv_PointOrder, HTuple* hv_ArcAngle);
|
||||
|
||||
void region_to_spoke(HObject ho_Region, HTuple hv_Offset, HTuple* hv_SpokeRows,
|
||||
HTuple* hv_SpokeCols);
|
||||
|
||||
void spoke(HObject ho_Image, HObject* ho_Regions, HTuple hv_Elements, HTuple hv_DetectHeight,
|
||||
HTuple hv_DetectWidth, HTuple hv_Sigma, HTuple hv_Threshold, HTuple hv_Transition,
|
||||
HTuple hv_Select, HTuple hv_ROIRows, HTuple hv_ROICols, HTuple hv_Direct, HTuple* hv_ResultRow,
|
||||
HTuple* hv_ResultColumn, HTuple* hv_ArcType);
|
||||
|
||||
void _628_PreWelded(HObject ho_Image, HTuple hv_model, HTuple hv_BenchmarkFile,
|
||||
HTuple hv_NinePointDocument, HTuple hv_CameraNumber, HTuple* hv_out_Cirle, HTuple* hv_Make,
|
||||
HTuple* hv_offset_x, HTuple* hv_offset_y);
|
||||
|
||||
void BeforeWelding_L(HObject ho_Image_L, HTuple hv_Pix_T, HTuple* hv_Make, HTuple* hv_Out_Line,
|
||||
HTuple* hv_Out_Vale, HTuple* hv_Out_PointRow, HTuple* hv_Out_PointCol);
|
||||
|
||||
void BeforeWelding_T(HObject ho_Image_T, HTuple hv_Pix_T, HTuple* hv_Make, HTuple* hv_Out_Line,
|
||||
HTuple* hv_Out_Vale, HTuple* hv_Out_PointRow, HTuple* hv_Out_PointCol);
|
||||
|
||||
|
||||
void Cal_PointCould_HeightValue(HObject ho_Tmp_Region, HObject ho_Zero_Region, HObject ho_XImageScaled,
|
||||
HObject ho_YImageScaled, HObject ho_ZImageScaled, HTuple hv_HeightPointPerenct,
|
||||
HTuple* hv_Out_Mean, HTuple* hv_Out_Max, HTuple* hv_Out_Min, HTuple* hv_Out_Height,
|
||||
HTuple* hv_Out_Flag, HTuple* hv_Out_NgTails);
|
||||
|
||||
void cs_628_PoleDetection(HObject ho_Image, HTuple hv_Pix, HTuple* hv_Distances,
|
||||
HTuple* hv_UP_Down_Point, HTuple* hv_life_Ren_Point, HTuple* hv_Point, HTuple* hv_Chamfering,
|
||||
HTuple* hv_Make);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <opencv.hpp>
|
||||
#include <unordered_map>
|
||||
#include <qqueue.h>
|
||||
#include "algo.h"
|
||||
class unionCalculate
|
||||
{
|
||||
public:
|
||||
//struct dataStruct
|
||||
//{
|
||||
// cv::Mat matImg;
|
||||
// HObject halconImg;
|
||||
// dataStruct(cv::Mat img1, HObject img2)
|
||||
// :matImg(img1),
|
||||
// halconImg(img2)
|
||||
// {
|
||||
|
||||
// }
|
||||
//};
|
||||
//方法1 用sn匹配
|
||||
//std::unordered_map<,std::string,dataStruct> dataMap;
|
||||
//void insertSubData(std::string& sign,cv::Mat& img)
|
||||
//{
|
||||
// dataVec.insert(std::make_pair(sign, img));
|
||||
//}
|
||||
//dataStruct getData(std::string& sign)
|
||||
//{
|
||||
//}
|
||||
|
||||
//方法2 获取最新的
|
||||
//子算法转完hobject再发送
|
||||
|
||||
|
||||
void insertSubData(HObject img)
|
||||
{
|
||||
mutexUnionCaculate.lock();
|
||||
dataQueue.enqueue(img);
|
||||
mutexUnionCaculate.unlock();
|
||||
}
|
||||
bool getData(HObject& res)
|
||||
{
|
||||
mutexUnionCaculate.lock();
|
||||
if (dataQueue.size() == 0)
|
||||
{
|
||||
mutexUnionCaculate.unlock();
|
||||
return false;
|
||||
}
|
||||
res = dataQueue.dequeue();
|
||||
dataQueue.clear();
|
||||
mutexUnionCaculate.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
struct calResult
|
||||
{
|
||||
bool algoFailed = false;
|
||||
std::vector<double>lines;
|
||||
std::vector<double>points;
|
||||
double upDownDistance, leftRightDistance;
|
||||
double interpoleValue;
|
||||
};
|
||||
void insertResult(calResult res)
|
||||
{
|
||||
mutexUnionCaculate.lock();
|
||||
resultQueue.enqueue(res);
|
||||
mutexUnionCaculate.unlock();
|
||||
}
|
||||
bool getResult(calResult& res)
|
||||
{
|
||||
mutexUnionCaculate.lock();
|
||||
if (resultQueue.size() == 0)
|
||||
{
|
||||
mutexUnionCaculate.unlock();
|
||||
return false;
|
||||
}
|
||||
res = resultQueue.dequeue();
|
||||
resultQueue.clear();
|
||||
mutexUnionCaculate.unlock();
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
QQueue<HObject> dataQueue;
|
||||
QQueue<calResult>resultQueue;
|
||||
std::mutex mutexUnionCaculate;
|
||||
};
|
||||
|
||||
|
||||
#pragma once
|
||||
Vendored
BIN
Binary file not shown.
Vendored
+3
-3
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#define FENGZHUANG_API __declspec(dllexport)
|
||||
@@ -15,8 +15,8 @@ using namespace cv;
|
||||
|
||||
FENGZHUANG_API void putTextHusky(Mat& dst, const char* str, Point org, Scalar color, int fontSize,
|
||||
const char* fn = "Arial", bool italic = false, bool underline = false);
|
||||
FENGZHUANG_API int32_t createDirectory(const wstring& directoryPath);
|
||||
FENGZHUANG_API int32_t createDirectory(const string& directoryPath);
|
||||
FENGZHUANG_API int32_t createDirectory(const std::wstring& directoryPath);
|
||||
FENGZHUANG_API int32_t createDirectory(const std::string& directoryPath);
|
||||
FENGZHUANG_API char* UnicodeToAnsi(const wchar_t* szStr);
|
||||
FENGZHUANG_API wchar_t* AnsiToUnicode(const char* szStr);
|
||||
FENGZHUANG_API std::string WString2String(const std::wstring& ws);
|
||||
|
||||
Reference in New Issue
Block a user