This commit is contained in:
2024-08-30 15:44:02 +08:00
parent 83eb308eaf
commit 473e92f7c0
5 changed files with 46 additions and 9 deletions
Binary file not shown.
@@ -34,7 +34,7 @@ std::vector<handdleAI::Bbox> getpinHandleAiEvaluateRect(std::shared_ptr <detData
int avgWidth = totalWidth / detResult.size();
cv::Point centerPos(src.rows / 2, src.cols / 2);
cv::Rect targetRect(src.cols / 3, src.rows / 3, src.cols / 3, src.rows / 3);
cv::Rect targetRect(src.cols / 4, src.rows / 4, src.cols / 2, src.rows / 2);
for (auto detData : detResult)
{
if ((detData.x< targetRect.x || detData.x > targetRect.x + targetRect.width ||
+34 -4
View File
@@ -87,6 +87,7 @@ public:
manualDetThread _manualDetThread;//手动触发线程
///////////////////////////////
bool startDet = false;
QMutex detMutex;
std::string currentSn;
void detProcessCallbackRegister()
@@ -97,7 +98,8 @@ public:
_triggerManager.registerCallback(361, 1, [this](QByteArray& byteArray) {detectionSwitch1(byteArray); }, "检测开始");
_triggerManager.registerCallback(361, 2, [this](QByteArray& byteArray) {detectionSwitch2(byteArray); }, "检测结束1");
_triggerManager.registerCallback(362, 1, [this](QByteArray& byteArray) {detectionEnd(byteArray); }, "检测结束2");
_triggerManager.registerCallback(364, 1, [this](QByteArray& byteArray) {frontBackDet(); }, "检测正反面");
_threadManager.registerCallback([this](std::shared_ptr<detData>data) {correctionResultHandle(data); });
_threadManager.registerCallback([this](std::shared_ptr<detData>data) {detectionResultHandle(data); });
}
@@ -228,6 +230,7 @@ public:
//拍照并检测 300
void captureImageAndDetection(QByteArray& byteArray)
{
startDet = true;
//detMutex.lock();
_lightSourceManager.getLightSourcePtr("COM9")->setValue(lightSourceChannel::DChannel, 255);
QThread::msleep(2000);//延时等待机械臂停稳
@@ -277,7 +280,7 @@ public:
emit _core._qtFunc.simpleSiemensTcp_Write100True();
}
}
//机械臂结束
//检测程序结束结束
void detectionEnd(QByteArray& byteArray)
{
_simpleSiemensTcp.writeDM100FALSE();
@@ -326,12 +329,16 @@ public:
int currentProductIndex = _core._appConfig._switchProductWidgetDataPtr.currentProductIndex;
if (currentBack == true)
currentBack = false;
else if (_core._appConfig.productDatas[currentProductIndex].isBackExist == true && result == true)
else if (
_core._appConfig.productDatas[currentProductIndex].isBackExist == true
&& result == true
&& startDet == true)
{
backArmIndex = _core._appConfig.productDatas[currentProductIndex].backArmIndex;
emit _core._qtFunc.uiModuleBackContinueDetDialog_show();
emit _core._qtFunc.uiModulestartDetBtn_disable();
}
startDet = false;
}
//校准结果处理
void correctionResultHandle(std::shared_ptr<detData>data)
@@ -441,7 +448,30 @@ public:
detDataManager* dManager = data->dManager;
data->dManager->deleteDetData(data->timeCode);
}
//使用点激光测量检测是否为正面,没数据就是正面
void frontBackDet()
{
_triggerManager.sendFinsMsg("write_short_364_1");
auto cameraPtr = _cameraManager.getCamera("181964");
if (cameraPtr == nullptr)
return;
for (int i = 0; i < 10; i++)//弃用
{
cameraPtr->trigger();
cameraPtr->getCameraValue();
}
for (int i = 0; i < 100; i++)//检测是否有数据
{
cameraPtr->trigger();
if (cameraPtr->getCameraValue() > -100)//有数据 是反面
{
_triggerManager.sendFinsMsg("write_short_365_2");
break;
}
}
_triggerManager.sendFinsMsg("write_short_365_1");//无数据 是正面
//正面反面是否继续检测,在机械臂脚本中决定
}
public slots:
void runBackDet()
+6 -2
View File
@@ -122,9 +122,13 @@ void connectSignalAndSlots(MainWindow* front, appCore* _core, detProcess* _detPr
front, [=]() {front->_displayWidget->_summaryDataManager->resetAllValue(); });
QObject::connect(&_core->_qtFunc, &qtFunction::uiModulestartDetBtn_disable,
front, [=]() {front->_displayWidget->_switchProductWidget->startBtn->setDisabled(true); });
front, [=]() {front->_displayWidget->_switchProductWidget->startBtn->setDisabled(true);
front->_displayWidget->_switchProductWidget->disableTextChange = true;
front->_displayWidget->_switchProductWidget->startBtn->setText(" "); });
QObject::connect(&_core->_qtFunc, &qtFunction::uiModulestartDetBtn_enable,
front, [=]() {front->_displayWidget->_switchProductWidget->startBtn->setEnabled(true); });
front, [=]() {front->_displayWidget->_switchProductWidget->startBtn->setEnabled(true);
front->_displayWidget->_switchProductWidget->disableTextChange = false;
front->_displayWidget->_switchProductWidget->startBtn->setText("运行"); });
QObject::connect(&_core->_qtFunc, &qtFunction::uiModuleBackContinueDetDialog_show,
front, [=]() {front->_backContinueDetDialog->show(); });
@@ -20,6 +20,7 @@ class switchProductWidget : public QWidget
Q_OBJECT
public:
//
bool disableTextChange = false;
QMutex mutex;
std::vector<productDataStruct>productDatas;
int* currentProductIndexPtr;
@@ -137,14 +138,16 @@ public slots:
if (status == true)
{
startBtn->toDefault();
startBtn->setText("运行");
if(disableTextChange == false)
startBtn->setText("运行");
snIntputLine->setDisabled(false);
std::cout << "按下软件运行" << std::endl;
}
else
{
startBtn->toRed();
startBtn->setText("急停");
if (disableTextChange == false)
startBtn->setText("急停");
snIntputLine->setDisabled(true);
std::cout << "按下软件急停" << std::endl;
}