diff --git a/candy b/candy index 3aac23e..bbc9f68 100644 Binary files a/candy and b/candy differ diff --git a/candy.pro.user b/candy.pro.user index f0ea7a8..05efa5b 100644 --- a/candy.pro.user +++ b/candy.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {f40858e6-f94a-4d17-9db8-96ef47726f77} + {64e02d7d-cd76-4242-b280-2dec608f5169} ProjectExplorer.Project.ActiveTarget @@ -61,12 +61,12 @@ Desktop Desktop - {8fde18c1-a446-458e-9f45-046b48cb1bad} + {00533096-fe49-4822-b384-b3c69b58cfb0} 0 0 0 - /home/nvidia/CandyProject/candy + /home/nvidia/CandyProject/candy624 true @@ -184,13 +184,13 @@ candy - Qt4ProjectManager.Qt4RunConfiguration:/home/nvidia/CandyProject/candy/candy.pro + Qt4ProjectManager.Qt4RunConfiguration:/home/nvidia/CandyProject/candy624/candy.pro true candy.pro false - /home/nvidia/CandyProject/candy + /home/nvidia/CandyProject/candy624 3768 false true diff --git a/ccc.mfs b/ccc.mfs index 3f68df2..39674f0 100644 --- a/ccc.mfs +++ b/ccc.mfs @@ -1,6 +1,6 @@ # {05D8C294-F295-4dfb-9D01-096BD04049F4} # GenApi persistence file (version 3.0.0) -# Device = HIKROBOT::HIKCamera -- HIKROBOT GigE Vision Camera Interface -- Device version = 1.2.0 -- Product GUID = EE4B7E09-DA29-4956-A1EC-212263331CFC -- Product version GUID = 79ace398-62e3-44a6-8845-f81aaf104382 +# Device = GEV::Camera -- GigE Vision Camera Interface -- Device version = 1.2.0 -- Product GUID = EE4B7E09-DA29-4956-A1EC-212263331CFC -- Product version GUID = 79ace398-62e3-44a6-8845-f81aaf104382 DeviceLinkSelector 0 DeviceLinkHeartbeatMode On DeviceLinkSelector 0 @@ -64,7 +64,7 @@ AcquisitionFrameRate 11.57 AcquisitionFrameRateEnable 1 TriggerSelector FrameBurstStart TriggerSelector FrameBurstStart -TriggerMode On +TriggerMode Off TriggerSelector FrameBurstStart TriggerSelector FrameBurstStart TriggerSource Line2 @@ -239,6 +239,7 @@ AutoFunctionAOIUsageWhiteBalance 0 AutoFunctionAOISelector AOI1 UserSetSelector Default UserSetDefault Default +GevPAUSEFrameReception 0 GevHeartbeatTimeout 3000 GevGVCPHeartbeatDisable 0 GevMCTT 0 diff --git a/moc_widget.cpp b/moc_widget.cpp index 41568b0..723e80d 100644 --- a/moc_widget.cpp +++ b/moc_widget.cpp @@ -22,7 +22,7 @@ static const uint qt_meta_data_Widget[] = { 6, // revision 0, // classname 0, 0, // classinfo - 48, 14, // methods + 49, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -80,6 +80,7 @@ static const uint qt_meta_data_Widget[] = { 1023, 24, 24, 24, 0x08, 1041, 24, 24, 24, 0x08, 1059, 24, 24, 24, 0x08, + 1080, 24, 24, 24, 0x08, 0 // eod }; @@ -114,6 +115,7 @@ static const char qt_meta_stringdata_Widget[] = { "On_btn6_clicked()\0On_btn7_clicked()\0" "On_btn8_clicked()\0On_btn9_clicked()\0" "On_btn0_clicked()\0On_btn_DEL_clicked()\0" + "readfrom_lowermachine()\0" }; void Widget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) @@ -170,6 +172,7 @@ void Widget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void case 45: _t->On_btn9_clicked(); break; case 46: _t->On_btn0_clicked(); break; case 47: _t->On_btn_DEL_clicked(); break; + case 48: _t->readfrom_lowermachine(); break; default: ; } } @@ -207,9 +210,9 @@ int Widget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 48) + if (_id < 49) qt_static_metacall(this, _c, _id, _a); - _id -= 48; + _id -= 49; } return _id; } diff --git a/moc_widget.o b/moc_widget.o index a06707e..393eadc 100644 Binary files a/moc_widget.o and b/moc_widget.o differ diff --git a/para.ini b/para.ini index 24f8863..5a8ca39 100644 Binary files a/para.ini and b/para.ini differ diff --git a/thread.cpp b/thread.cpp index db3d8fb..4dfa5da 100644 --- a/thread.cpp +++ b/thread.cpp @@ -9,6 +9,7 @@ #include #include #include +#include QSemaphore emptybuff(2); //空缓冲区信号量 QSemaphore fullbuff(0); //正在处理的缓冲区信号量 @@ -39,7 +40,10 @@ extern void __stdcall onImageDataCallBackFunc(unsigned char * pData, MV_FRAME_OU if(!emptybuff.tryAcquire()) //申请空缓冲区 { loss_flag = true; - qDebug()<<"loss loss loss loss loss loss loss loss"; + + std::cout << ">>> loss loss loss loss <<<" << std::endl; + fflush(0); + return; } @@ -81,7 +85,7 @@ Process_img::Process_img(QObject *parent) : QThread(parent), m_stop(false) void Process_img::run() { - qDebug()<<"deal thread:"< 0) //确保为0 @@ -219,23 +223,7 @@ void Process_img::data_process(cv::Mat img) if(defect_size < blow_time) { int compensation = (blow_time - defect_size) / 2; -// if (start - compensation < 0) -// { -// start = 0; -// } -// else -// { -// start = start - compensation; -// } -// if (end + compensation > (PULSE_NUMBER-1)) -// { -// end = PULSE_NUMBER-1; -// } -// else -// { -// end = end + compensation; -// } if((start - compensation > 0) && ((end + compensation) < PULSE_NUMBER - 1)) { start = start - compensation; diff --git a/thread.o b/thread.o index afdc2e2..da6d929 100644 Binary files a/thread.o and b/thread.o differ diff --git a/ui_widget.h b/ui_widget.h index 582a4cf..757fed2 100644 --- a/ui_widget.h +++ b/ui_widget.h @@ -42,6 +42,7 @@ public: QPushButton *btn_Tab2_1; QPushButton *btn_Tab2_5; QLabel *label_stop; + QLabel *label_warning; QWidget *tab_3; QPushButton *btn_Tab3_4; QPushButton *btn_Tab3_6; @@ -524,6 +525,11 @@ public: QFont font4; font4.setPointSize(18); label_stop->setFont(font4); + label_warning = new QLabel(tab_2); + label_warning->setObjectName(QString::fromUtf8("label_warning")); + label_warning->setGeometry(QRect(530, 530, 141, 41)); + label_warning->setFont(font4); + label_warning->setStyleSheet(QString::fromUtf8("color:rgb(255, 0, 0);")); tabWidget->addTab(tab_2, QString()); tab_3 = new QWidget(); tab_3->setObjectName(QString::fromUtf8("tab_3")); @@ -1352,7 +1358,7 @@ public: retranslateUi(Widget); - tabWidget->setCurrentIndex(4); + tabWidget->setCurrentIndex(1); QMetaObject::connectSlotsByName(Widget); @@ -1381,6 +1387,7 @@ public: btn_Tab2_5->setText(QApplication::translate("Widget", "\345\217\202\346\225\260\350\260\203\346\225\264\n" "Parameters", 0, QApplication::UnicodeUTF8)); label_stop->setText(QString()); + label_warning->setText(QString()); tabWidget->setTabText(tabWidget->indexOf(tab_2), QApplication::translate("Widget", "Tab 2", 0, QApplication::UnicodeUTF8)); btn_Tab3_4->setText(QApplication::translate("Widget", "\347\233\270\346\234\272\345\217\202\346\225\260\350\256\276\347\275\256\n" "Camera Parameters", 0, QApplication::UnicodeUTF8)); diff --git a/widget.cpp b/widget.cpp index ae74b0e..645b172 100644 --- a/widget.cpp +++ b/widget.cpp @@ -40,6 +40,7 @@ Widget::Widget(QWidget *parent) : ui(new Ui::Widget) { ui->setupUi(this); + system("mkdir -p /home/nvidia/candyPic"); this->setWindowFlags(Qt::Widget); this->showFullScreen(); init_window(); @@ -188,19 +189,6 @@ void Widget::connect_signals() connect(ui->btn_channel_up, SIGNAL(clicked()), this, SLOT(On_btnchannelup_click())); connect(ui->btn_channel_down, SIGNAL(clicked()), this, SLOT(On_btnchanneldown_click())); connect(ui->btn_channel_send, SIGNAL(clicked()), this, SLOT(On_btn_channel_send_clicked())); -// connect(ui->btn_1, SIGNAL(clicked()), this, SLOT(On_btn_1_clicked())); -// connect(ui->btn_2, SIGNAL(clicked()), this, SLOT(On_btn_2_clicked())); -// connect(ui->btn_3, SIGNAL(clicked()), this, SLOT(On_btn_3_clicked())); -// connect(ui->btn_4, SIGNAL(clicked()), this, SLOT(On_btn_4_clicked())); -// connect(ui->btn_5, SIGNAL(clicked()), this, SLOT(On_btn_5_clicked())); -// connect(ui->btn_6, SIGNAL(clicked()), this, SLOT(On_btn_6_clicked())); -// connect(ui->btn_7, SIGNAL(clicked()), this, SLOT(On_btn_7_clicked())); -// connect(ui->btn_8, SIGNAL(clicked()), this, SLOT(On_btn_8_clicked())); -// connect(ui->btn_9, SIGNAL(clicked()), this, SLOT(On_btn_9_clicked())); -// connect(ui->btn_0, SIGNAL(clicked()), this, SLOT(On_btn_0_clicked())); -// connect(ui->btn_dot, SIGNAL(clicked()), this, SLOT(On_btn_dot_clicked())); -// connect(ui->btn_del, SIGNAL(clicked()), this, SLOT(On_btn_del_clicked())); -// connect(ui->btn_clr, SIGNAL(clicked()), this, SLOT(On_btn_clr_clicked())); } void Widget::On_btn_Tab1_2_click() @@ -224,6 +212,7 @@ void Widget::On_btnStart_click() connect(process_img, SIGNAL(send_res(QVector)), this, SLOT(drawbox(QVector)), Qt::BlockingQueuedConnection); connect(process_img, SIGNAL(send_tab(uint8_t*)), this, SLOT(get_tab(uint8_t*)), Qt::BlockingQueuedConnection); + ui->label_warning->setText(" "); int n = emptybuff.available(); if(n < 2) { @@ -238,7 +227,7 @@ void Widget::On_btnStart_click() QByteArray ba = delay_time.toLatin1(); char* dt = ba.data(); char send_tab[12]; - qDebug() << dt[0] << dt[1] <exitThread(); process_img->wait(); -// - //my_test_thread -// grab_img->wait(); -// if(grab_img->isFinished()) -// { -// qDebug()<<"grab thread finish"; -// } -// - - if(process_img->isFinished()) + if(!process_img->isFinished()) { - qDebug()<<"process thread finish"; + qDebug()<<"process thread finish failed"; } - -// -// delete grab_img; -// - delete process_img; qDebug() << "Stop Success!"; @@ -586,6 +561,12 @@ void Widget::judge_password(QString password) void Widget::showimage(cv::Mat img) { +// if(loss_flag == true) +// { +// ui->label_warning->setText("loss"); +// QApplication::processEvents(); +// loss_flag = false; +// } static int counter = 0; if(save_flag && counter == 0) { @@ -620,29 +601,27 @@ void Widget::drawbox(QVector bounding_box) QRect rect(bounding_box[i].pointA_x* (pix.width() / 2376.0f), bounding_box[i].pointA_y* (pix.height() / 584.0f), width, height); rects << rect; } - painter.drawRects(rects); ui->showlabel->setPixmap(pix); -// if(empty_flag == false) +// if(loss_flag) // { -// QDateTime time = QDateTime::currentDateTime();648 -// QString str = time.toString("yyyyMMddhhmmss"); -// QString filepath = RESULT_PATH + str + ".bmp";. -//#ifdef DEBUG -// cv::imwrite(filepath.toLatin1().data(), defect_pic); -//#else -// pix.save(filepath); -//#endif -// empty_flag = true; +//// uint8_t buf[3008] = {0}; +//// uint8_t zero[3000] = {0}; +////// socket->write((const char*)buf, 3000); +//// buf[0] = 0xAA; +//// buf[1] = 0x0B; +//// buf[2] = 0xBA; +//// buf[3] = 'd'; +//// buf[4] = 'a'; +//// buf[3005] = 0xFF; +//// buf[3006] = 0xFF; +//// buf[3007] = 0xBB; +//// memcpy(buf+5, zero, 3000); +//// socket->write((const char*)buf, 3008); +// loss_flag = false; // } - if(loss_flag) - { - uint8_t buf[2500] = {0}; - socket->write((const char*)buf, 2500); - loss_flag = false; - } } void Widget::showimage_test(cv::Mat img) @@ -684,6 +663,7 @@ void Widget::ServerNewConnection() ui->MCU_status->setStyleSheet("QLabel{background-color:rgb(0,255,0);}"); ui->MCU_status->setText(QString::fromLocal8Bit("已连接")); qDebug()<<"new connection"; + connect(socket, SIGNAL(readyRead()), this, SLOT(readfrom_lowermachine())); //char send_buf[13] = {0xAA, 0x00, 0x07, 'p', 'o', 'w', 'e', 'r', 'o', 'n', 0xFF, 0xFF, 0xBB}; //socket->write((const char*)send_buf, 13); @@ -785,7 +765,7 @@ void Widget::On_btnImportImg_click() } qDebug()<btnImportImg->setText(QString::fromLocal8Bit("导出中")); + ui->btnImportImg->setText(QString::fromLocal8Bit("导出中...")); +// ui->btnImportImg->setStyleSheet("background-color:rgb(255,0,0)"); + QApplication::processEvents(); system(command.toUtf8().data()); + ui->btnImportImg->setText(QString::fromLocal8Bit("导出图片\nExport Images")); +// ui->btnImportImg->setStyleSheet("background-color:rgb(0,255,0)"); } } @@ -1203,264 +1187,13 @@ void Widget::On_btn_channel_send_clicked() socket->write((const char*)buf, TRIGGER_PULSE_NUMBER * (VALVE_NUMBER / 8) + 8); } -//void Widget::On_btn_1_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("1"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("1"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_2_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("2"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("2"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_3_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("3"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("3"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_4_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("4"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("4"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_5_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("5"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("5"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_6_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("6"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("6"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_7_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("7"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("7"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_8_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("8"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("8"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_9_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("9"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("9"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_0_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("0"); -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("0"); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_dot_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QDoubleSpinbox")) -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// str.append("."); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_del_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// if(str.size()==0) return; -// str = str.left(str.size()-1); - -// spinbox->setValue(str.toInt()); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// int value = spinbox->value(); -// QString str = QString::number(value); -// if(str.size()==0) return; -// str = str.left(str.size()-1); -// spinbox->setValue(str.toDouble()); -// } -//} - -//void Widget::On_btn_clr_clicked() -//{ -// QWidget* m_widget = this->focusWidget(); -// if(m_widget->inherits("QSpinBox")) -// { -// QSpinBox* spinbox = qobject_cast(m_widget); -// spinbox->clear(); -// } -// else -// { -// QDoubleSpinBox* spinbox = qobject_cast(m_widget); -// spinbox->cleanText(); -// } -//} +void Widget::readfrom_lowermachine() +{ + char recbuf[8] = {0}; + int ret = socket->read(recbuf, 8); + if(ret > 0){ +// std::cout << "loss loss loss" << std::endl; +// fflush(0); + ui->label_warning->setText("error"); + } +} diff --git a/widget.h b/widget.h index b22c3a2..1b9faa7 100644 --- a/widget.h +++ b/widget.h @@ -11,6 +11,7 @@ #include "thread.h" #include "camera.h" #include "correct.h" +#include "qprocess.h" //#define DEBUG @@ -105,19 +106,7 @@ private slots: void On_btn0_clicked(); void On_btn_DEL_clicked(); -// void On_btn_1_clicked(); -// void On_btn_2_clicked(); -// void On_btn_3_clicked(); -// void On_btn_4_clicked(); -// void On_btn_5_clicked(); -// void On_btn_6_clicked(); -// void On_btn_7_clicked(); -// void On_btn_8_clicked(); -// void On_btn_9_clicked(); -// void On_btn_0_clicked(); -// void On_btn_dot_clicked(); -// void On_btn_del_clicked(); -// void On_btn_clr_clicked(); + void readfrom_lowermachine(); private: Ui::Widget *ui; diff --git a/widget.o b/widget.o index be862d3..86f7a8b 100644 Binary files a/widget.o and b/widget.o differ diff --git a/widget.ui b/widget.ui index 0656cdf..b723d8c 100644 --- a/widget.ui +++ b/widget.ui @@ -26,7 +26,7 @@ background-color: rgb(218, 239, 252); - 4 + 1 @@ -2811,6 +2811,27 @@ Parameters + + + + 530 + 530 + 141 + 41 + + + + + 18 + + + + color:rgb(255, 0, 0); + + + + +