|
|
|
|
@ -5,32 +5,37 @@ SmokeBoxIdentification::SmokeBoxIdentification(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
{
|
|
|
|
|
qRegisterMetaType<QVector<ImageInfo> >("QVector<ImageInfo>");
|
|
|
|
|
qRegisterMetaType<QMap<QString, int> >("QMap<QString,int>");
|
|
|
|
|
qRegisterMetaType<lightCtrl>("lightCtrl");
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
this->setWindowTitle(tr("烟箱检测系统"));
|
|
|
|
|
//m_pShowRltImgLabel = ui.label_showImg;
|
|
|
|
|
m_pCameraControl = new CameraControl();
|
|
|
|
|
m_pCaptureThread = new QThread();
|
|
|
|
|
m_pCameraControl->moveToThread(m_pCaptureThread);
|
|
|
|
|
//m_pCameraControl = new CameraControl();
|
|
|
|
|
//m_pCaptureThread = new QThread();
|
|
|
|
|
//m_pCameraControl->moveToThread(m_pCaptureThread);
|
|
|
|
|
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgCapture, m_pCameraControl, &CameraControl::onCapture);
|
|
|
|
|
connect(m_pCameraControl, &CameraControl::sgCapturedImage, this, &SmokeBoxIdentification::onCapturedImage);
|
|
|
|
|
connect(m_pCaptureThread, &QThread::finished, m_pCameraControl, &QObject::deleteLater);
|
|
|
|
|
m_pCaptureThread->start();
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgCapture, CameraControl::instance(), &CameraControl::onCapture);
|
|
|
|
|
connect(CameraControl::instance(), &CameraControl::sgCapturedImage, this, &SmokeBoxIdentification::onCapturedImage);
|
|
|
|
|
//connect(m_pCaptureThread, &QThread::finished, m_pCameraControl, &QObject::deleteLater);
|
|
|
|
|
//m_pCaptureThread->start();
|
|
|
|
|
|
|
|
|
|
QString applicationDirPath = QCoreApplication::applicationDirPath();
|
|
|
|
|
QtConcurrent::run([=]()
|
|
|
|
|
{
|
|
|
|
|
readCameraConfig();
|
|
|
|
|
m_bCamerasInit = initCamera();
|
|
|
|
|
//readCameraConfig();
|
|
|
|
|
//m_bCamerasInit = initCamera();
|
|
|
|
|
if (decodeSmokeInfoCsv(applicationDirPath + SMOKEINFO_XLSX_CONFIG))
|
|
|
|
|
matchSmokeNameAndTemplateFolderName(applicationDirPath + NUM_TEMPLATE_PATH);
|
|
|
|
|
m_pNumTemplateBuild = new QNumTemplateBuild();
|
|
|
|
|
m_pDataProcess = std::make_shared<dataPreProcessing>();
|
|
|
|
|
if (m_pDataProcess)
|
|
|
|
|
{
|
|
|
|
|
dataPreProcessing * t = (dataPreProcessing*)m_pDataProcess.get();
|
|
|
|
|
//dataPreProcessing * t = (dataPreProcessing*)m_pDataProcess.get();
|
|
|
|
|
m_pDataProcess->getFileDir(applicationDirPath + NUM_TEMPLATE_PATH);
|
|
|
|
|
m_pDataProcess->transmitFilePathForSampleWithItsCorresLabel();
|
|
|
|
|
ADModule::instance()->setDataProcessObj(m_pDataProcess);
|
|
|
|
|
m_pDataProcess->setWinSize(170);
|
|
|
|
|
ADModule::instance()->setDataProcessObj(m_pDataProcess);
|
|
|
|
|
m_pNumTemplateBuild->setDataProcessObj(m_pDataProcess);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -38,222 +43,251 @@ SmokeBoxIdentification::SmokeBoxIdentification(QWidget *parent)
|
|
|
|
|
m_pNetControl = new NetControl(filePath, true);
|
|
|
|
|
connect(m_pNetControl, &NetControl::sgReceiveData, this, &SmokeBoxIdentification::onDecodeMsg);
|
|
|
|
|
ADModule::instance()->loadParameters(filePath);
|
|
|
|
|
filePath = applicationDirPath + SERIAL_CONFIG;
|
|
|
|
|
filePath = applicationDirPath + COM_CONFIG;
|
|
|
|
|
lpSerialStation::instance()->loadParameters(filePath);
|
|
|
|
|
CodeScanStation::instance()->loadParameters(filePath);
|
|
|
|
|
lpSerialStation::instance()->openComs();
|
|
|
|
|
CodeScanStation::instance()->openComs();
|
|
|
|
|
m_pCategoryMatcher = new CategoryMatcher();
|
|
|
|
|
connect(CodeScanStation::instance(), &CodeScanStation::sgNewCodeScanData, lpSerialStation::instance()
|
|
|
|
|
, &lpSerialStation::onNewCodeScanResults);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgCategoryMatchFinished, this, &SmokeBoxIdentification::onNumStatistic);
|
|
|
|
|
connect(lpSerialStation::instance(), &lpSerialStation::sgMonitorSensorTriggerStart, this
|
|
|
|
|
, &SmokeBoxIdentification::onMonitorSensorTriggerStart);
|
|
|
|
|
connect(lpSerialStation::instance(), &lpSerialStation::sgMonitorSensorTriggerStop, this
|
|
|
|
|
, &SmokeBoxIdentification::onMonitorSensorTriggerStop);
|
|
|
|
|
connect(lpSerialStation::instance(), &lpSerialStation::sgNewEmptyCheckResults, this
|
|
|
|
|
, &SmokeBoxIdentification::onSendEmptyCheckResults);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgControlSideLight, lpSerialStation::instance()
|
|
|
|
|
, &lpSerialStation::onControlSideLight);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgStartEmptyPlaceCheck, lpSerialStation::instance()
|
|
|
|
|
, &lpSerialStation::onStartEmptyPlaceCheck);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgStopEmptyPlaceCheck, lpSerialStation::instance()
|
|
|
|
|
, &lpSerialStation::onStopEmptyPlaceCheck);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgMonitorSensorTriggerStart, ADModule::instance()
|
|
|
|
|
, &ADModule::onDataRequestStart);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgMonitorSensorTriggerStop, ADModule::instance()
|
|
|
|
|
, &ADModule::onDataRequestStop);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSendData2AndAlgo, ADModule::instance(), &ADModule::onSendData2Algo);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSaveSensorData2Local, ADModule::instance(), &ADModule::onSaveData2File);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSendStockCheckMsg, this, &SmokeBoxIdentification::onSendStockCheckMsg, Qt::QueuedConnection);
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSendStockCheckMsg, this, &SmokeBoxIdentification::onSendStockCheckResults, Qt::QueuedConnection);
|
|
|
|
|
connect(ui.action_templateNum, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOnLight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SmokeBoxIdentification::~SmokeBoxIdentification()
|
|
|
|
|
{
|
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOffLight);
|
|
|
|
|
DELETE_POINTER(m_pNetControl);
|
|
|
|
|
m_pCaptureThread->quit();
|
|
|
|
|
m_pCaptureThread->wait();
|
|
|
|
|
DELETE_POINTER(m_pCaptureThread);
|
|
|
|
|
DELETE_POINTER(m_pCameraControl);
|
|
|
|
|
//m_pCaptureThread->quit();
|
|
|
|
|
//m_pCaptureThread->wait();
|
|
|
|
|
//DELETE_POINTER(m_pCaptureThread);
|
|
|
|
|
//DELETE_POINTER(m_pCameraControl);
|
|
|
|
|
DELETE_POINTER(m_pCategoryMatcher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SmokeBoxIdentification::readCameraConfig()
|
|
|
|
|
{
|
|
|
|
|
m_mapIdCameraInfoSide.clear();
|
|
|
|
|
m_mapIdCameraInfoTop.clear();
|
|
|
|
|
m_mapSerialNumberIdSide.clear();
|
|
|
|
|
m_mapSerialNumberIdTop.clear();
|
|
|
|
|
QString filePath = QCoreApplication::applicationDirPath() + CAMERA_CONFIG;
|
|
|
|
|
QFile file(filePath);
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "打开文件失败!";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
QByteArray arr = file.readAll();
|
|
|
|
|
file.close();
|
|
|
|
|
if (arr.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "内容为空";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QJsonParseError err;
|
|
|
|
|
QJsonDocument doc = QJsonDocument::fromJson(arr, &err);
|
|
|
|
|
if (doc.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
qWarning() << err.errorString(); //打印失败信息
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//bool SmokeBoxIdentification::readCameraConfig()
|
|
|
|
|
//{
|
|
|
|
|
// m_mapIdCameraInfoSide.clear();
|
|
|
|
|
// m_mapIdCameraInfoTop.clear();
|
|
|
|
|
// m_mapSerialNumberIdSide.clear();
|
|
|
|
|
// m_mapSerialNumberIdTop.clear();
|
|
|
|
|
// QString filePath = QCoreApplication::applicationDirPath() + CAMERA_CONFIG;
|
|
|
|
|
// QFile file(filePath);
|
|
|
|
|
// if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "打开文件失败!";
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// QByteArray arr = file.readAll();
|
|
|
|
|
// file.close();
|
|
|
|
|
// if (arr.isEmpty())
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "内容为空";
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// QJsonParseError err;
|
|
|
|
|
// QJsonDocument doc = QJsonDocument::fromJson(arr, &err);
|
|
|
|
|
// if (doc.isEmpty())
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << err.errorString(); //打印失败信息
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// QJsonObject jsonObj = doc.object();
|
|
|
|
|
// auto getCameraType = [](int type)-> CameraType
|
|
|
|
|
// {
|
|
|
|
|
// CameraType cameraType;
|
|
|
|
|
// switch (type)
|
|
|
|
|
// {
|
|
|
|
|
// case 100:
|
|
|
|
|
// cameraType = CameraType::Virtual;
|
|
|
|
|
// break;
|
|
|
|
|
// case 140:
|
|
|
|
|
// cameraType = CameraType::Hik;
|
|
|
|
|
// break;
|
|
|
|
|
// case 190:
|
|
|
|
|
// cameraType = CameraType::Basler;
|
|
|
|
|
// break;
|
|
|
|
|
// default:
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// return cameraType;
|
|
|
|
|
// };
|
|
|
|
|
// QJsonObject topObj = jsonObj.value("top").toObject();
|
|
|
|
|
// int topStartId, topEndId;
|
|
|
|
|
// if (!topObj.isEmpty())
|
|
|
|
|
// {
|
|
|
|
|
// topStartId = topObj.value("startID").toInt();
|
|
|
|
|
// topEndId = topObj.value("endID").toInt();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "top id error";
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// QJsonObject sideObj = jsonObj.value("side").toObject();
|
|
|
|
|
// int sideStartId, sideEndId;
|
|
|
|
|
// if (!sideObj.isEmpty())
|
|
|
|
|
// {
|
|
|
|
|
// sideStartId = sideObj.value("startID").toInt();
|
|
|
|
|
// sideEndId = sideObj.value("endID").toInt();
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "side id error";
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// QJsonObject devicesObj = jsonObj.value("devices").toObject();
|
|
|
|
|
// if (!devicesObj.isEmpty()) {
|
|
|
|
|
// CameraInfo cameraInfo;
|
|
|
|
|
// QStringList devicesLabelList = devicesObj.keys();
|
|
|
|
|
// for each (QString deviceLabel in devicesLabelList)
|
|
|
|
|
// {
|
|
|
|
|
// cameraInfo.cameraLabel = deviceLabel;
|
|
|
|
|
// QStringList strList = deviceLabel.split(' ');
|
|
|
|
|
// if (strList.length() != 2)
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "Device label: " << deviceLabel << " syntax error!";
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// cameraInfo.modelName = strList.at(0);
|
|
|
|
|
// cameraInfo.serialNumber = strList.at(1);
|
|
|
|
|
// QJsonObject deviceObj = devicesObj.value(deviceLabel).toObject();
|
|
|
|
|
// if (!deviceObj.isEmpty())
|
|
|
|
|
// {
|
|
|
|
|
// cameraInfo.cameraType = getCameraType(deviceObj.value("type").toInt());
|
|
|
|
|
// cameraInfo.exposure = deviceObj.value("exposure").toDouble();
|
|
|
|
|
// cameraInfo.imageHeight = deviceObj.value("height").toInt();
|
|
|
|
|
// cameraInfo.imageWidth = deviceObj.value("width").toInt();
|
|
|
|
|
// cameraInfo.saveImgSuffix = deviceObj.value("save_img_suffix").toString();
|
|
|
|
|
// int id = deviceObj.value("id").toInt();
|
|
|
|
|
// if (id >= topStartId && id <= topEndId)
|
|
|
|
|
// {
|
|
|
|
|
// m_mapIdCameraInfoTop[id] = cameraInfo;
|
|
|
|
|
// m_mapSerialNumberIdTop[cameraInfo.serialNumber] = id;
|
|
|
|
|
// }
|
|
|
|
|
// else if (id >= sideStartId && id <= sideEndId)
|
|
|
|
|
// {
|
|
|
|
|
// m_mapIdCameraInfoSide[id] = cameraInfo;
|
|
|
|
|
// m_mapSerialNumberIdSide[cameraInfo.serialNumber] = id;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return true;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
QJsonObject jsonObj = doc.object();
|
|
|
|
|
auto getCameraType = [](int type)-> CameraType
|
|
|
|
|
{
|
|
|
|
|
CameraType cameraType;
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case 100:
|
|
|
|
|
cameraType = CameraType::Virtual;
|
|
|
|
|
break;
|
|
|
|
|
case 140:
|
|
|
|
|
cameraType = CameraType::Hik;
|
|
|
|
|
break;
|
|
|
|
|
case 190:
|
|
|
|
|
cameraType = CameraType::Basler;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return cameraType;
|
|
|
|
|
};
|
|
|
|
|
QJsonObject topObj = jsonObj.value("top").toObject();
|
|
|
|
|
int topStartId, topEndId;
|
|
|
|
|
if (!topObj.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
topStartId = topObj.value("startID").toInt();
|
|
|
|
|
topEndId = topObj.value("endID").toInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "top id error";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
QJsonObject sideObj = jsonObj.value("side").toObject();
|
|
|
|
|
int sideStartId, sideEndId;
|
|
|
|
|
if (!sideObj.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
sideStartId = sideObj.value("startID").toInt();
|
|
|
|
|
sideEndId = sideObj.value("endID").toInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "side id error";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
QJsonObject devicesObj = jsonObj.value("devices").toObject();
|
|
|
|
|
if (!devicesObj.isEmpty()) {
|
|
|
|
|
CameraInfo cameraInfo;
|
|
|
|
|
QStringList devicesLabelList = devicesObj.keys();
|
|
|
|
|
for each (QString deviceLabel in devicesLabelList)
|
|
|
|
|
{
|
|
|
|
|
cameraInfo.cameraLabel = deviceLabel;
|
|
|
|
|
QStringList strList = deviceLabel.split(' ');
|
|
|
|
|
if (strList.length() != 2)
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "Device label: " << deviceLabel << " syntax error!";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
cameraInfo.modelName = strList.at(0);
|
|
|
|
|
cameraInfo.serialNumber = strList.at(1);
|
|
|
|
|
QJsonObject deviceObj = devicesObj.value(deviceLabel).toObject();
|
|
|
|
|
if (!deviceObj.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
cameraInfo.cameraType = getCameraType(deviceObj.value("type").toInt());
|
|
|
|
|
cameraInfo.exposure = deviceObj.value("exposure").toDouble();
|
|
|
|
|
cameraInfo.imageHeight = deviceObj.value("height").toInt();
|
|
|
|
|
cameraInfo.imageWidth = deviceObj.value("width").toInt();
|
|
|
|
|
cameraInfo.saveImgSuffix = deviceObj.value("save_img_suffix").toString();
|
|
|
|
|
int id = deviceObj.value("id").toInt();
|
|
|
|
|
if (id >= topStartId && id <= topEndId)
|
|
|
|
|
{
|
|
|
|
|
m_mapIdCameraInfoTop[id] = cameraInfo;
|
|
|
|
|
m_mapSerialNumberIdTop[cameraInfo.serialNumber] = id;
|
|
|
|
|
}
|
|
|
|
|
else if (id >= sideStartId && id <= sideEndId)
|
|
|
|
|
{
|
|
|
|
|
m_mapIdCameraInfoSide[id] = cameraInfo;
|
|
|
|
|
m_mapSerialNumberIdSide[cameraInfo.serialNumber] = id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//bool SmokeBoxIdentification::initCamera()
|
|
|
|
|
//{
|
|
|
|
|
// QList<CameraInfo> cameraInfoList = m_mapIdCameraInfoSide.values();
|
|
|
|
|
// cameraInfoList.append(m_mapIdCameraInfoTop.values());
|
|
|
|
|
// if (!m_pCameraControl->loadCamera(cameraInfoList))
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "Load camera failed";
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// QStringList serialNumberList = m_mapSerialNumberIdSide.keys();
|
|
|
|
|
// serialNumberList.append(m_mapSerialNumberIdTop.keys());
|
|
|
|
|
// if (!m_pCameraControl->openCamera(serialNumberList))
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "Open camera failed";
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// if (!m_pCameraControl->startCamera(serialNumberList))
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "Start camera failed";
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// if (!m_pCameraControl->setSoftwareTrigger(serialNumberList))
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "Set software trigger failed";
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return true;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
bool SmokeBoxIdentification::initCamera()
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onActionClicked()
|
|
|
|
|
{
|
|
|
|
|
QList<CameraInfo> cameraInfoList = m_mapIdCameraInfoSide.values();
|
|
|
|
|
cameraInfoList.append(m_mapIdCameraInfoTop.values());
|
|
|
|
|
if (!m_pCameraControl->loadCamera(cameraInfoList))
|
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
|
if (strObj == "action_templateNum")
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "Load camera failed";
|
|
|
|
|
return false;
|
|
|
|
|
m_pNumTemplateBuild->setParent(this);
|
|
|
|
|
m_pNumTemplateBuild->setWindowTitle(tr("建立数量模板"));
|
|
|
|
|
m_pNumTemplateBuild->setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_pNumTemplateBuild->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_pNumTemplateBuild->setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_pNumTemplateBuild->show();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QStringList serialNumberList = m_mapSerialNumberIdSide.keys();
|
|
|
|
|
serialNumberList.append(m_mapSerialNumberIdTop.keys());
|
|
|
|
|
if (!m_pCameraControl->openCamera(serialNumberList))
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "Open camera failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!m_pCameraControl->startCamera(serialNumberList))
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "Start camera failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!m_pCameraControl->setSoftwareTrigger(serialNumberList))
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "Set software trigger failed";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SmokeBoxIdentification::captureTop()
|
|
|
|
|
{
|
|
|
|
|
emit sgCapture(m_mapSerialNumberIdTop.keys());
|
|
|
|
|
emit sgCapture(eCameraLocation::emTop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SmokeBoxIdentification::captureSide()
|
|
|
|
|
{
|
|
|
|
|
emit sgCapture(m_mapSerialNumberIdSide.keys());
|
|
|
|
|
emit sgCapture(eCameraLocation::emSide);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SmokeBoxIdentification::getSaveImgNameInfo(QString serialNumber, FileInfo& fileInfo)
|
|
|
|
|
{
|
|
|
|
|
QString imgSaveBaseName;
|
|
|
|
|
auto iter = m_mapSerialNumberIdSide.find(serialNumber);
|
|
|
|
|
if (iter == m_mapSerialNumberIdSide.end())
|
|
|
|
|
{
|
|
|
|
|
iter = m_mapSerialNumberIdTop.find(serialNumber);
|
|
|
|
|
if (iter != m_mapSerialNumberIdTop.end())
|
|
|
|
|
{
|
|
|
|
|
int id = iter.value();
|
|
|
|
|
QString suffix = m_mapIdCameraInfoTop.value(id).saveImgSuffix;
|
|
|
|
|
fileInfo.suffix = suffix;
|
|
|
|
|
fileInfo.baseName = QString::number(id);
|
|
|
|
|
fileInfo.name = fileInfo.baseName + suffix;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "Can not find " << serialNumber;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int id = iter.value();
|
|
|
|
|
QString suffix = m_mapIdCameraInfoSide.value(id).saveImgSuffix;
|
|
|
|
|
fileInfo.suffix = suffix;
|
|
|
|
|
fileInfo.baseName = QString::number(id);
|
|
|
|
|
fileInfo.name = fileInfo.baseName + suffix;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//bool SmokeBoxIdentification::getSaveImgNameInfo(QString serialNumber, FileInfo& fileInfo)
|
|
|
|
|
//{
|
|
|
|
|
// QString imgSaveBaseName;
|
|
|
|
|
// auto iter = m_mapSerialNumberIdSide.find(serialNumber);
|
|
|
|
|
// if (iter == m_mapSerialNumberIdSide.end())
|
|
|
|
|
// {
|
|
|
|
|
// iter = m_mapSerialNumberIdTop.find(serialNumber);
|
|
|
|
|
// if (iter != m_mapSerialNumberIdTop.end())
|
|
|
|
|
// {
|
|
|
|
|
// int id = iter.value();
|
|
|
|
|
// QString suffix = m_mapIdCameraInfoTop.value(id).saveImgSuffix;
|
|
|
|
|
// fileInfo.suffix = suffix;
|
|
|
|
|
// fileInfo.baseName = QString::number(id);
|
|
|
|
|
// fileInfo.name = fileInfo.baseName + suffix;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// qWarning() << "Can not find " << serialNumber;
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// int id = iter.value();
|
|
|
|
|
// QString suffix = m_mapIdCameraInfoSide.value(id).saveImgSuffix;
|
|
|
|
|
// fileInfo.suffix = suffix;
|
|
|
|
|
// fileInfo.baseName = QString::number(id);
|
|
|
|
|
// fileInfo.name = fileInfo.baseName + suffix;
|
|
|
|
|
// }
|
|
|
|
|
// return true;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void SmokeBoxIdentification::saveImage(const cv::Mat& imgMat, const QString& filePath)
|
|
|
|
|
{
|
|
|
|
|
@ -299,8 +333,7 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < vecImageInfo.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
FileInfo fileInfo;
|
|
|
|
|
getSaveImgNameInfo(vecImageInfo.at(i).cameraSn, fileInfo);
|
|
|
|
|
FileInfo fileInfo = vecImageInfo.at(i).saveImgInfo;
|
|
|
|
|
QString filePath = QString("%1\\%2").arg(dataSaveFolderPath).arg(fileInfo.name);
|
|
|
|
|
if (workMode == WorkMode::IntoStock)
|
|
|
|
|
{
|
|
|
|
|
@ -312,10 +345,10 @@ void SmokeBoxIdentification::saveImage(const QVector<ImageInfo>& vecImageInfo, i
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& vecImageInfo)
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& vecImageInfo, int cameraLocation)
|
|
|
|
|
{
|
|
|
|
|
QString serialNumber = vecImageInfo.last().cameraSn;
|
|
|
|
|
if (m_mapSerialNumberIdTop.contains(serialNumber))
|
|
|
|
|
if (cameraLocation == eCameraLocation::emTop)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "top captured";
|
|
|
|
|
QtConcurrent::run([=] {
|
|
|
|
|
@ -331,7 +364,7 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& ve
|
|
|
|
|
m_workMode = WorkMode::Idle;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (m_mapSerialNumberIdSide.contains(serialNumber))
|
|
|
|
|
else if (cameraLocation == eCameraLocation::emSide)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "side captured";
|
|
|
|
|
QtConcurrent::run([=] {
|
|
|
|
|
@ -346,9 +379,8 @@ Q_SLOT void SmokeBoxIdentification::onCapturedImage(const QVector<ImageInfo>& ve
|
|
|
|
|
if (m_pCategoryMatcher->smokeMatch(typeNum, imgInfo.image, imgRltMat))
|
|
|
|
|
{
|
|
|
|
|
bRlt = true;
|
|
|
|
|
FileInfo fileInfo;
|
|
|
|
|
getSaveImgNameInfo(imgInfo.cameraSn, fileInfo);
|
|
|
|
|
QString fileName = QString("%1_%2_rlt%3").arg(fileInfo.baseName)
|
|
|
|
|
FileInfo fileInfo = imgInfo.saveImgInfo;
|
|
|
|
|
QString fileName = QString("%1_%2_rlt%3").arg(fileInfo.strId)
|
|
|
|
|
.arg(m_currtStockCheckInfo.smokeTypeNum).arg(fileInfo.suffix);
|
|
|
|
|
QString filePath = QString("%1\\%2").arg(dataSaveFolder).arg(fileName);
|
|
|
|
|
saveImage(imgRltMat, filePath);
|
|
|
|
|
@ -386,7 +418,32 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
|
|
|
|
|
qDebug() << "msg: " << msg << " content: " << msgContent;
|
|
|
|
|
QStringList strList = msgContent.split(SPLIT_RULE);
|
|
|
|
|
qDebug() << "strlist length: " << strList.length() << " head: " << strList.at(0);
|
|
|
|
|
if (strList.length() == 7 && strList.at(0) == STOCK_CHECK_HEAD)
|
|
|
|
|
if (strList[0] == EMPTY_CHECK_HEAD)
|
|
|
|
|
{
|
|
|
|
|
if (strList.length() == 4)
|
|
|
|
|
{
|
|
|
|
|
EmptyCheckInfo emptyCheckInfo;
|
|
|
|
|
emptyCheckInfo.streetName = strList[1];
|
|
|
|
|
emptyCheckInfo.taskNum = strList[2];
|
|
|
|
|
m_currtEmptyCheckInfo = emptyCheckInfo;
|
|
|
|
|
if (strList[3] == "START")
|
|
|
|
|
{
|
|
|
|
|
m_workMode = WorkMode::EmptyCheck;
|
|
|
|
|
emit sgStartEmptyPlaceCheck(m_currtEmptyCheckInfo.streetName);
|
|
|
|
|
}
|
|
|
|
|
else if (strList[3] == "END")
|
|
|
|
|
{
|
|
|
|
|
if (m_workMode == WorkMode::EmptyCheck)
|
|
|
|
|
{
|
|
|
|
|
emit sgStopEmptyPlaceCheck();
|
|
|
|
|
m_workMode = WorkMode::Idle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (strList.at(0) == STOCK_CHECK_HEAD)
|
|
|
|
|
{
|
|
|
|
|
if (strList.length() == 7)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "开始货位盘点";
|
|
|
|
|
m_workMode = WorkMode::StockCheck;
|
|
|
|
|
@ -398,7 +455,7 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
|
|
|
|
|
stockCheckInfo.smokeQuantity = strList.at(5);
|
|
|
|
|
m_currtStockCheckInfo = stockCheckInfo;
|
|
|
|
|
}
|
|
|
|
|
else if (strList.length() == 3 && strList.at(0) == STOCK_CHECK_HEAD)
|
|
|
|
|
else if (strList.length() == 3)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "取货到位";
|
|
|
|
|
QString taskNum = strList.at(2);
|
|
|
|
|
@ -409,7 +466,10 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
|
|
|
|
|
captureTop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strList.length() == 4 && strList.at(0) == INTO_STOCK_HEAD)
|
|
|
|
|
}
|
|
|
|
|
else if (strList.at(0) == INTO_STOCK_HEAD)
|
|
|
|
|
{
|
|
|
|
|
if (strList.length() == 4)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "入库顶部拍照";
|
|
|
|
|
m_workMode = WorkMode::IntoStock;
|
|
|
|
|
@ -421,6 +481,22 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
|
|
|
|
|
captureTop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strList.at(0) == LIGHT_CONTROL_HEAD)
|
|
|
|
|
{
|
|
|
|
|
if (strList.length() == 3)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "开关灯";
|
|
|
|
|
if (strList.at(2) == "0")
|
|
|
|
|
{
|
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOffLight);
|
|
|
|
|
}
|
|
|
|
|
else if (strList.at(2) == "1")
|
|
|
|
|
{
|
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOnLight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onNumStatistic(QString typeNum)
|
|
|
|
|
{
|
|
|
|
|
@ -428,11 +504,6 @@ Q_SLOT void SmokeBoxIdentification::onNumStatistic(QString typeNum)
|
|
|
|
|
if (!m_bDataCollection)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "typeNum: " << typeNum;
|
|
|
|
|
QString dataSaveFolder = QString("%1\\%2\\%3\\%4").arg(FILE_STORAGE_PATH)
|
|
|
|
|
.arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum)
|
|
|
|
|
.arg(m_currtStockCheckInfo.smokeQuantity);
|
|
|
|
|
dataPreProcessing::mkDir(dataSaveFolder);
|
|
|
|
|
emit sgSaveSensorData2Local(dataSaveFolder);
|
|
|
|
|
if (typeNum == "0")
|
|
|
|
|
{
|
|
|
|
|
m_currtStockCheckInfo.smokeQuantityRlt = "0";
|
|
|
|
|
@ -487,7 +558,7 @@ Q_SLOT void SmokeBoxIdentification::onNumStatistic(QString typeNum)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SmokeBoxIdentification::onSendStockCheckMsg(int mode)
|
|
|
|
|
void SmokeBoxIdentification::onSendStockCheckResults(int mode)
|
|
|
|
|
{
|
|
|
|
|
QString resultInfoMsg;
|
|
|
|
|
switch (mode)
|
|
|
|
|
@ -561,6 +632,11 @@ Q_SLOT void SmokeBoxIdentification::onMonitorSensorTriggerStop(eSideID)
|
|
|
|
|
emit sgMonitorSensorTriggerStop();
|
|
|
|
|
m_bDataCollection = false;
|
|
|
|
|
emit sgSendData2AndAlgo();
|
|
|
|
|
QString dataSaveFolder = QString("%1\\%2\\%3\\%4").arg(FILE_STORAGE_PATH)
|
|
|
|
|
.arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum)
|
|
|
|
|
.arg(m_currtStockCheckInfo.smokeQuantity);
|
|
|
|
|
dataPreProcessing::mkDir(dataSaveFolder);
|
|
|
|
|
emit sgSaveSensorData2Local(dataSaveFolder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -596,7 +672,7 @@ bool SmokeBoxIdentification::decodeSmokeInfoCsv(const QString& filePath)
|
|
|
|
|
|
|
|
|
|
int rowEnd = cellRange.lastRow();
|
|
|
|
|
int colEnd = cellRange.lastColumn();
|
|
|
|
|
for (int i = rowStart + 2; i <= rowEnd; ++i)
|
|
|
|
|
for (int i = rowStart + 1; i <= rowEnd; ++i)
|
|
|
|
|
{
|
|
|
|
|
QString smokeCode = wsheet->read(i, colStart).toString();
|
|
|
|
|
QString smokeName = wsheet->read(i, colStart + 1).toString();
|
|
|
|
|
@ -650,3 +726,20 @@ bool SmokeBoxIdentification::matchSmokeNameAndTemplateFolderName(const QString&
|
|
|
|
|
qDebug() << "match smokeName and templateFolderName successed";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onSendEmptyCheckResults(const QMap<QString, int>& mapEmptyCheckResults)
|
|
|
|
|
{
|
|
|
|
|
QString emptyAll;
|
|
|
|
|
for each (QString code in mapEmptyCheckResults.keys())
|
|
|
|
|
{
|
|
|
|
|
int emptyStatus = mapEmptyCheckResults[code];
|
|
|
|
|
emptyAll.append(code).append(CODE_CONTENT_SPLIT).append(QString::number(emptyStatus))
|
|
|
|
|
.append(CONTENT_SPLIT);
|
|
|
|
|
}
|
|
|
|
|
QString emptyResult;
|
|
|
|
|
emptyResult.append(EMPTY_CHECK_HEAD).append(SPLIT_RULE).append(m_currtEmptyCheckInfo.streetName)
|
|
|
|
|
.append(SPLIT_RULE).append(m_currtEmptyCheckInfo.taskNum).append(SPLIT_RULE).append(emptyAll)
|
|
|
|
|
.append(END_SYMBOL);
|
|
|
|
|
m_pNetControl->sendMsg(emptyResult);
|
|
|
|
|
qDebug() << "send msg: " << emptyResult;
|
|
|
|
|
}
|